cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron QuartzJobScheduler.java
Date Thu, 18 Sep 2003 08:54:18 GMT
giacomo     2003/09/18 01:54:18

  Modified:    src/blocks/cron/java/org/apache/cocoon/components/cron
                        QuartzJobScheduler.java
  Log:
  Make the cron block behave fair if cocoon or the servlet
  container is configured allowing reloads
  
  Revision  Changes    Path
  1.6       +23 -7     cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
  
  Index: QuartzJobScheduler.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -d -b -u -r1.5 -r1.6
  --- QuartzJobScheduler.java	5 Sep 2003 10:21:28 -0000	1.5
  +++ QuartzJobScheduler.java	18 Sep 2003 08:54:18 -0000	1.6
  @@ -69,7 +69,14 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.quartz.*;
  +import org.quartz.CronTrigger;
  +import org.quartz.Job;
  +import org.quartz.JobDataMap;
  +import org.quartz.JobDetail;
  +import org.quartz.Scheduler;
  +import org.quartz.SchedulerException;
  +import org.quartz.SimpleTrigger;
  +import org.quartz.Trigger;
   
   import org.quartz.impl.DirectSchedulerFactory;
   
  @@ -136,6 +143,9 @@
       /** The group name */
       static final String DEFAULT_QUARTZ_JOB_GROUP = "Cocoon";
   
  +    /** The scheduler name */
  +    static final String DEFAULT_QUARTZ_SCHEDULER_NAME = "Cocoon";
  +
       /** The PooledExecutor instance */
       private PooledExecutor m_executor;
   
  @@ -251,11 +261,14 @@
        */
       public void configure(final Configuration config)
       throws ConfigurationException {
  -        final ThreadPool pool = createThreadPool(config.getChild("thread-pool"));
  -
           try {
  -            DirectSchedulerFactory.getInstance().createScheduler(pool, new RAMJobStore());
  -            m_scheduler = DirectSchedulerFactory.getInstance().getScheduler();
  +            // If cocoon reloads (or is it the container that reload us?) 
  +            // we cannot create the same scheduler again
  +            final String runID = new Date().toString().replace(' ', '_');
  +            final ThreadPool pool = createThreadPool(config.getChild("thread-pool"));
  +            DirectSchedulerFactory.getInstance().createScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME,
runID, pool,
  +                                                                 new RAMJobStore());
  +            m_scheduler = DirectSchedulerFactory.getInstance().getScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME,
runID);
           } catch (final SchedulerException se) {
               throw new ConfigurationException("cannot create a quartz scheduler", se);
           }
  @@ -280,9 +293,12 @@
               }
   
               m_scheduler.shutdown(m_shutdownGraceful);
  +            m_scheduler = null;
           } catch (final SchedulerException se) {
               getLogger().error("failure during scheduler shutdown", se);
           }
  +
  +        m_executor = null;
       }
   
       /* (non-Javadoc)
  
  
  

Mime
View raw message