标签:spring
<bean id="quartzSchedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local=" loadPortalUserLoginOrLogoutTrigger "/>
</list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.threadPool.threadCount">30</prop>
</props>
</property>
</bean>
<bean id="loadPortalUserLoginOrLogoutTrigger" class= "org.springframework.scheduling.quartz.CronTriggerBean">
<property name= "jobDetail">
<ref bean= "loadPortalUserLoginOrLogoutDetail"/>
</property>
<property name="cronExpression">
<value>0/30 * * * * ?</value>
</property>
</bean>
该触发器设置为从0秒开始,每30秒执行一次
<bean id="loadPortalUserLoginOrLogoutDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<property name="targetObject">
<ref bean="PortalUserLoginOrLogout"/>
</property>
<property name="concurrent" value="false"/>
<property name="targetMethod">
<value>executeTask</value>
</property>
</bean>
<bean id="PortalUserLoginOrLogout" class="com.wafer.wse.device.job.impl.PortalUserLoginOrLogoutImpl"></bean>
public interface PortalUserLoginOrLogout {
/**
* 执行计划操作
*/
public void executeTask();
}
public class PortalUserLoginOrLogoutImpl implements PortalUserLoginOrLogout{
private final Logger LOGGER = Logger.getLogger(PortalUserLoginOrLogoutImpl.class);
private LogOperatorDAO logOperDao;
private DeviceIfService deviceIfService;
private DeviceDAO devicedao;
@Override
public synchronized void executeTask() {}
}
实现的方法就会在executeTask中执行,每30秒一次
标签:spring
原文地址:http://tianjian.blog.51cto.com/3549910/1665975