Quartz Scheduler(2.2.1) - Working with TriggerListeners and JobListeners
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的更多相关文章
- Table of Contents - Quartz Scheduler
Getting Started Hello World Integration with Spring Quartz Scheduler Developer Guide Usage of JobDat ...
- Quartz Scheduler(2.2.1) - Working with SchedulerListeners
SchedulerListeners SchedulerListeners are much like TriggerListeners and JobListeners, except they r ...
- spring集成quartz scheduler
创建项目 有两种创建quart配置作业 1.使用MethodInvokingJobDetailFactoryBean Quartz Scheduler 配置作业(MethodInvokingJobD ...
- Quartz Scheduler(2.2.1) - hello world
简单示例 1. maven 依赖 <dependencies> <dependency> <groupId>org.quartz-scheduler</gro ...
- 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 ...
- Quartz Scheduler 开发指南(1)
Quartz Scheduler 开发指南(1) 原文地址:http://www.quartz-scheduler.org/generated/2.2.2/html/qtz-all/ 实例化调度程序( ...
- 最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 任务调度示例
参考http://blog.csdn.net/defonds/article/details/49496895 本文将演示如何通过 Spring 使用 Quartz Scheduler 进行任务调度. ...
- 整合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 ...
- Quartz Scheduler(2.2.1) - Integration with Spring
1. maven 依赖: <properties> <spring.version>3.2.3.RELEASE</spring.version> <quart ...
随机推荐
- WebForm 回传后如何保持页面的滚动位置
转载自 http://www.cnblogs.com/renjuwht/archive/2009/06/17/1505000.html 默认情况下,ASP.NET页面回传到服务器后,页面会跳回顶部.对 ...
- 解决Java版CKFinder无法显示缩略图问题
这些天在写我的Java EE项目的时候用到了CKEditor和CKFinder,但是在用CKFinder的时候无法显示图片的缩略图,但是官网上的demo上却有缩略图,我一直以为是自己配置错误了,我把官 ...
- hibernateTemplate HibernateDaoSupport不建议在Spring与Hibernate整合中使用
HibernateTemplate类属于spring框架中的类 :org.springframework.orm.hibernate3.HibernateTemplate HibernateTempl ...
- zookeeper的C#Client
最近在搭一套soa, 服务使用java/scala 的finagle 协议使用thrift 然后 finagle默认服务端会是使用zookeeper作为节点存储.. 所以想要访问具体服务,需要先通过 ...
- ASP.NET MVC 3 入门级常用设置、技巧和报错
1.ASP.NET MVC 3 如何去除默认验证 这个默认验证是在web.config配置文件中设置的 <add key="ClientValidationEnabled&quo ...
- Codeforces Round #327 (Div. 2) D. Chip 'n Dale Rescue Rangers 二分 物理
D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- Winform 水印TextBox
方法一: public partial class WaterTextBox : TextBox { private readonly Label lblwaterText = new Label() ...
- [Ramda] Basic Curry with Ramda
var _ = R; /***************************************** C U R R Y I N G E X A M P L E **************** ...
- PHP概率算法(适用于抽奖、随机广告)
做网站类的有时会弄个活动什么的,来让用户参加,既吸引用户注册,又提高网站的用户活跃度.同时参加的用户会获得一定的奖品,有100%中奖的,也有按一定概率中奖的,大的比如中个ipad.iphone5,小的 ...
- 一条直线上N个线段所覆盖的总长度
原文:http://blog.csdn.net/bxyill/article/details/8962832 问题描述: 现有一直线,从原点到无穷大. 这条直线上有N个线段.线段可能相交. 问,N个线 ...