Timermanager is automatically loaded on the web to manage the timer chain. An exception occurs when the class Update Server is hot loaded. This requires some extraordinary processing of timermanager to ensure the correctness of the timer chain.
The automatic timertask loading function provided by Spring framework can easily implement Timer chain management. At the same time, using the Spring framework function can easily add and delete timers.
1. Declare in Web. xml
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
<Param-value>/WEB-INF/schedulingContext-timer.xml </param-value>
</Context-param>
<Servlet>
<Servlet-Name> context </servlet-Name>
<Servlet-class> org. springframework. Web. Context. contextloaderservlet </servlet-class>
<Load-on-startup> 3 </load-on-startup>
</Servlet>
2. Describe the user's timer in schedulingContext-timer.xml
<Bean id = "timer" class = "org. springframework. Scheduling. Timer. timerfactorybean">
<Property name = "scheduledtimertasks">
<List>
<Ref local = "jorwangscheduledtimertask1"/>
</List>
</Property>
</Bean>
<Bean id = "jortimetask1" class = "workflow. Common. mytimer">
</Bean>
<Bean id = "jorwangscheduledtimertask1" class = "org. springframework. Scheduling. Timer. scheduledtimertask">
<Property name = "timertask"> <ref bean = "jortimetask1"/> </property>
<Property name = "delay"> <value> 10000 </value> </property>
<Property name = "Period"> <value> 86400000 </value> </property>
</Bean>
3. Compile the workflow. Common. mytimer timer.
In this way, the timer function is easily completed. To modify, add, or delete a timer, you only need to adjust the content in steps 2 and 3.