[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...

Gavin King gavin.king at jboss.com
Tue Jun 5 20:49:36 EDT 2007


  User: gavin   
  Date: 07/06/05 20:49:36

  Modified:    src/main/org/jboss/seam/core      AbstractDispatcher.java
                        CronSchedule.java QuartzDispatcher.java
                        Schedule.java TimerSchedule.java
  Log:
  minor cleanups
  
  Revision  Changes    Path
  1.7       +6 -12     jboss-seam/src/main/org/jboss/seam/core/AbstractDispatcher.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractDispatcher.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/AbstractDispatcher.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- AbstractDispatcher.java	5 Jun 2007 17:02:43 -0000	1.6
  +++ AbstractDispatcher.java	6 Jun 2007 00:49:36 -0000	1.7
  @@ -6,10 +6,10 @@
   import java.util.Date;
   
   import org.jboss.seam.Component;
  +import org.jboss.seam.annotations.timer.Cron;
   import org.jboss.seam.annotations.timer.Duration;
   import org.jboss.seam.annotations.timer.Expiration;
   import org.jboss.seam.annotations.timer.IntervalDuration;
  -import org.jboss.seam.annotations.timer.Cron;
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.intercept.InvocationContext;
  @@ -180,20 +180,14 @@
            }
         }
         
  -      if (cron != null && (!cron.trim().equals(""))) 
  +      if ( cron!=null ) 
         {
  -        return new CronSchedule(duration, expiration, cron.trim());
  -      } else {
  -        return new TimerSchedule(duration, expiration, intervalDuration);
  +        return new CronSchedule(duration, expiration, cron);
         }
  -
  -      /*
  -      } else if (intervalDuration != null) {
  +      else 
  +      {
           return new TimerSchedule(duration, expiration, intervalDuration);
  -      } else if (expiration != null || duration != null) {
  -        return new Schedule (duration, expiration);
         }
  -      */
      }
      
   }
  
  
  
  1.2       +3 -4      jboss-seam/src/main/org/jboss/seam/core/CronSchedule.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CronSchedule.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/CronSchedule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CronSchedule.java	5 Jun 2007 17:02:43 -0000	1.1
  +++ CronSchedule.java	6 Jun 2007 00:49:36 -0000	1.2
  @@ -24,7 +24,7 @@
       */
      public CronSchedule(Long duration, String cron)
      {
  -      this.duration = duration;
  +      super(duration);
         this.cron = cron;
      }
   
  @@ -34,14 +34,13 @@
       */
      public CronSchedule(Date expiration, String cron)
      {
  -      this.expiration = expiration;
  +      super(expiration);
         this.cron = cron;
      }
   
      CronSchedule(Long duration, Date expiration, String cron)
      {
  -      this.duration = duration;
  -      this.expiration = expiration;
  +      super(duration, expiration);
         this.cron = cron;
      }
   
  
  
  
  1.4       +52 -41    jboss-seam/src/main/org/jboss/seam/core/QuartzDispatcher.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: QuartzDispatcher.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/QuartzDispatcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- QuartzDispatcher.java	5 Jun 2007 17:02:43 -0000	1.3
  +++ QuartzDispatcher.java	6 Jun 2007 00:49:36 -0000	1.4
  @@ -2,26 +2,12 @@
   
   import static org.jboss.seam.annotations.Install.BUILT_IN;
   
  -import java.util.Date;
  -import java.rmi.server.UID;
   import java.io.Serializable;
  +import java.rmi.server.UID;
  +import java.util.Date;
   
   import javax.interceptor.Interceptors;
   
  -import org.quartz.SchedulerFactory;
  -import org.quartz.Scheduler;
  -import org.quartz.Job;
  -import org.quartz.JobDetail;
  -import org.quartz.JobDataMap;
  -import org.quartz.Trigger;
  -import org.quartz.SimpleTrigger;
  -import org.quartz.CronTrigger;
  -import org.quartz.JobExecutionContext;
  -import org.quartz.JobExecutionException;
  -import org.quartz.SchedulerException;
  -
  -import org.jboss.seam.log.LogProvider;
  -import org.jboss.seam.log.Logging;
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Create;
  @@ -31,6 +17,18 @@
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.ejb.SeamInterceptor;
   import org.jboss.seam.intercept.InvocationContext;
  +import org.jboss.seam.log.LogProvider;
  +import org.jboss.seam.log.Logging;
  +import org.quartz.CronTrigger;
  +import org.quartz.Job;
  +import org.quartz.JobDataMap;
  +import org.quartz.JobDetail;
  +import org.quartz.JobExecutionContext;
  +import org.quartz.JobExecutionException;
  +import org.quartz.Scheduler;
  +import org.quartz.SchedulerException;
  +import org.quartz.SchedulerFactory;
  +import org.quartz.SimpleTrigger;
   
   /**
    * Dispatcher implementation that uses the Quartz library.
  @@ -49,14 +47,16 @@
      private static Scheduler scheduler;
   
      @Create
  -   public void initScheduler () 
  +   public void initScheduler() 
      {
        SchedulerFactory schedulerFactory = new org.quartz.impl.StdSchedulerFactory();
  -     try {
  +     try 
  +     {
          scheduler = schedulerFactory.getScheduler();
          scheduler.start();
          log.info("The QuartzDispatcher has started");
  -     } catch (SchedulerException se) {
  +     } 
  +     catch (SchedulerException se) {
          log.error("Cannot get or start a Quartz Scheduler");
          se.printStackTrace ();
        }
  @@ -70,14 +70,17 @@
         JobDetail jobDetail = new JobDetail(jobName, null, QuartzJob.class);
         jobDetail.getJobDataMap().put("async", new AsynchronousEvent(type, parameters));
          
  -      SimpleTrigger trigger = new SimpleTrigger (triggerName, null);
  +      SimpleTrigger trigger = new SimpleTrigger(triggerName, null);
         
         log.info("In the scheduleAsynchronousEvent()");
   
  -      try {
  -        scheduler.scheduleJob( jobDetail, trigger );
  +      try 
  +      {
  +        scheduler.scheduleJob(jobDetail, trigger);
           return new QuartzTriggerHandle(triggerName);
  -      } catch (SchedulerException se) {
  +      } 
  +      catch (SchedulerException se) 
  +      {
           log.error("Cannot Schedule a Quartz Job");
           se.printStackTrace ();
           return null;
  @@ -87,9 +90,12 @@
      public QuartzTriggerHandle scheduleTimedEvent(String type, Schedule schedule, Object... parameters)
      {
         log.info("In the scheduleTimedEvent()");
  -      try {
  +      try 
  +      {
           return scheduleWithQuartzService( schedule, new AsynchronousEvent(type, parameters) );
  -      } catch (SchedulerException se) {
  +      } 
  +      catch (SchedulerException se) 
  +      {
           log.error("Cannot Schedule a Quartz Job");
           se.printStackTrace ();
           return null;
  @@ -99,12 +105,14 @@
      public QuartzTriggerHandle scheduleInvocation(InvocationContext invocation, Component component)
      {
         log.info("In the scheduleInvocation()");
  -      try {
  +      try 
  +      {
           return scheduleWithQuartzService( 
                  createSchedule(invocation), 
                  new AsynchronousInvocation(invocation, component)
               );
  -      } catch (SchedulerException se) {
  +      } 
  +      catch (SchedulerException se) {
           log.error("Cannot Schedule a Quartz Job");
           se.printStackTrace ();
           return null;
  @@ -131,7 +139,8 @@
         if (schedule instanceof CronSchedule) 
         {
           CronSchedule cronSchedule = (CronSchedule) schedule; 
  -        try {
  +        try 
  +        {
             CronTrigger trigger = new CronTrigger (triggerName, null);
             trigger.setCronExpression(cronSchedule.getCron());
             if ( cronSchedule.getExpiration()!=null )
  @@ -145,7 +154,9 @@
   
             scheduler.scheduleJob( jobDetail, trigger );
   
  -        } catch (Exception e) {
  +        } 
  +        catch (Exception e) 
  +        {
             log.error ("Cannot submit cron job");
             e.printStackTrace ();
             return null;
  @@ -156,19 +167,19 @@
            TimerSchedule timerSchedule = (TimerSchedule) schedule;
            if ( timerSchedule.getExpiration()!=null )
            {
  -            SimpleTrigger trigger = new SimpleTrigger (triggerName, null, timerSchedule.getExpiration(), null, SimpleTrigger.REPEAT_INDEFINITELY, timerSchedule.getIntervalDuration());
  +            SimpleTrigger trigger = new SimpleTrigger(triggerName, null, timerSchedule.getExpiration(), null, SimpleTrigger.REPEAT_INDEFINITELY, timerSchedule.getIntervalDuration());
               scheduler.scheduleJob( jobDetail, trigger );
   
            }
            else if ( timerSchedule.getDuration()!=null )
            {
  -             SimpleTrigger trigger = new SimpleTrigger (triggerName, null, calculateDelayedDate(timerSchedule.getDuration()), null, SimpleTrigger.REPEAT_INDEFINITELY, timerSchedule.getIntervalDuration());
  +             SimpleTrigger trigger = new SimpleTrigger(triggerName, null, calculateDelayedDate(timerSchedule.getDuration()), null, SimpleTrigger.REPEAT_INDEFINITELY, timerSchedule.getIntervalDuration());
                scheduler.scheduleJob( jobDetail, trigger );
   
            }
            else
            {
  -            SimpleTrigger trigger = new SimpleTrigger (triggerName, null, SimpleTrigger.REPEAT_INDEFINITELY, timerSchedule.getIntervalDuration());
  +            SimpleTrigger trigger = new SimpleTrigger(triggerName, null, SimpleTrigger.REPEAT_INDEFINITELY, timerSchedule.getIntervalDuration());
               scheduler.scheduleJob( jobDetail, trigger );
   
            }
  @@ -178,19 +189,19 @@
           if ( schedule.getExpiration()!=null )
           {
               SimpleTrigger trigger = new SimpleTrigger (triggerName, null, schedule.getExpiration());
  -            scheduler.scheduleJob( jobDetail, trigger );
  +            scheduler.scheduleJob(jobDetail, trigger);
   
           }
           else if ( schedule.getDuration()!=null )
           {
               SimpleTrigger trigger = new SimpleTrigger (triggerName, null, calculateDelayedDate(schedule.getDuration()));
  -            scheduler.scheduleJob( jobDetail, trigger );
  +            scheduler.scheduleJob(jobDetail, trigger);
   
           }
           else
           {
  -           SimpleTrigger trigger = new SimpleTrigger (triggerName, null);
  -           scheduler.scheduleJob( jobDetail, trigger );
  +           SimpleTrigger trigger = new SimpleTrigger(triggerName, null);
  +           scheduler.scheduleJob(jobDetail, trigger);
   
           }
         }
  @@ -242,23 +253,23 @@
            this.triggerName = triggerName; 
         }
   
  -      public void cancel () throws SchedulerException
  +      public void cancel() throws SchedulerException
         {
            log.info("Cancel executing Quartz job");
            scheduler.unscheduleJob(triggerName, null);
         }
         
  -      public void pause () throws SchedulerException
  +      public void pause() throws SchedulerException
         {
            log.info("Pause executing Quartz job");
  -         scheduler.pauseTrigger (triggerName, null);
  +         scheduler.pauseTrigger(triggerName, null);
            
         }
         
  -      public void resume () throws SchedulerException
  +      public void resume() throws SchedulerException
         {
            log.info("Resume executing Quartz job");
  -         scheduler.resumeTrigger (triggerName, null);
  +         scheduler.resumeTrigger(triggerName, null);
         }
      }
   
  
  
  
  1.2       +20 -4     jboss-seam/src/main/org/jboss/seam/core/Schedule.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Schedule.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Schedule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- Schedule.java	5 Jun 2007 17:02:43 -0000	1.1
  +++ Schedule.java	6 Jun 2007 00:49:36 -0000	1.2
  @@ -14,8 +14,8 @@
    */
   public class Schedule implements Serializable
   {
  -   Long duration;
  -   Date expiration;
  +   private Long duration;
  +   private Date expiration;
      
      Long getDuration()
      {
  @@ -29,14 +29,30 @@
      
      /**
       * @param duration the delay before the event occurs
  -    * @param expriation the datetime at which the event occurs
  +    * @param expiration the datetime at which the event occurs
       */
  -   public Schedule(Long duration, Date expiration)
  +   Schedule(Long duration, Date expiration)
      {
         this.duration = duration;
         this.expiration = expiration;
      }
   
  +   /**
  +    * @param duration the delay before the event occurs
  +    */
  +   public Schedule(Long duration)
  +   {
  +      this.duration = duration;
  +   }
  +
  +   /**
  +    * @param expiration the datetime at which the event occurs
  +    */
  +   public Schedule(Date expiration)
  +   {
  +      this.expiration = expiration;
  +   }
  +
      public Schedule () { }
   
   }
  
  
  
  1.4       +5 -6      jboss-seam/src/main/org/jboss/seam/core/TimerSchedule.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TimerSchedule.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/TimerSchedule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- TimerSchedule.java	5 Jun 2007 17:02:43 -0000	1.3
  +++ TimerSchedule.java	6 Jun 2007 00:49:36 -0000	1.4
  @@ -25,7 +25,7 @@
       */
      public TimerSchedule(Long duration)
      {
  -      this.duration = duration;
  +      super(duration);
      }
   
      /**
  @@ -33,7 +33,7 @@
       */
      public TimerSchedule(Date expiration)
      {
  -      this.expiration = expiration;
  +      super(expiration);
      }
   
      /**
  @@ -42,7 +42,7 @@
       */
      public TimerSchedule(Long duration, Long intervalDuration)
      {
  -      this.duration = duration;
  +      super(duration);
         this.intervalDuration = intervalDuration;
      }
   
  @@ -52,14 +52,13 @@
       */
      public TimerSchedule(Date expiration, Long intervalDuration)
      {
  -      this.expiration = expiration;
  +      super(expiration);
         this.intervalDuration = intervalDuration;
      }
   
      TimerSchedule(Long duration, Date expiration, Long intervalDuration)
      {
  -      this.duration = duration;
  -      this.expiration = expiration;
  +      super(duration, expiration);
         this.intervalDuration = intervalDuration;
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list