Commits

Anonymous committed b8ab821

refactored JobExecutionContext.getJobDataMap() to be getMergedJobDataMap()

CVS: ----------------------------------------------------------------------
CVS: Issue number:
CVS: If this change addresses one or more issues,
CVS: then enter the issue number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to the project by someone else; i.e.,
CVS: they sent us a patch or a set of diffs, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.

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

  • Participants
  • Parent commits 4f14edf

Comments (0)

Files changed (5)

src/java/org/quartz/JobDataMap.java

  * Job with different data inputs.  
  * </p>
  * 
+ * <p>
+ * The <code>JobExecutionContext</code> passed to a Job at execution time 
+ * also contains a convenience <code>JobDataMap</code> that is the result
+ * of merging the contents of the trigger's JobDataMap (if any) over the
+ * Job's JobDataMap (if any).  
+ * </p>
+ * 
  * @see Job
  * @see StatefulJob
  * @see Trigger

src/java/org/quartz/JobExecutionContext.java

  * </p>
  * 
  * <p>
- * The <code>JobDataMap</code> found on this object serves as a convenience -
+ * The <code>JobDataMap</code> found on this object (via the 
+ * <code>getMergedJobDataMap()</code> method) serves as a convenience -
  * it is a merge of the <code>JobDataMap</code> found on the 
  * <code>JobDetail</code> and the one found on the <code>Trigger</code>, with 
  * the value in the latter overriding any same-named values in the former.
  * to the job instance that is running).
  * </p>
  * 
+ * @see #getJobDetail()
+ * @see #getScheduler()
+ * @see #getMergedJobDataMap()
+ * 
  * @see Job
  * @see Trigger
  * @see JobDataMap
         this.jobDataMap = new JobDataMap();
         this.jobDataMap.putAll(jobDetail.getJobDataMap());
         this.jobDataMap.putAll(trigger.getJobDataMap());
+        
+        this.jobDataMap.setMutable(false);
+        this.trigger.getJobDataMap().setMutable(false);
     }
 
     /*
      * <code>StatefulJob</code>'s own JobDataMap.
      * </p>
      * 
+     * <p>
+     * Attempts to change the contents of this map typically result in an 
+     * <code>IllegalStateException</code>.
+     * </p>
+     * 
      */
-    public JobDataMap getJobDataMap() {
+    public JobDataMap getMergedJobDataMap() {
         return jobDataMap;
     }
 
-
     /**
      * <p>
      * Get the <code>JobDetail</code> associated with the <code>Job</code>.

src/java/org/quartz/Trigger.java

      * </p>
      * 
      * <p>
-     * Changes made to this map during job execution are not re-persisted.
+     * Changes made to this map during job execution are not re-persisted, and
+     * in fact typically result in an <code>IllegalStateException</code>.
      * </p>
      */
     public JobDataMap getJobDataMap() {

src/java/org/quartz/simpl/PropertySettingJobFactory.java

  * 
  * @see org.quartz.spi.JobFactory
  * @see SimpleJobFactory
- * @see JobExecutionContext#getJobDataMap()
+ * @see JobExecutionContext#getMergedJobDataMap()
  * @see #setWarnIfPropertyNotFound(boolean)
  * @see #setThrowIfPropertyNotFound(boolean)
  * 

src/java/org/quartz/utils/DirtyFlagMap.java

 package org.quartz.utils;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
      * 
      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      */
+    private static final long serialVersionUID = 1433884852607126222L;
 
     private boolean dirty = false;
-
+    private transient boolean locked = false;
     private Map map;
 
     /*
      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      */
 
+
+    public void setMutable(boolean mutable) {
+        this.locked = !mutable;
+        if(locked)
+            map = Collections.unmodifiableMap(map);
+        else
+            map = new HashMap(map);
+    }
+    
+    
+    public boolean isMutable() {
+        return !locked;
+    }
+    
     /**
      * <p>
      * Clear the 'dirty' flag (set dirty flag to <code>false</code>).