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. <a href="javascript:void(0);" id='test' onclick="javascript:alert('即将上线,敬请期待!');"><em class="rmwd"></em>征稿平台</a>

    <a href="javascript:void(0);" id='test' onclick="javascript:alert('即将上线,敬请期待!');&q ...

  2. 图文讲解:iOS App提交流程

    原文:http://www.toceansoft.com/ios/3287.jhtml 一.证书的导出 1.1.前期工作 首先你需要有一个苹果的开发者帐号,一个Mac系统. 如果没有帐号可以在打开ht ...

  3. 修改mysql字符编码出现Job failed to start解决办法

        从网上找到如下资料: $sudo gedit /etc/mysql/my.cnf [client]下添加: default-character-set=utf8 [mysqld]下添加: de ...

  4. AngularJS~集成的ajax和服务的注入

    AngularJS很美,以至于迷倒了不少年青人和我这位大叔,它的美不仅仅是在写法上,而且在设计方法上都进乎于完美,用什么服务就注入什么服务,这样方法本来就很直观,程序员感觉直观了,程序在运行起来也按需 ...

  5. wikioi 3027 线段覆盖 2

    题目描述 Description 数轴上有n条线段,线段的两端都是整数坐标,坐标范围在0~1000000,每条线段有一个价值,请从n条线段中挑出若干条线段,使得这些线段两两不覆盖(端点可以重合)且线段 ...

  6. 音频视频播放(jquery中将jquery方法转化成js方法)

    在jQuery中没有音频视频直接播放的方法,我们在写音频视频时,应该将jquery的方法转化为js方法:play():pause() 补充:   将jq对象转化成js对象写法: var music=$ ...

  7. Lambda表达式实现有限状态机

    实现状态机有多种模式,其中最灵活而强大的方式是通过迁移表来实现,该方式的缺点之一是需要编写大量小块代码去支持迁移表.而在C#3.0中,可以以一种非常优雅的方式实现. 除了有限状态机外,还有有限自动机, ...

  8. search result

    https://github.com/search?l=java&p=86&q=Floating+window&type=Code&utf8=%E2%9C%93http ...

  9. [安卓学习]AndroidManifest.xml文件内容详解

    一,重要性 AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根 ...

  10. phonegap platform add ios 出错的问题

    在Mac上新安装的Phonegap,版本3.3-0.18.0. 本来创建项目后按教程: http://docs.phonegap.com/en/edge/guide_platforms_ios_ind ...