Java Reference
In-Depth Information
<bean name="documentReplicationJob"
class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass"
value="com.apress.springenterpriserecipes.replicator.FileReplicationJob" />
<property name="jobDataAsMap">
<map>
<entry key="fileReplicator" value-ref="documentReplicator" />
</map>
</property>
</bean>
Spring also offers MethodInvokingJobDetailFactoryBean for you to define a job that executes a
single method of a particular object. This saves you the trouble of creating a job class. You can use the
following job detail to replace the previous:
<bean id="documentReplicationJob" class="org.springframework.
scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="documentReplicator" />
<property name="targetMethod" value="replicate" />
</bean>
You can configure a Quartz SimpleTrigger object in Spring's bean configuration file through
SimpleTriggerBean , which requires a reference to a JobDetail object. This bean provides common
default values for certain trigger properties, such as using the bean name as the job name, setting
indefinite repeat count, and so on.
<bean id="documentReplicationTrigger"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="documentReplicationJob" />
<property name="repeatInterval" value="60000" />
<property name="startDelay" value="5000" />
</bean>
You can also configure a Quartz CronTrigger object in the bean configuration file through
CronTriggerBean .
<bean id="documentReplicationTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="documentReplicationJob" />
<property name="cronExpression" value=" 0 * * * * ? " />
</bean>
Finally, you can configure a SchedulerFactoryBean instance to create a Scheduler object for running
your trigger. You can specify multiple triggers in this factory bean.
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="documentReplicationTrigger" />
<!-- other triggers you have may be included here -->
</list>
</property>
</bean>
Search WWH ::




Custom Search