The first part of the increase is the implementation of the program code, this article we will use the configuration file timer configuration, reduce the amount of code, improve flexibility.
1, need to use the document: Quartz.properties, it is said that this file if not, according to the default, the results of the deployment to Tomcat, prompted to find the file;
#============================================================================# Configure Main Scheduler Properties #============================================================================org.quartz.scheduler.instancename = QuartzSchedulerorg.quartz.scheduler.instanceId = auto#========================================================== ==================# Configure ThreadPool #======================================================================= =====org.quartz.threadpool.class = Org.quartz.simpl.SimpleThreadPoolorg.quartz.threadPool.threadCount = 2org.quartz.threadpool.threadpriority = 5#====================================================================== ======# Configure Jobstore #============================================================================ Org.quartz.jobStore.misfireThreshold = 60000org.quartz.jobstore.class = org.quartz.simpl.ramjobstore#============= ===============================================================# Configure Plugins #============================================================================org.quartz.plugin.trigghistory.class = Org.quartz.plugins.history.LoggingJobHistoryPluginorg.quartz.plugin.jobInitializer.class = Org.quartz.plugins.xml.JobInitializationPluginorg.quartz.plugin.jobInitializer.fileNames = Jobs.xmlorg.quartz.plugin.jobInitializer.overWriteExistingJobs = Trueorg.quartz.plugin.jobInitializer.failOnFileNotFound = Trueorg.quartz.plugin.jobInitializer.scanInterval = 10org.quartz.plugin.jobinitializer.wrapinusertransaction = False
2, Jobs.xml, the above mentioned configuration file, configuration trigger and job name, etc.;
<?XML version= ' 1.0 ' encoding= ' utf-8 '?><Quartzxmlns= "Http://www.opensymphony.com/quartz/JobSchedulingData"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.opensymphony.com/quartz/JobSchedulingData http://www.opensymphony.com/quartz/xml/job_ Scheduling_data_1_5.xsd "version= "1.5"> <Job> <Job-detail> <name>HelloWorld</name> <Group>DEFAULT</Group> <Description>A job that just for test</Description> <Job-class>cn.jfinal.job.RedPacketValidate</Job-class> <Volatility>False</Volatility> <Durability>False</Durability> <Recover>False</Recover> </Job-detail> <Trigger> < Simple> <name>HelloTrigger1</name> <Group>DEFAULT</Group> <Job-name>Redpacketvalidate</Job-name> <Job-group>DEFAULT</Job-group> <Start-time>2015-10-26t16:56:30</Start-time> <!--repeat indefinitely every seconds - <Repeat-count>-1</Repeat-count> <Repeat-interval>10000</Repeat-interval> </ Simple> </Trigger> </Job> </Quartz>
The above two files must be placed in the apache-tomcat-7.0.59\webapps\jfinal_demo\web-inf\classes to be effective.
3. Some necessary jar packages to be added to Lib:
Create a Web project that will Quartz-1.6.0.jar, and all the jars under the core under the Lib directory, All Jta.jar under the Commons-beanutils.jar and Commons-digester-1.7.jar,build directories in the optional directory are placed under the Web-inf "Lib directory of the Web project.
Jta.jar Description: Java JTA specification;
4. Web. XML configuration
<servlet> <Servlet-name>Quartzinitializer</Servlet-name> <Display-name>Quartz Initializer Servlet</Display-name> <Servlet-class>Org.quartz.ee.servlet.QuartzInitializerServlet</Servlet-class> <Load-on-startup>1</Load-on-startup> <Init-param> <Param-name>Config-file</Param-name> <Param-value>/quartz.properties</Param-value> </Init-param> <Init-param> <Param-name>Shutdown-on-unload</Param-name> <Param-value>True</Param-value> </Init-param> </servlet>
General reference: http://www.cnblogs.com/phinecos/archive/2008/09/03/1283103.html
A preliminary exploration of the timer in the
jfinal (ii)