Using Quartz in the web
1, first in the Web. xml file to add the following (according to their own circumstances set)
adding Quartzinitializerservlet,quartz in Web. XML to be able to be used in a website application provides a quartzinitializerservlet and a quartzinitializerlistener for loading the web When applied, initializes the quartz.
<servlet>
<servlet-name>
Quartzinitializer
</servlet-name>
<servlet-class>
Org.quartz.ee.servlet.QuartzInitializerServlet
</servlet-class>
<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>
<load-on-startup>1</load-on-startup>
</servlet>
2, the configuration of the Quartz.properties file (each property description of the next write), the contents are as follows:
The above mentioned quartz.properties, which is self-specified, Quartz provides a default configuration file to meet the basic J2SE application, if in the Web application, we want to write the Job,trigger configuration to the file, we need to write, and specify to load our own quratz.properties at initialization, where the position is placed under classes.
Org.quartz.scheduler.instanceName = Testscheduler
Org.quartz.scheduler.instanceId = One
Org.quartz.threadPool.class = Org.quartz.simpl.SimpleThreadPool
Org.quartz.threadPool.threadCount = 2
Org.quartz.threadPool.threadPriority = 4
Org.quartz.plugin.jobInitializer.class = Org.quartz.plugins.xml.JobInitializationPlugin
Org.quartz.plugin.jobInitializer.fileName = Quartz_job.xml
Org.quartz.plugin.jobInitializer.overWriteExistingJobs = False
Org.quartz.plugin.jobInitializer.failOnFileNotFound = True
Org.quartz.plugin.shutdownhook.class = Org.quartz.plugins.management.ShutdownHookPlugin
Org.quartz.plugin.shutdownhook.cleanShutdown = True
3, quartz_job.xml file configuration (each property description of the next write), the contents are as follows:
Quartz to use a plug-in to load its own XML configuration file, which specifies to load the Classes/quartz_job.xml file.
As an example, the simple job simplequartzjob in Quartz timed task learning (a):
<?xml version= "1.0" encoding= "UTF-8"?
<quartz>
<job>
< Job-detail>
<name>listener1</name>
<group>group1</group>
<job-class>simplequartzjob</ Job-class>
</job-detail>
<trigger>
<cron>
<name>job1</name>
<group>group1</group>
<job-name>listener1</job-name>
<job-group>group1</job-group>
<CRON-EXPRESSION>0/10 * * * *?</cron-expression>
</cron>
</trigger>
</job>
</quartz>
Quartz timed Task Learning (ii) Web application