Spring Quartz

前面写了关于Spring Quartz的基本配置方式,可以参考这个帖子:

http://zhangzhenting.iteye.com/blog/603021

 

下面是关于这个配置的另一种方式:

	<bean id="xxxManager" class="org.springframework.scheduling.quartz.JobDetailBean">
		<property name="jobClass" value="com.zzt.application.service.Xxx" />
		<property name="jobDataAsMap">
			<map>
				<entry key="xxx" value-ref="xxx"/>
			</map>
		</property>
	</bean>

	<bean id="xxxTrigger"
		class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="xxxManager" />
		<property name="cronExpression">
			<value>5/5 * * * * ?</value>
		</property>
	</bean>
	<bean
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref bean="xxxTrigger" />
			</list>
		</property>
	</bean>

 说明:

1.当指定的jobClass里面有属性注入时,需要在jobDataAsMap这个属性中列出来;

2.jobClass对于的Java类需要继承自org.springframework.scheduling.quartz.QuartzJobBean个类,并实现该抽象类里面的方法,如下:

    protected void executeInternal(JobExecutionContext jobExec) throws JobExecutionException
    {
        // do sth ...
    }

 

你可能感兴趣的:(spring,bean,quartz,Blog)