声明触发器loadPortalUserLoginOrLogoutTrigger
<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>
定义触发器loadPortalUserLoginOrLogoutTrigger(条件模式)
<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秒执行一次
调用实体类PortalUserLoginOrLogout,制定调用的方法executeTask
<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>
声明实体类PortalUserLoginOrLogout
<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秒一次