Save This Page
Home » quartz-1.6.0 » org.quartz.ee » servlet » [javadoc | source]
org.quartz.ee.servlet
public class: QuartzInitializerServlet [javadoc | source]
java.lang.Object
   javax.servlet.GenericServlet
      javax.servlet.http.HttpServlet
         org.quartz.ee.servlet.QuartzInitializerServlet

All Implemented Interfaces:
    Serializable, Servlet, ServletConfig

A Servlet that can be used to initialize Quartz, if configured as a load-on-startup servlet in a web application.

You'll want to add something like this to your WEB-INF/web.xml file:

<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>/some/path/my_quartz.properties</param-value>
</init-param>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>start-scheduler-on-load</param-name>
<param-value>true</param-value>
</init-param>
</servlet>

The init parameter 'config-file' can be used to specify the path (and filename) of your Quartz properties file. If you leave out this parameter, the default ("quartz.properties") will be used.

The init parameter 'shutdown-on-unload' can be used to specify whether you want scheduler.shutdown() called when the servlet is unloaded (usually when the application server is being shutdown). Possible values are "true" or "false". The default is "true".

The init parameter 'start-scheduler-on-load' can be used to specify whether you want the scheduler.start() method called when the servlet is first loaded. If set to false, your application will need to call the start() method before the scheduler begins to run and process jobs. Possible values are "true" or "false". The default is "true", which means the scheduler is started.

A StdSchedulerFactory instance is stored into the ServletContext. You can gain access to the factory from a ServletContext instance like this:
StdSchedulerFactory factory = (StdSchedulerFactory) ctx
.getAttribute(QuartzFactoryServlet.QUARTZ_FACTORY_KEY);

The init parameter 'servlet-context-factory-key' can be used to override the name under which the StdSchedulerFactory is stored into the ServletContext, in which case you will want to use this name rather than QuartzFactoryServlet.QUARTZ_FACTORY_KEY in the above example.

Once you have the factory instance, you can retrieve the Scheduler instance by calling getScheduler() on the factory.
Field Summary
public static final  String QUARTZ_FACTORY_KEY     
Method from org.quartz.ee.servlet.QuartzInitializerServlet Summary:
destroy,   doGet,   doPost,   init
Methods from javax.servlet.http.HttpServlet:
service
Methods from javax.servlet.GenericServlet:
destroy,   getInitParameter,   getInitParameterNames,   getServletConfig,   getServletContext,   getServletInfo,   getServletName,   init,   init,   log,   log,   service
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.quartz.ee.servlet.QuartzInitializerServlet Detail:
 public  void destroy() 
 public  void doGet(HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException 
 public  void doPost(HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException 
 public  void init(ServletConfig cfg) throws ServletException