TriggerListeners and JobListeners

Listeners are objects that you create to perform actions based on events occurring within the scheduler. As indicated by their names, TriggerListeners receive events related to triggers, and JobListeners receive events related to jobs.

TriggerListener

Trigger-related events include: trigger firings, trigger misfirings, and trigger completions (the jobs fired off by the trigger is finished).

The org.quartz.TriggerListener Interface

public interface TriggerListener {
public String getName();
public void triggerFired(Trigger trigger, JobExecutionContext context);
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context);
public void triggerMisfired(Trigger trigger);
public void triggerComplete(Trigger trigger, JobExecutionContext context, int triggerInstructionCode);
}

JobListener

Job-related events include: a notification that the job is about to be executed, and a notification when the job has completed execution.

The org.quartz.JobListener Interface

public interface JobListener {
public String getName();
public void jobToBeExecuted(JobExecutionContext context);
public void jobExecutionVetoed(JobExecutionContext context);
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException);
}

Creating Your Own Listeners

To create a listener, simply create an object that implements the org.quartz.TriggerListener and/or org.quartz.JobListener interface.

Listeners are then registered with the scheduler at run time, and must be given a name (or rather, they must advertise their own name via their getName() method).

For your convenience, rather than implementing these interfaces, your class could also extend the class JobListenerSupport or TriggerListenerSupport and simply override the events you're interested in.

Listeners are registered with the scheduler's ListenerManager along with a Matcher that describes the Jobs/Triggers for which the listener wants to receive events.

Listeners are not used by most users of Quartz, but are handy when application requirements create the need for the notification of events, without the Job itself having to explicitly notify the application

Code Samples for Adding Listeners

The following code samples illustrate ways to add JobListeners with interest in different types of jobs. Adding TriggerListeners works in a the same way.

scheduler.getListenerManager().addJobListener(myJobListener, KeyMatcher.jobKeyEquals(new JobKey("myJobName", "myJobGroup")));

Quartz Scheduler(2.2.1) - Working with TriggerListeners and JobListeners的更多相关文章

  1. Table of Contents - Quartz Scheduler

    Getting Started Hello World Integration with Spring Quartz Scheduler Developer Guide Usage of JobDat ...

  2. Quartz Scheduler(2.2.1) - Working with SchedulerListeners

    SchedulerListeners SchedulerListeners are much like TriggerListeners and JobListeners, except they r ...

  3. spring集成quartz scheduler

    创建项目 有两种创建quart配置作业 1.使用MethodInvokingJobDetailFactoryBean  Quartz Scheduler 配置作业(MethodInvokingJobD ...

  4. Quartz Scheduler(2.2.1) - hello world

    简单示例 1. maven 依赖 <dependencies> <dependency> <groupId>org.quartz-scheduler</gro ...

  5. Quartz Scheduler(2.2.1) - Working with JobStores

    About Job Stores JobStores are responsible for keeping track of all the work data you give to the sc ...

  6. Quartz Scheduler 开发指南(1)

    Quartz Scheduler 开发指南(1) 原文地址:http://www.quartz-scheduler.org/generated/2.2.2/html/qtz-all/ 实例化调度程序( ...

  7. 最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 任务调度示例

    参考http://blog.csdn.net/defonds/article/details/49496895 本文将演示如何通过 Spring 使用 Quartz Scheduler 进行任务调度. ...

  8. 整合shiro出现【Correct the classpath of your application so that it contains a single, compatible version of org.quartz.Scheduler】

    跑的时候出现错误: Description: An attempt was made to call the method org.quartz.Scheduler.getListenerManage ...

  9. Quartz Scheduler(2.2.1) - Integration with Spring

    1. maven 依赖: <properties> <spring.version>3.2.3.RELEASE</spring.version> <quart ...

随机推荐

  1. UVA 11354 Bond(MST + LCA)

    n<=50000, m<=100000的无向图,对于Q<=50000个询问,每次求q->p的瓶颈路. 其实求瓶颈路数组maxcost[u][v]有用邻接矩阵prim的方法.但是 ...

  2. Sql CLR

    using System;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using Microsof ...

  3. android EditText控制光标的位置

    利用自定义键盘,需要手动删除编辑框中的文本时,会根据光标的位置来删除字符.那么,如何来控制光标呢,android为我们提供了哪些方法,来处理光标呢? 这里提供几个自己写的方法,根据这些方法可以满足在光 ...

  4. Servlet 总结

    1,什么是Servlet2,Servlet有什么作用3,Servlet的生命周期4,Servlet怎么处理一个请求5,Servlet与JSP有什么区别6,Servlet里的cookie技术7,Serv ...

  5. 关于Linux vi命令 vi命令一览表

    vi是所有UNIX系统都会提供的屏幕编辑器,它提供了一个视窗设备,通过它可以编辑文件.当然,对UNIX系统略有所知的人,或多或少都觉得vi超级难用,但vi是最基本的编辑器,学好了vi,以后在UNIX世 ...

  6. 对iOS中MVC的理解

    总结于斯坦福大学的白头发老头的公开课 模型-控制器-视图(MVC)是一种将应用中给所有类组织起来的策略 模型(Model)实际上考虑的是“什么”的问题,即你的程序是什么? 以纸牌匹配游戏为例子,模型就 ...

  7. 【SQL】导出表数据到Excel中

    打开数据库之后点击新建表查询: ------------------------------------------------------------------------------------ ...

  8. iOS常用动画代码

    使用前 需引入QuartzCore.framework, 并在相关文件中加入 #import "QuartzCore/QuartzCore.h" 定义 shakeFeedbackO ...

  9. osg通过glsl实现一个平面的水效果(法线贴图) 【转】

    转自 http://blog.sina.com.cn/s/blog_78ea87380101ehk3.html 此文实现一个简单的的水面效果,主要是法线贴图, 效果图如下:   此文分为三部分:ver ...

  10. 【android】在eclipse中查看genymotion模拟器的sd卡文件夹

    假设用google自带模拟器或者真机调试时,sd卡文件夹是在/mnt/sdcard.这个相信大家都知道. 但是今天用genymotion调试时.发现根本打不开/mnt/sdcard这个文件夹,当时也没 ...