projects implemented in the use Quartz Web schedule,
mainly introduce jar package, complete the basic configuration.
first be configured to be automatically executed Class and Class in the regular implementation of the method:
property name = "targetObject" ref corresponding Class
property name = "targetMethod" ref corresponding Method
<bean id="exportJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="exportFileManager" />
</property>
<property name="targetMethod">
<value>fileExport2</value>
</property>
</bean>
exportFileManager I have in the Spring configuration file :
<bean id="exportFileManager" parent="managerProxyTemplate">
<property name="target">
<bean class="com.wonders.mywebapp.infobackup.service.ExportFileManager">
<property name="efilesDAO" ref="efilesDao"/>
<property name="personInfoDao" ref="personInfoDao"/>
</bean>
</property>
</bean>
then configure the method execution time :
property name = "jobDetail" ref just configured jobDetail
property name = "cronExpression" ref regular time
<bean id="cronTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="exportJobDetail" />
</property>
<property name="cronExpression">
<value>0 46 19 * * ?</value>
</property>
</bean>
Finally the last step defined triggers, unified management to the schedule :,
Use because of a configuration file can define multiple regular implementation of the Method, just need to add each trigger in list , you can
<bean
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="writeTrigger" />
<ref local="cronTrigger" />
</list>
</property>
</bean>
finally adding the total spring configuration xml file, complete the configuration.
没有评论:
发表评论