- 浏览: 780176 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (386)
- Linux (36)
- Tomcat (6)
- windows (8)
- Apache (10)
- Java (25)
- jquery (7)
- Jquery 插件 (3)
- Oracle (5)
- Oracle SQL (68)
- Spring (15)
- 开发工具 (6)
- Struts (20)
- js (14)
- Project Code (2)
- Project Code Tomcat (1)
- libset (1)
- JSP (8)
- arithmetic (2)
- 浏览器 (1)
- extjs (3)
- 学习网站 (5)
- 生活情感 (0)
- 电话号码算法 (3)
- 快捷键 (1)
- 转载 (1)
- Dos命令 (2)
- services (1)
- Resources (1)
- 行业积累 (3)
- 项目积累 (3)
- Web (3)
- 文档 (1)
- JavaEE (2)
- JSF (3)
- http (3)
- JS窗口 (1)
- Html (4)
- Flex (1)
- 资讯 (2)
- 项目规范 (1)
- Struts s:property textarea中默认值用 (1)
- Quartz 2.0.2 (12)
- 1天有多少毫秒 (1)
- 专题 (1)
- intellij idea 10 CD-KEY (1)
- restlet (4)
- Mail (1)
- Excel (3)
- Menu (1)
- Big Data技术综述 (1)
- Quart 1 (1)
- nosql (1)
- linux远程 (1)
- jdk (5)
- wind7 (1)
- 虚拟人 (0)
- 虚拟机 (1)
- 终端 (1)
- Ubuntu (16)
- Myeclipse (2)
- Wmware (1)
- eclipse (2)
- css (2)
- csv (1)
- 开源 (1)
- plsql (2)
- cassandra (4)
- maven (1)
- hadoop (2)
- mysql (1)
- spring security (1)
- tools (1)
- jdbc (2)
- exception (2)
- 硬盘数据备份 (1)
- dwr (1)
- svn (1)
- PowerDesigner15使用时的十五个问题 (1)
- tomcat 项目发部路径 (1)
- js 暂停执行 (1)
- jquery jqgrid 格式化数据显示 (1)
- js 代码模板 (1)
- strutss2 直接跳转到jsp页面 (1)
- servlet (1)
- jdbc spring (1)
- js学习网站 (1)
- 自学考试 (2)
- hibernate (2)
- eos (1)
- c (4)
- 黑马 (2)
- 大数据 (2)
- 实战云大数据案例分享 (0)
- Spark (2)
- Flink (1)
最新评论
-
coosummer:
推荐使用http://buttoncssgenerator.c ...
jquery button 漂亮 -
thinktothings:
Array_06 写道你好,我是一名刚毕业学生,我以后就是做J ...
如何转型架构师 -
thinktothings:
软考,考有职业资格证,有系统的知识体系学习
如何转型架构师 -
Array_06:
你好,我是一名刚毕业学生,我以后就是做Java的架构师,那请问 ...
如何转型架构师 -
beykery:
你这也太复杂了。。。。jsf2不应该是这样的。。。。
JSF2.0的一个简单Demo
Quartz Enterprise Job Scheduler Tutorial
Lesson 2: The Quartz API, and Introduction to Jobs And Triggers
The Quartz API
The key interfaces of the Quartz API are:
- Scheduler - the main API for interacting with the scheduler.
- Job - an interface to be implemented by components that you wish to have executed by the scheduler.
- JobDetail - used to define instances of Jobs.
- Trigger - a component that defines the schedule upon which a given Job will be executed.
- JobBuilder - used to define/build JobDetail instances, which define instances of Jobs.
- TriggerBuilder - used to define/build Trigger instances.
A Scheduler 's life-cycle is bounded by it's creation, via a SchedulerFactory and a call to its shutdown() method. Once created the Scheduler interface can be used add, remove, and list Jobs and Triggers, and perform other scheduling-related operations (such as pausing a trigger). However, the Scheduler will not actually act on any triggers (execute jobs) until it has been started with the start() method, as shown in Lesson 1 .
Quartz provides "builder" classes that define a Domain Specific Language (or DSL, also sometimes referred to as a "fluent interface"). In the previous lesson you saw an example of it, which we present a portion of here again:
// define the job and tie it to our HelloJob class JobDetail job = newJob(HelloJob.class) .withIdentity("myJob", "group1") // name "myJob", group "group1" .build(); // Trigger the job to run now, and then every 40 seconds Trigger trigger = newTrigger() .withIdentity("myTrigger", "group1") .startNow() .withSchedule(simpleSchedule() .withIntervalInSeconds(40) .repeatForever()) .build(); // Tell quartz to schedule the job using our trigger sched.scheduleJob(job, trigger);
The block of code that builds the job definition is using methods that were statically imported from the JobBuilder class. Likewise, the block of code that builds the trigger is using methods imported from the TriggerBuilder class - as well as from the SimpleScheduleBulder class.
The static imports of the DSL can be achieved through import statements such as these:
import static org.quartz.JobBuilder.*; import static org.quartz.SimpleScheduleBuilder.*; import static org.quartz.CronScheduleBuilder.*; import static org.quartz.CalendarIntervalScheduleBuilder.*; import static org.quartz.TriggerBuilder.*; import static org.quartz.DateBuilder.*;
The various "ScheduleBuilder " classes have methods relating to defining different types of schedules.
The DateBuilder class contains various methods for easily constructing java.util.Date instances for particular points in time (such as a date that represents the next even hour - or in other words 10:00:00 if it is currently 9:43:27).
Jobs and Triggers
A Job is a class that implements the Job interface, which has only one simple method:
The Job Interface
package org.quartz; public interface Job { public void execute(JobExecutionContext context) throws JobExecutionException; }
When the Job's trigger fires (more on that in a moment), the execute(..) method is invoked by one of the scheduler's worker threads. The JobExecutionContext object that is passed to this method provides the job instance with information about its "run-time" environment - a handle to the Scheduler that executed it, a handle to the Trigger that triggered the execution, the job's JobDetail object, and a few other items.
The JobDetail object is created by the Quartz client (your program) at the time the Job is added to the scheduler. It contains various property settings for the Job, as well as a JobDataMap , which can be used to store state information for a given instance of your job class. It is essentially the definition of the job instance, and is discussed in further detail in the next lesson.
Trigger objects are used to trigger the execution (or 'firing') of jobs. When you wish to schedule a job, you instantiate a trigger and 'tune' its properties to provide the scheduling you wish to have. Triggers may also have a JobDataMap associated with them - this is useful to passing parameters to a Job that are specific to the firings of the trigger. Quartz ships with a handful of different trigger types, but the most commonly used types are SimpleTrigger and CronTrigger.
SimpleTrigger is handy if you need 'one-shot' execution (just single execution of a job at a given moment in time), or if you need to fire a job at a given time, and have it repeat N times, with a delay of T between executions. CronTrigger is useful if you wish to have triggering based on calendar-like schedules - such as "every Friday, at noon" or "at 10:15 on the 10th day of every month."
Why Jobs AND Triggers? Many job schedulers do not have separate notions of jobs and triggers. Some define a 'job' as simply an execution time (or schedule) along with some small job identifier. Others are much like the union of Quartz's job and trigger objects. While developing Quartz, we decided that it made sense to create a separation between the schedule and the work to be performed on that schedule. This has (in our opinion) many benefits.
For example, Jobs can be created and stored in the job scheduler independent of a trigger, and many triggers can be associated with the same job. Another benefit of this loose-coupling is the ability to configure jobs that remain in the scheduler after their associated triggers have expired, so that that it can be rescheduled later, without having to re-define it. It also allows you to modify or replace a trigger without having to re-define its associated job.
Identities
Jobs and Triggers are given identifying keys as they are registered with the Quartz scheduler. The keys of Jobs and Triggers (JobKey and TriggerKey) allow them to be placed into 'groups' which can be useful for organizing your jobs and triggers into categories such as "reporting jobs" and "maintenance jobs". The name portion of the key of a job or trigger must be unique within the group - or in other words, the complete key (or identifier) of a job or trigger is the compound of the name and group.
You now have a general idea about what Jobs and Triggers are, you can learn more about them in Lesson 3: More About Jobs & JobDetails and Lesson 4: More About Triggers .
- UsingQuartz.zip (858.7 KB)
- 下载次数: 2
发表评论
-
quartz 执行时间配置
2011-09-26 10:23 2515CronTrigger Tutorial Intro ... -
1天有多少毫秒
2011-07-28 14:43 18611、 --1天有多少毫秒 1天=86400000 ... -
Lesson 7: TriggerListeners and c
2011-07-27 14:41 1667Quartz Enterprise Job Scheduler ... -
Lesson 6: CronTrigger
2011-07-27 14:28 1286Quartz Enterprise Job Scheduler ... -
Lesson 5: SimpleTrigger
2011-07-27 14:22 1227Quartz Enterprise Job Scheduler ... -
Lesson 4: More About Triggers
2011-07-27 14:14 1102Quartz Enterprise Job Scheduler ... -
Lesson 3: More About Jobs and Job Details
2011-07-27 11:58 1370Quartz Enterprise Job Scheduler ... -
Lesson 1: Using Quartz
2011-07-27 11:22 1086Quartz Enterprise Job Scheduler ... -
Examples Overview
2011-07-27 10:24 1026Examples Overview Welcome to t ... -
CronTrigger Tutorial
2011-07-27 10:04 1098http://www.quartz-scheduler.o ... -
quartz-2.0.2-examples
2011-07-27 07:58 1492Cron Triggers Expression ...
相关推荐
《Lesson 1: 使用Quartz》 在IT领域,任务调度是系统自动化的重要组成部分,而Quartz是一款功能强大且广泛使用的Java作业调度框架。本文将深入探讨如何利用Quartz进行任务管理和执行,以及其在实际项目中的应用。 ...
"Lesson 3: More About Jobs and Job Details"这个主题聚焦于如何更深入地理解任务(Jobs)以及它们的相关细节。在这个教程中,我们将探讨任务管理的核心概念、相关的工具,以及如何通过源码分析来了解其工作原理。 ...
包含翻译后的API文档:quartz-2.3.0-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.quartz-scheduler:quartz:2.3.0; 标签:scheduler、quartz、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用...
本课"Lesson 4: More About Triggers"深入探讨了触发器的使用和实现细节。 在关系型数据库中,触发器主要用于实现数据完整性、业务规则的强制和审计跟踪等功能。当数据发生变化时,它们可以执行复杂的操作,这些...
QuartzAPI是一个强大的任务调度库,广泛用于Java应用程序中,以实现定时任务的自动化执行。这个"QuartzAPI中文chm"文档是专门为中文用户设计的学习资源,旨在帮助开发者快速理解和掌握Quartz的核心功能和使用方法。 ...
包含翻译后的API文档:quartz-2.3.2-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.quartz-scheduler:quartz:2.3.2; 标签:quartz、scheduler、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用...
这个API文档详细地介绍了如何使用Quartz进行任务的定时执行。Quartz的核心概念包括Job(作业)、Trigger(触发器)和Scheduler(调度器)。下面我们将深入探讨这些概念以及它们在实际开发中的应用。 1. **Job**:在...
【标题】:“Introduction to Quartz(2)” 【描述】:这篇博客主要介绍了Quartz,一个开源的作业调度框架,用于在Java应用程序中实现任务调度。Quartz允许开发人员定义作业和触发器,以便在特定时间执行预定的任务...
包含翻译后的API文档:quartz-2.3.2-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.quartz-scheduler:quartz:2.3.2; 标签:scheduler、quartz、jar包、java、中英对照文档; 使用方法:解压翻译后...
Quartz API的设计基于两个主要概念:Jobs(作业)和Triggers(触发器)。Jobs是实际要执行的工作单元,它们实现了`org.quartz.Job`接口,并通过`execute()`方法来定义其执行逻辑。而Triggers则定义了何时以及如何...
3. **Scheduler**:Scheduler是整个调度系统的管理者,它负责管理和执行Jobs与Triggers。通过Scheduler,你可以安排新的Job,暂停、恢复或删除已有的Job,以及控制Trigger的执行。 4. **Calendar**:Calendar是用于...
Quartz API 是一个开源的 Java 任务调度框架,它允许开发者在应用程序中创建、调度和管理作业(Jobs)和触发器(Triggers)。这个“quartzAPI-2.2.1参看文档”包含了关于 Quartz 2.2.1 版本的详细信息,非常适合学习...
2. **Carbon与Quartz**:Carbon是另一种开发MacOS应用的技术栈,虽然不如Cocoa流行,但依然可以使用Quartz 2D进行图形处理。 3. **跨平台移植**:如果开发者需要将代码从其他平台(如Windows、Linux)移植到MacOS,...
5. **易用性**:Quartz提供了一套直观的API,使得开发者能够方便地创建、调度和管理任务。 在Java开发中,使用Quartz通常涉及以下步骤: 1. **定义Job类**:创建一个实现了`org.quartz.Job`接口的类,这个类包含了...
2. **Recovering Jobs**:Quartz能够恢复因异常而未完成的Job。如果Job在执行时发生错误,Quartz可以尝试重新调度该Job。 3. **Clustered Schedulers**:在分布式环境中,Quartz支持集群,多个调度器可以在不同的...
The Quartz 2D API is easy to use and provides accessto powerful featuressuch astransparency layers, path-based drawing, offscreen rendering, advanced color management, anti-aliased rendering, and PDF ...
2. **Scheduler**:Scheduler是Quartz的核心组件,负责管理和调度所有的Job和Trigger。你可以通过Scheduler实例来安排新的任务,或者修改已有的任务。 3. **CalendarIntervalTrigger**和**CronTrigger**:这两者是...
- **代码重用**:利用Quartz 2D和Cocoa提供的API,可以编写高度可重用的代码模块。 - **跨平台兼容性**:虽然本书主要介绍在Mac OS X上的应用,但很多技术和概念也可以应用于其他平台,如iOS或Windows。 #### 六、...
Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用中。它提供了巨大的灵活性而不牺牲简单性。你能够用它来为执行一个作业而创建简单的或复杂的...
Quartz提供了丰富的API来创建、管理和控制作业(Jobs)和触发器(Triggers),使得开发者能够灵活地定义任务执行规则。 在Quartz中,核心概念包括: 1. **Job**: 代表一个具体的任务,是需要执行的工作单元。Job不...