首页 > 其他 > 详细

记录一下Spring+Quertz的过程

时间:2014-02-17 05:01:30      阅读:329      评论:0      收藏:0      [点我收藏+]

实体类 extends QuartzJobBean

/**
 * 
 * @author Frank
 *@date 2014 02-16
 */

public class MyJobServiceImple extends QuartzJobBean {
	private SmartMenuScheduleService smartMenuScheduleService;

	@Override
	protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
		/**
		 * 调用同步方法
		 */
		this.getSmartMenuScheduleService().sendMenuSchedule();
	}

	public SmartMenuScheduleService getSmartMenuScheduleService() {
		return smartMenuScheduleService;
	}

	public void setSmartMenuScheduleService(SmartMenuScheduleService smartMenuScheduleService) {
		this.smartMenuScheduleService = smartMenuScheduleService;
	}

}

Xml配置

        <bean id="myJob" class="org.springframework.scheduling.quartz.JobDetailBean">
		<property name="jobClass" value="com.hestia.mosa.menu.service.MyJobServiceImple" />
 		<property name="jobDataAsMap">
			<map>
				<entry key="smartMenuScheduleService">
					<ref bean="smartMenuScheduleService" />
				</entry>
			</map>
		</property>
	</bean>
 
	<!-- 同步触发器 -->
	<bean id="groupCustomerTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="myJob" />
		<!-- Cron表达式:每天凌晨1点执行一次 -->
		<property name="cronExpression">
			<value>0 0 1 * * ?</value>
		</property>
	</bean>

	<!-- 任务调度器 如果将lazy-init=‘false‘那么容器启动就会执行调度程序 -->
	<bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="transactionManager" ref="transactionManager" />
		<property name="triggers">
			<list>
				<ref bean="groupCustomerTrigger" />
			</list>
		</property>
		<property name="quartzProperties">
			<map>
				<entry key="org.quartz.threadPool.threadCount" value="1" />
			</map>
		</property>
	</bean>



记录一下Spring+Quertz的过程

原文:http://blog.csdn.net/pengchengmm/article/details/19290215

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!