Commits

jhouse  committed d803d68

QUARTZ-238 - new listener for simple job-chaining functionality (associated changes)

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@63269f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 315b41b

Comments (0)

Files changed (2)

File src/java/org/quartz/JobDetail.java

 import java.util.Set;
 
 import org.apache.commons.collections.SetUtils;
+import org.quartz.utils.Key;
 
 /**
  * <p>
 
     private Set jobListeners = SetUtils.orderedSet(new HashSet());
 
+    private transient Key key = null;
+
     /*
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     * 
-     * Constructors.
-     * 
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     */
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    *
+    * Constructors.
+    *
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    */
 
     /**
      * <p>
      *              if nameis null or empty, or the group is an empty string.
      */
     public JobDetail(String name, String group, Class jobClass,
-            boolean volatility, boolean durability, boolean recover) {
+                     boolean volatility, boolean durability, boolean recover) {
         setName(name);
         setGroup(group);
         setJobClass(jobClass);
         if (group == null) {
             group = Scheduler.DEFAULT_GROUP;
         }
-        
+
         this.group = group;
     }
 
         return group + "." + name;
     }
 
+    public Key getKey() {
+        if(key == null) {
+            key = new Key(getName(), getGroup());
+        }
+
+        return key;
+    }
+
     /**
      * <p>
      * Return the description given to the <code>Job</code> instance by its

File src/java/org/quartz/Trigger.java

 import java.util.Date;
 import java.util.LinkedList;
 
+import org.quartz.utils.Key;
+
 
 /**
  * <p>
         Comparable {
 
     private static final long serialVersionUID = -3904243490805975570L;
-    
+
     /*
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     * 
-     * Constants.
-     * 
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     */
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    *
+    * Constants.
+    *
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    */
 
     /**
      * <p>
      * currently executing.
      * </p>
      *
-     * @see StatefulJob 
+     * @see StatefulJob
      */
     public static final int STATE_BLOCKED = 4;
 
      * The default value for priority.
      */
     public static final int DEFAULT_PRIORITY = 5;
-    
+
     /*
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     * 
-     * Data members.
-     * 
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     */
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    *
+    * Data members.
+    *
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    */
 
     private String name;
 
     private String jobGroup = Scheduler.DEFAULT_GROUP;
 
     private String description;
-    
+
     private JobDataMap jobDataMap;
 
     private boolean volatility = false;
     private int misfireInstruction = MISFIRE_INSTRUCTION_SMART_POLICY;
 
     private LinkedList triggerListeners = new LinkedList();
-    
+
     private int priority = DEFAULT_PRIORITY;
-    
+
+    private transient Key key = null;
+
     /*
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     * 
-     * Constructors.
-     * 
-     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-     */
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    *
+    * Constructors.
+    *
+    * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    */
+
 
-    
 
     /**
      * <p>
         if(group == null) {
             group = Scheduler.DEFAULT_GROUP;
         }
-        
+
         this.group = group;
     }
 
         if(jobGroup == null) {
             jobGroup = Scheduler.DEFAULT_GROUP;
         }
-        
+
         this.jobGroup = jobGroup;
     }
 
         return group + "." + name;
     }
 
-    /**
+    public Key getKey() {
+        if(key == null) {
+            key = new Key(getName(), getGroup());
+        }
+
+        return key;
+    }
+
+\    /**
      * <p>
      * Returns the 'full name' of the <code>Job</code> that the <code>Trigger</code>
      * points to, in the format "group.name".
     public void setJobDataMap(JobDataMap jobDataMap) {
         this.jobDataMap = jobDataMap;
     }
-    
+
     /**
      * <p>
      * Whether or not the <code>Trigger</code> should be persisted in the
     public int getPriority() {
         return priority;
     }
-    
+
 
     /**
      * The priority of a <code>Trigger</code> acts as a tiebreaker such that if 
             throw new IllegalArgumentException(
                 "Trigger listener '" + name + "' is already registered for trigger: " + getFullName());
         }
-        
+
         triggerListeners.add(name);
     }
 
     public boolean removeTriggerListener(String name) {
         return triggerListeners.remove(name);
     }
-        
+
     /**
      * <p>
      * Returns an array of <code>String</code>  containing the names of all
     public void clearAllTriggerListeners() {
         triggerListeners.clear();
     }
-    
+
     /**
      * <p>
      * This method should not be used by the Quartz client.
      * @see #triggered(Calendar)
      */
     public abstract int executionComplete(JobExecutionContext context,
-            JobExecutionException result);
+                                          JobExecutionException result);
 
     /**
      * <p>
      */
     public abstract Date getStartTime();
 
-    public abstract void setStartTime(Date startTime); 
-    
-    public abstract void setEndTime(Date endTime); 
-    
+    public abstract void setStartTime(Date startTime);
+
+    public abstract void setEndTime(Date endTime);
+
     /**
      * <p>
      * Get the time at which the <code>Trigger</code> should quit repeating -
         if(myTime.after(otherTime)) {
             return 1;
         }
-        
+
         return 0;
     }
 
 
         return true;
     }
-    
-    
+
+
     public int hashCode() {
-        return getFullName().hashCode(); 
+        return getFullName().hashCode();
     }
-    
+
     public Object clone() {
         Trigger copy;
         try {
             copy = (Trigger) super.clone();
-            
+
             copy.triggerListeners = (LinkedList)triggerListeners.clone();
-            
+
             // Shallow copy the jobDataMap.  Note that this means that if a user
             // modifies a value object in this map from the cloned Trigger
             // they will also be modifying this Trigger. 
             if (jobDataMap != null) {
-                copy.jobDataMap = (JobDataMap)jobDataMap.clone(); 
+                copy.jobDataMap = (JobDataMap)jobDataMap.clone();
             }
-            
+
         } catch (CloneNotSupportedException ex) {
             throw new IncompatibleClassChangeError("Not Cloneable.");
         }