QUARTZ SCHEDULER AND LOGGING

本文介绍了Spring框架中定时任务的两种实现方式:SimpleTriggerBean和CronTriggerBean。SimpleTriggerBean类似于ScheduledTimerTask,可以指定任务运行频率及首次执行的延迟时间。CronTriggerBean则允许使用Cron表达式来精确指定任务的执行时间和日期。此外,还探讨了Quartz应用的运行时行为配置,包括JobStore的作用以及日志系统的实现。

spring comes with two subclasses of trigger: simplertriggerbean and crontriggerbean. simplertiggerbean is very similar to

scheduledtimertask. you can specify how often a job should run and how long to wait before running the job for the first

time.crontiggerbean is another spring subclass of quartz's tigger class. this trigger class lets you specify exact times and

days when the job will run. crontirggerbean lets you use a cron expression to specify exact times that a job will run.  the

cronexpression property tells the trigger when to fire. cronexpression is made up of six time elements separated by

spaces. the quartz.properties file defines the runtime behavior of the quartz application and contains many properties that

can be set to control how quartz behaves.you should use one of the factory methods to ensure that all facets of the

scheduler are instantiated and initialized properly. quickly simply, a quartz job is a java class that performs a task on your

behalf. when the scheduler calls a job, a jobexecutioncontext is passed to the execute method. the job executioncontext is

an object that gives the job access to the runtime environment of quartz and the detaild of job itself. this is analogous to a

java web application in which a servlet has access to the servletcontext. from rhe jobexecutioncontext, the job can access

everything about its environment including the jobdetail and trigger that were registered with the scheduler for the job. the

question mark character can be used only in the dayofmoneth and day of week fields,but not at the same time. you can

think of the ? character as i donot care what valur is in this field. the scheduler uses the configured jobstore to store and

retrieve scheduling information and to determine its responsibilities for triggering jobs. quartz supports several different

types of storage mechanisms for scheduler information.  the api for the jobstore interface can be generated into the

following categories: job-related api trigger-related api calendar-related api and scheduler-related api. rmi is a

mechanism that enables an object in one address space to cummunicate with obhecrs in a different address space.

logging is a systematic and controlled way of representing the state of an application in a human-readable fashion. the

logging components have the freedom to publish logging information to any destination of choice such as a file,console,

database,or remote location. a logging package should provide flexibility in terms of what to log and where to log. the jdk

logging api consists of several objects that capture logging information and process and publish the intended logging

information to any preferred destination. the java.util.logging.logrecord object encapsulates all the logging information. the

java.util.logging.handler object is responsible for publishing logging information to various destinations- a file,

console,memory buffer. each logger provides a number of different logging methods.  the streamhandler class acts as a

base class for any stream-based handler. it is possible to specifiy a java.io.outputstream object. a streamhandler acquires the following initialization properties.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值