Ram,

Thanks a lot. Dunno how I missed that..

For all of you out there who needs an example of this
functionality:

QuartzPlugIn qp = (QuartzPlugIn)
request.getSession().getServletContext().getAttribute(QuartzPlugIn.PLUGIN_KEY);

Scheduler scheduler = qp.getScheduler();


Best,
James


--- Ram <[EMAIL PROTECTED]> wrote:

> Under the jgs-struts src
> 
>
src\java\com\jgsullivan\struts\plugins\QuartzPlugIn.java
> 
> If you look in this source code PLUGIN_KEY is the
> key in the application
> context. Using this you can access the scheduler .
> 
> Hope this helps.
> 
>  I am attaching the source here for your reference
> 
> /**
>  * $Header:
>
/cvs/jgsullivan/struts/src/java/com/jgsullivan/struts/plugins/QuartzPlugIn.j
> ava,v 1.7 2003/12/31 12:48:50 pjaromin Exp $
>  * $Revision
>  * $Date: 2003/12/31 12:48:50 $
>  *
>  *
>
===========================================================================
>  *
>  * JGSullivan Quartz Plugin
>  *
>  * Quartz plugin allowing for XML-configured jobs to
> be run from within the
>  * application server/Jakarta Struts environment.
>  *
>  *
>
===========================================================================
>  */
> package com.jgsullivan.struts.plugins;
> 
> 
> import javax.servlet.ServletException;
> 
> import org.xml.sax.InputSource;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.struts.action.ActionServlet;
> import org.apache.struts.config.ModuleConfig;
> import org.apache.struts.action.PlugIn;
> 
> import org.quartz.Scheduler;
> 
> import com.jgsullivan.quartz.SchedulerBuilder;
> 
> 
> /**
>  * Class QuartzPlugin
>  *
>  * This plugin requires a single property and an XML
> quartz configuration
> file
>  * describing the jobs/triggers to execute. See
> <code>quartz-config.dtd</code>
>  * for details on creating a quartz-config.xml file.
>  *<p>
>  * This class inherits the properties from
> <code>PluginSupport</code>.
>  *<p>
>  * Example configuration:
>  * <code><pre>
>  * &lt;plug-in
>  *     
>
className="com.jgsullivan.struts.plugins.QuartzPlugin"&gt;
>  *      &lt;set-property
>  *          property="configPath"
>  *          value="/WEB-INF/quartz-config.xml"/&gt;
>  * &lt;/plug-in&gt;
>  *</pre></code>
>  * @see com.jgsullivan.quartz.SchedulerBuilder
>  * @see com.jgsullivan.struts.plugins.PlugInSupport
>  *
>  * @author Patrick Jaromin
> &lt;[EMAIL PROTECTED]&gt;
>  * @version $Revision: 1.7 $ $Date: 2003/12/31
> 12:48:50 $
>  */
> public class QuartzPlugIn extends PlugInSupport {
> 
>  /**
>   * The default key to used to lookup this plugin in
> a Struts application.
>   * May be overriden in the <code>plug-in</code>
> definition.
>   * @see
> com.jgsullivan.struts.plugins.PlugInSupport#key
>   */
>  public static final String PLUGIN_KEY =
> PlugInSupport.class.getName();
> 
>     /**
>      * Commons Logging instance.
>      */
>     protected static Log log =
> LogFactory.getLog(PlugInSupport.class);
> 
>     /**
>      * Field: scheduler
>      */
>     protected Scheduler scheduler;
> 
>     /**
>      * Method init
>      * Creates and starts the scheduler and places
> this plugin class in
>   * the application context using the key specified
> in the struts-config.xml
>   * <code>plug-in</code> definition's property
> setters -
>   * <code>&lt;set-property property="key"
> value="XXXX"/&gt;</code>
>   * or, if not specified, the default key reference
> by
>   * <code>QuartzPlugin.PLUGIN_KEY</code>
>      *
>      * @param servlet
>      * @param config
>      *
>      * @throws javax.servlet.ServletException
>      *
>      */
>     public void init() throws
> javax.servlet.ServletException {
> 
>         log.info("Initializing QuartzPlugIn");
> 
>         try {
>             SchedulerBuilder builder   = new
> SchedulerBuilder();
>             scheduler
>        =
> builder.buildScheduler(getConfigURL().openStream());
> 
>             scheduler.start();
>         }
>         catch (Exception ex) {
>             throw new javax.servlet
>                 .ServletException("Error
> initializing Quartz scheduler",
> ex);
>         }
>     }
> 
>  /**
>   * Returns the key for this plugin. If the key is
> not defined, returns
>   * the default key.
>   * @return
>   */
>  public String getKey() {
>   if (key == null) {
>    return this.PLUGIN_KEY;
>   }
>   return key;
>  }
> 
>     /**
>      * Method getScheduler
>      *
>      *
>      * @return
>      *
>      */
>     public Scheduler getScheduler() {
>         return this.scheduler;
>     }
> 
> 
> 
> }
> 
> 
> Thanks
> -Ram
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



                
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to