title: Integration of tomcat and Quartz scheduler on startup
body: <p>I am using tomcat version 6.0. My requirement is that when tomcat starts up, I would like to start a <code>QuartzScheduler</code> which will schedule some jobs at a regular interval. I am trying to figure out the best possible way to do it. Here are the options that I could think of - </p>
  
  <ol>
  <li>I can do this via a servlet with "<code>load-on-startup</code>" descriptor in <code>web.xml</code> file to start the scheduler and schedule the jobs inside the servlet.</li>
  <li>Can be done using a <code>ContextListener</code> (this sounds a better approach to me than 1).  This might be a clean approach to start the scheduler inside the <code>contextInitialized</code> method and shutdown the scheduler inside <code>contextDestroyed</code> method.</li>
  <li>Using a MBean-descriptor. I develop a MBean which will get started when the server starts up with mbeans-descriptor.xml file. </li>
  </ol>
  
  <p>To me, it looks like second approach is better. Third one might not be a good idea as it is clearly not a MBean to be monitored by jconsole or so. My purpose is to start the scheduler and stop it when tomcat stops.
  Is there any better and cleaner way to do this ?</p>