applicationContext_timer.xml 2.6 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
	定时器配置文件
-->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
	<!-- 营销发送定时器开始 -->
	<bean id="quartjob" class="com.espeed.yxy.timer.SendMailTimer" >
		<property name="yxysendmailservice" ref="yxysendmailservice"/>
	</bean>
	<bean id="objAndmethod"
		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="quartjob" />  
		<property name="targetMethod" value="timerMethod" />
	</bean>
	<bean id="dotime" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="objAndmethod" />
		</property>
		<property name="cronExpression">
			<!-- 
				<value>0/45 * * * * ?</value>
			 -->
			<value>0 0/1 * * * ?</value>
		</property>
	</bean>
	<!-- 营销发送定时器结束 -->
	
	<!-- 营销计划定时器开始 -->
	<bean id="markplanjob" class="com.espeed.yxy.timer.MarketingPlanTime" >
		<property name="marketingplanservice" ref="marketingplanservice"/>
		<property name="yxysendmailservice" ref="yxysendmailservice"/>
	</bean>
	<bean id="planobjmethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="markplanjob" />  
		<property name="targetMethod" value="marketingmethod" />
	</bean>
	<bean id="markplan" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="planobjmethod" />
		</property>
		<property name="cronExpression">
			<value>0/50 * * * * ?</value>
		</property>
	</bean>
	<!-- 营销计划定时器结束 -->
	
	<!--  管理类 如果将lazy-init='false'那么容器启动就会执行调度程序     -->
	<bean id="startQuartz" lazy-init="false" autowire="no"
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers" >
			<list>
				<ref bean="dotime"/>
				<ref bean="markplan"/>
			</list>
		</property>
	</bean>
	
	<!--  注入scheduler   -->
	<bean id="updatetime" class="com.espeed.yxy.timer.InitializingCronTrigger">
		<property name="scheduler" ref="startQuartz" />
	</bean>
	
</beans>