Author: aheritier
Date: Tue Apr 10 06:36:37 2007
New Revision: 527135

URL: http://svn.apache.org/viewvc?view=rev&rev=527135
Log:
Fix for : 
Caused by: java.util.ConcurrentModificationException
        at 
java.util.AbstractList$Itr.checkForComodification(AbstractList.java:448)
        at java.util.AbstractList$Itr.next(AbstractList.java:419)
        at org.apache.maven.werkz.Goal.firePreGoalCallbacks(Goal.java:697)

Modified:
    maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java

Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java?view=diff&rev=527135&r1=527134&r2=527135
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java 
(original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java Tue Apr 
10 06:36:37 2007
@@ -71,42 +71,38 @@
 import java.util.List;
 import java.util.Set;
 
-/** Abstract Goal to attain.
- *
- *  <p>
- *  A <code>Goal</code> embodies both an action and the
- *  precursors for that action. A <code>Goal</code>'s
- *  precursors will be satisfied before attempting to
- *  perform the target <code>Goal</code>'s action.  There
- *  may be a case that once precursors have been satisfied
- *  there is no further action required to be perform for
- *  a particular <code>Goal</code>.
- *  </p>
+/**
+ * Abstract Goal to attain.
  * 
  * <p>
- * A <code>Goal</code>'s postcursors are also tracked
- * so that if a <code>Goal</code>'s state has been changed
- * and the <code>Goal</code>s ahead of it in the hierarchy 
- * need to be notified, it can <code>percolate</code> forward
+ * A <code>Goal</code> embodies both an action and the precursors for that 
action. A <code>Goal</code>'s precursors
+ * will be satisfied before attempting to perform the target 
<code>Goal</code>'s action. There may be a case that
+ * once precursors have been satisfied there is no further action required to 
be perform for a particular
+ * <code>Goal</code>.
+ * </p>
+ * 
+ * <p>
+ * A <code>Goal</code>'s postcursors are also tracked so that if a 
<code>Goal</code>'s state has been changed and
+ * the <code>Goal</code>s ahead of it in the hierarchy need to be notified, it 
can <code>percolate</code> forward
  * and have it's postcursors satisfied.
  * </p>
  * 
- *  @see WerkzProject
- *  @see Action
- *  
- *  @author <a href="mailto:[EMAIL PROTECTED]">bob mcwhirter</a>
+ * @see WerkzProject
+ * @see Action
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">bob mcwhirter</a>
  */
 public class Goal
 {
     // ------------------------------------------------------------
-    //     Constants
+    // Constants
     // ------------------------------------------------------------
 
     /** Empty <code>Goal</code> array. */
     public static final Goal[] EMPTY_ARRAY = new Goal[0];
 
     // ------------------------------------------------------------
-    //     Class members
+    // Class members
     // ------------------------------------------------------------
 
     /** Unique name. */
@@ -137,12 +133,14 @@
     private String description;
 
     // ------------------------------------------------------------
-    //     Constructors
+    // Constructors
     // ------------------------------------------------------------
 
-    /** Construct a new <code>Goal</code> with the specified name.
-     *
-     *  @param name The name of the <code>Goal</code>.
+    /**
+     * Construct a new <code>Goal</code> with the specified name.
+     * 
+     * @param name
+     *            The name of the <code>Goal</code>.
      */
     public Goal( String name )
     {
@@ -156,11 +154,13 @@
         this.postActionCallbacks = Collections.EMPTY_LIST;
     }
 
-    /** Construct a new <code>Goal</code> with the specified name
-     *  and <code>Action</code>.
-     *
-     *  @param name The name of the <code>Goal</code>.
-     *  @param action The <code>Action</code> for this <code>Goal</code>.
+    /**
+     * Construct a new <code>Goal</code> with the specified name and 
<code>Action</code>.
+     * 
+     * @param name
+     *            The name of the <code>Goal</code>.
+     * @param action
+     *            The <code>Action</code> for this <code>Goal</code>.
      */
     public Goal( String name, Action action )
     {
@@ -170,61 +170,70 @@
     }
 
     // ------------------------------------------------------------
-    //     Instance methods
+    // Instance methods
     // ------------------------------------------------------------
 
-    /** Retrieve the name of this <code>Goal</code>.
-     *
-     *  @return This <code>Goal</code>'s name.
+    /**
+     * Retrieve the name of this <code>Goal</code>.
+     * 
+     * @return This <code>Goal</code>'s name.
      */
     public String getName()
     {
         return this.name;
     }
 
-    /** Retrieve the description of this <code>Goal</code>.
-     *
-     *  @return The description of this goal.
+    /**
+     * Retrieve the description of this <code>Goal</code>.
+     * 
+     * @return The description of this goal.
      */
     public String getDescription()
     {
         return this.description;
     }
 
-    /** Set the description for this <code>Goal</code>.
-     *
-     *  @param description The description of this goal.
+    /**
+     * Set the description for this <code>Goal</code>.
+     * 
+     * @param description
+     *            The description of this goal.
      */
     public void setDescription( String description )
     {
         this.description = description;
     }
 
-    /** Retrieve the <code>Action</code> of this <code>Goal</code>.
-     *
-     *  @return The <code>Action</code> of this <code>Goal</code>.
+    /**
+     * Retrieve the <code>Action</code> of this <code>Goal</code>.
+     * 
+     * @return The <code>Action</code> of this <code>Goal</code>.
      */
     public Action getAction()
     {
         return this.action;
     }
 
-    /** Set the <code>Action</code> of this <code>Goal</code>.
-     *
-     *  @param action The <code>Action</code> of this <code>Goal</code>.
+    /**
+     * Set the <code>Action</code> of this <code>Goal</code>.
+     * 
+     * @param action
+     *            The <code>Action</code> of this <code>Goal</code>.
      */
     public void setAction( Action action )
     {
         this.action = action;
     }
 
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-    //     PRE GOAL
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-
-    /** Add a <b>pre-goal</b> callback to this <code>Goal</code>.
-     *
-     *  @param callback The callback to add.
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    // PRE GOAL
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+    /**
+     * Add a <b>pre-goal</b> callback to this <code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to add.
      */
     public void addPreGoalCallback( PreGoalCallback callback )
     {
@@ -236,9 +245,11 @@
         this.preGoalCallbacks.add( callback );
     }
 
-    /** Remove all occurences of a <b>pre-goal</b> callback from this 
<code>Goal</code>.
-     *
-     *  @param callback The callback to remove.
+    /**
+     * Remove all occurences of a <b>pre-goal</b> callback from this 
<code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to remove.
      */
     public void removePreGoalCallback( PreGoalCallback callback )
     {
@@ -248,22 +259,25 @@
         }
     }
 
-    /** Retrieve an unmodifiable list of the <b>pre-goal</b> callbacks.
-     *
-     *  @return An unmodifiable <code>List</code> of 
<code>PreGoalCallback</code>s.
+    /**
+     * Retrieve an unmodifiable list of the <b>pre-goal</b> callbacks.
+     * 
+     * @return An unmodifiable <code>List</code> of 
<code>PreGoalCallback</code>s.
      */
     public List getPreGoalCallbacks()
     {
         return Collections.unmodifiableList( this.preGoalCallbacks );
     }
 
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-    //     POST GOAL
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-
-    /** Add a <b>post-goal</b> callback to this <code>Goal</code>.
-     *
-     *  @param callback The callback to add.
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    // POST GOAL
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+    /**
+     * Add a <b>post-goal</b> callback to this <code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to add.
      */
     public void addPostGoalCallback( PostGoalCallback callback )
     {
@@ -275,9 +289,11 @@
         this.postGoalCallbacks.add( callback );
     }
 
-    /** Remove all occurences of a <b>post-goal</b> callback from this 
<code>Goal</code>.
-     *
-     *  @param callback The callback to remove.
+    /**
+     * Remove all occurences of a <b>post-goal</b> callback from this 
<code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to remove.
      */
     public void removePostGoalCallback( PostGoalCallback callback )
     {
@@ -287,22 +303,25 @@
         }
     }
 
-    /** Retrieve an unmodifiable list of the <b>post-goal</b> callbacks.
-     *
-     *  @return An unmodifiable <code>List</code> of 
<code>PostGoalCallback</code>s.
+    /**
+     * Retrieve an unmodifiable list of the <b>post-goal</b> callbacks.
+     * 
+     * @return An unmodifiable <code>List</code> of 
<code>PostGoalCallback</code>s.
      */
     public List getPostGoalCallbacks()
     {
         return Collections.unmodifiableList( this.postGoalCallbacks );
     }
 
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-    //     PRE ACTION
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-
-    /** Add a <b>pre-action</b> callback to this <code>Goal</code>.
-     *
-     *  @param callback The callback to add.
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    // PRE ACTION
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+    /**
+     * Add a <b>pre-action</b> callback to this <code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to add.
      */
     public void addPreActionCallback( PreActionCallback callback )
     {
@@ -314,9 +333,11 @@
         this.preActionCallbacks.add( callback );
     }
 
-    /** Remove all occurences of a <b>pre-action</b> callback from this 
<code>Goal</code>.
-     *
-     *  @param callback The callback to remove.
+    /**
+     * Remove all occurences of a <b>pre-action</b> callback from this 
<code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to remove.
      */
     public void removePreActionCallback( PreActionCallback callback )
     {
@@ -326,22 +347,25 @@
         }
     }
 
-    /** Retrieve an unmodifiable list of the <b>pre-action</b> callbacks.
-     *
-     *  @return An unmodifiable <code>List</code> of 
<code>PreActionCallback</code>s.
+    /**
+     * Retrieve an unmodifiable list of the <b>pre-action</b> callbacks.
+     * 
+     * @return An unmodifiable <code>List</code> of 
<code>PreActionCallback</code>s.
      */
     public List getPreActionCallbacks()
     {
         return Collections.unmodifiableList( this.preActionCallbacks );
     }
 
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-    //     POST ACTION
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-
-    /** Add a <b>post-action</b> callback to this <code>Goal</code>.
-     *
-     *  @param callback The callback to add.
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    // POST ACTION
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+    /**
+     * Add a <b>post-action</b> callback to this <code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to add.
      */
     public void addPostActionCallback( PostActionCallback callback )
     {
@@ -353,9 +377,11 @@
         this.postActionCallbacks.add( callback );
     }
 
-    /** Remove all occurences of a <b>post-action</b> callback from this 
<code>Goal</code>.
-     *
-     *  @param callback The callback to remove.
+    /**
+     * Remove all occurences of a <b>post-action</b> callback from this 
<code>Goal</code>.
+     * 
+     * @param callback
+     *            The callback to remove.
      */
     public void removePostActionCallback( PostActionCallback callback )
     {
@@ -365,43 +391,43 @@
         }
     }
 
-    /** Retrieve an unmodifiable list of the <b>post-action</b> callbacks.
-     *
-     *  @return An unmodifiable <code>List</code> of 
<code>PostActionCallback</code>s.
+    /**
+     * Retrieve an unmodifiable list of the <b>post-action</b> callbacks.
+     * 
+     * @return An unmodifiable <code>List</code> of 
<code>PostActionCallback</code>s.
      */
     public List getPostActionCallbacks()
     {
         return Collections.unmodifiableList( this.postActionCallbacks );
     }
 
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
-    /** Determine if this <code>Goal</code> has been satisfied
-     *  for the specified <code>Session</code>.
-     *
-     *  @param session The <code>Session</code> context in which
-     *         to test for goal satisfaction.
-     *
-     *  @return <code>true</code> if this <code>Goal</code> has been
-     *          satisfied within the <code>Session</code>, otherwise
-     *          <code>false</code>.
+    /**
+     * Determine if this <code>Goal</code> has been satisfied for the 
specified <code>Session</code>.
+     * 
+     * @param session
+     *            The <code>Session</code> context in which to test for goal 
satisfaction.
+     * 
+     * @return <code>true</code> if this <code>Goal</code> has been satisfied 
within the <code>Session</code>,
+     *         otherwise <code>false</code>.
      */
     public boolean isSatisfied( Session session )
     {
         return session.isGoalSatisfied( this );
     }
 
-    /** Add a precursor <code>Goal</code> to this <code>Goal</code>.
-     *
-     *  @param precursor The precursor <code>Goal</code> that must
-     *         be satisfied before performing this <code>Goal</code>.
-     *
-     *  @throws CyclicGoalChainException if adding the precursor would
-     *          result in a cyclic dependency.
+    /**
+     * Add a precursor <code>Goal</code> to this <code>Goal</code>.
+     * 
+     * @param precursor
+     *            The precursor <code>Goal</code> that must be satisfied 
before performing this <code>Goal</code>.
+     * 
+     * @throws CyclicGoalChainException
+     *             if adding the precursor would result in a cyclic dependency.
      */
-    public void addPrecursor( Goal precursor )
-        throws CyclicGoalChainException
+    public void addPrecursor( Goal precursor ) throws CyclicGoalChainException
     {
         if ( Collections.EMPTY_LIST.equals( this.precursors ) )
         {
@@ -424,25 +450,27 @@
         }
     }
 
-    /** Add a postcursor <code>Goal</code> to this <code>Goal</code>.
-     *
-     * @param postcursor The postcursor <code>Goal</code> that 
-     *      depends on this <code>Goal</code>.
-     *
-     * @throws CyclicGoalChainException if adding the postcursor would
-     *      result in a cyclic dependency.
+    /**
+     * Add a postcursor <code>Goal</code> to this <code>Goal</code>.
+     * 
+     * @param postcursor
+     *            The postcursor <code>Goal</code> that depends on this 
<code>Goal</code>.
+     * 
+     * @throws CyclicGoalChainException
+     *             if adding the postcursor would result in a cyclic 
dependency.
      */
-    public void addPostcursor( Goal postcursor )
-        throws CyclicGoalChainException
+    public void addPostcursor( Goal postcursor ) throws 
CyclicGoalChainException
     {
         postcursor.addPrecursor( this );
     }
 
-    /** Adds a postcursor <code>Goal</code> without looping back to the 
-     * <code>postcursor.addPrecursor</code> and entering an infinite loop.
+    /**
+     * Adds a postcursor <code>Goal</code> without looping back to the 
<code>postcursor.addPrecursor</code> and
+     * entering an infinite loop.
      * 
-     * @param postcursor The postcursor <code>Goal</code> that is already
-     *      tracking this <code>Goal</goal> as a precursor and is letting this 
+     * @param postcursor
+     *            The postcursor <code>Goal</code> that is already tracking 
this
+     *            <code>Goal</goal> as a precursor and is letting this 
      *      <code>Goal</code> know that it is a postcursor.
      */
     private void addInternalPostcursor( Goal postcursor )
@@ -455,18 +483,18 @@
         this.postcursors.add( postcursor );
     }
 
-    /** Retrieve an unmodifiable <code>List</code> of this <code>Goal</code>'s
-     *  precursor <code>Goal</code>s.
-     *
-     *  @return The <code>List<code> of precursor <code>Goal</code>s.
+    /**
+     * Retrieve an unmodifiable <code>List</code> of this <code>Goal</code>'s 
precursor <code>Goal</code>s.
+     * 
+     * @return The <code>List<code> of precursor <code>Goal</code>s.
      */
     public List getPrecursors()
     {
         return Collections.unmodifiableList( this.precursors );
     }
 
-    /** Retrive an unmodifiable <code>List</code> of this <code>Goal</code>'s
-     * postcursor <code>Goal</code>s.
+    /**
+     * Retrive an unmodifiable <code>List</code> of this <code>Goal</code>'s 
postcursor <code>Goal</code>s.
      * 
      * @return The <code>List</code> of postcursor <code>Goal</code>s.
      */
@@ -475,15 +503,18 @@
         return Collections.unmodifiableList( this.postcursors );
     }
 
-    /** Attempt to attain this <code>Goal</code>'s precursor 
<code>Goal</code>s.
-     *
-     *  @param session The context in which to attain goals.
-     *
-     *  @throws UnattainableGoalException if unable to satisfy a precursor.
-     *  @throws NoActionDefinitionException if this goal contains no action 
definition.
+    /**
+     * Attempt to attain this <code>Goal</code>'s precursor <code>Goal</code>s.
+     * 
+     * @param session
+     *            The context in which to attain goals.
+     * 
+     * @throws UnattainableGoalException
+     *             if unable to satisfy a precursor.
+     * @throws NoActionDefinitionException
+     *             if this goal contains no action definition.
      */
-    void attainPrecursors( Session session )
-        throws UnattainableGoalException, NoActionDefinitionException
+    void attainPrecursors( Session session ) throws UnattainableGoalException, 
NoActionDefinitionException
     {
         Iterator precursorIter = getPrecursors().iterator();
         Goal eachPrereq = null;
@@ -496,15 +527,18 @@
         }
     }
 
-    /** Attempt to attain this <code>Goal</code>'s postcursor 
<code>Goal</code>s.
+    /**
+     * Attempt to attain this <code>Goal</code>'s postcursor 
<code>Goal</code>s.
      * 
-     * @param session The context in which to attain goals.
+     * @param session
+     *            The context in which to attain goals.
      * 
-     * @throws UnattainableGoalException if unable to satisfy a postcursor.
-     * @throws NoActionDefinitionException if this goal contains no action 
definition.
+     * @throws UnattainableGoalException
+     *             if unable to satisfy a postcursor.
+     * @throws NoActionDefinitionException
+     *             if this goal contains no action definition.
      */
-    void percolatePostcursors( Session session )
-        throws UnattainableGoalException, NoActionDefinitionException
+    void percolatePostcursors( Session session ) throws 
UnattainableGoalException, NoActionDefinitionException
     {
         Iterator postreqIter = getPostcursors().iterator();
         Goal eachPostreq = null;
@@ -517,28 +551,32 @@
         }
     }
 
-    /** Perform a cyclic dependency check.
-     *
-     *  @throws CyclicGoalChainException if a dependency cycle is discovered.
+    /**
+     * Perform a cyclic dependency check.
+     * 
+     * @throws CyclicGoalChainException
+     *             if a dependency cycle is discovered.
      */
-    void checkForCycles()
-        throws CyclicGoalChainException
+    void checkForCycles() throws CyclicGoalChainException
     {
         Set visited = new HashSet();
 
         checkForCycles( this, visited );
     }
 
-    /** Perform a cyclic dependency check.
-     *
-     *  @param initialGoal The root <code>Goal</code> initiating the cycle 
check.
-     *  @param visited The <code>Set</code> of all <code>Goal</code>s visited
-     *         between the root <code>initialGoal</code> and this 
<code>Goal</code>.
-     *
-     *  @throws CyclicGoalChainException if a cyclic dependency is detected.
+    /**
+     * Perform a cyclic dependency check.
+     * 
+     * @param initialGoal
+     *            The root <code>Goal</code> initiating the cycle check.
+     * @param visited
+     *            The <code>Set</code> of all <code>Goal</code>s visited 
between the root <code>initialGoal</code>
+     *            and this <code>Goal</code>.
+     * 
+     * @throws CyclicGoalChainException
+     *             if a cyclic dependency is detected.
      */
-    void checkForCycles( Goal initialGoal, Set visited )
-        throws CyclicGoalChainException
+    void checkForCycles( Goal initialGoal, Set visited ) throws 
CyclicGoalChainException
     {
         if ( visited.contains( this ) )
         {
@@ -558,16 +596,18 @@
         }
     }
 
-    /** Attempt to attain this <code>Goal</code>.
-     *
-     *  @param session The context in which to attain goals.
-     *
-     *  @throws UnattainableGoalException if unable to attain this 
<code>Goal</code>
-     *          or one of its precursor <code>Goal</code>s.
-     *  @throws NoActionDefinitionException if this goal contains no action 
definition.
+    /**
+     * Attempt to attain this <code>Goal</code>.
+     * 
+     * @param session
+     *            The context in which to attain goals.
+     * 
+     * @throws UnattainableGoalException
+     *             if unable to attain this <code>Goal</code> or one of its 
precursor <code>Goal</code>s.
+     * @throws NoActionDefinitionException
+     *             if this goal contains no action definition.
      */
-    public final void attain( Session session )
-        throws UnattainableGoalException, NoActionDefinitionException
+    public final void attain( Session session ) throws 
UnattainableGoalException, NoActionDefinitionException
     {
         if ( session.isGoalSatisfied( this ) )
         {
@@ -583,16 +623,18 @@
         fire( session );
     }
 
-    /** Attempt to percolate this <code>Goal</code> through to its Postcursors.
-     *
-     *  @param session The context in which to percolate goals.
-     *
-     *  @throws UnattainableGoalException if unable to attain this 
<code>Goal</code>
-     *          or one of its precursor <code>Goal</code>s.
-     *  @throws NoActionDefinitionException if this goal contains no action 
definition.
+    /**
+     * Attempt to percolate this <code>Goal</code> through to its Postcursors.
+     * 
+     * @param session
+     *            The context in which to percolate goals.
+     * 
+     * @throws UnattainableGoalException
+     *             if unable to attain this <code>Goal</code> or one of its 
precursor <code>Goal</code>s.
+     * @throws NoActionDefinitionException
+     *             if this goal contains no action definition.
      */
-    public final void percolate( Session session )
-        throws UnattainableGoalException, NoActionDefinitionException
+    public final void percolate( Session session ) throws 
UnattainableGoalException, NoActionDefinitionException
     {
         if ( session.isGoalSatisfied( this ) )
         {
@@ -604,17 +646,18 @@
         percolatePostcursors( session );
     }
 
-    /** Fires pre-goal callbacks, the <code>Goal</code>'s action, if need be, 
and 
-     * the post-goal callbacks.
-     *
-     *  @param session The context in which to fire the goal.
-     *
-     *  @throws UnattainableGoalException if unable to attain this 
<code>Goal</code>
-     *          or one of its precursor <code>Goal</code>s.
-     *  @throws NoActionDefinitionException if this goal contains no action 
definition.
+    /**
+     * Fires pre-goal callbacks, the <code>Goal</code>'s action, if need be, 
and the post-goal callbacks.
+     * 
+     * @param session
+     *            The context in which to fire the goal.
+     * 
+     * @throws UnattainableGoalException
+     *             if unable to attain this <code>Goal</code> or one of its 
precursor <code>Goal</code>s.
+     * @throws NoActionDefinitionException
+     *             if this goal contains no action definition.
      */
-    private final void fire( Session session )
-        throws UnattainableGoalException, NoActionDefinitionException
+    private final void fire( Session session ) throws 
UnattainableGoalException, NoActionDefinitionException
     {
         session.info( getName() + ":" );
 
@@ -675,12 +718,13 @@
         session.info( "" );
     }
 
-    /** Fire the pre-goal callbacks.
-     *
-     *  @throws Exception if an error occurs while firing a callback.
+    /**
+     * Fire the pre-goal callbacks.
+     * 
+     * @throws Exception
+     *             if an error occurs while firing a callback.
      */
-    void firePreGoalCallbacks()
-        throws Exception
+    void firePreGoalCallbacks() throws Exception
     {
         Iterator callbackIter = this.preGoalCallbacks.iterator();
         PreGoalCallback eachCallback = null;
@@ -694,20 +738,24 @@
 
         while ( callbackIter.hasNext() )
         {
-            eachCallback = (PreGoalCallback) callbackIter.next();
+            synchronized ( callbackIter )
+            {
+                eachCallback = (PreGoalCallback) callbackIter.next();
+                eachCallback.firePreGoal( this );
+            }
 
-            eachCallback.firePreGoal( this );
         }
 
         // log.info( "end pre-goal callbacks" );
     }
 
-    /** Fire the post-goal callbacks.
-     *
-     *  @throws Exception if an error occurs while firing a callback.
+    /**
+     * Fire the post-goal callbacks.
+     * 
+     * @throws Exception
+     *             if an error occurs while firing a callback.
      */
-    void firePostGoalCallbacks()
-        throws Exception
+    void firePostGoalCallbacks() throws Exception
     {
         Iterator callbackIter = this.postGoalCallbacks.iterator();
         PostGoalCallback eachCallback = null;
@@ -720,12 +768,13 @@
         }
     }
 
-    /** Fire the pre-action callbacks.
-     *
-     *  @throws Exception if an error occurs while firing a callback.
+    /**
+     * Fire the pre-action callbacks.
+     * 
+     * @throws Exception
+     *             if an error occurs while firing a callback.
      */
-    void firePreActionCallbacks()
-        throws Exception
+    void firePreActionCallbacks() throws Exception
     {
         Iterator callbackIter = this.preActionCallbacks.iterator();
         PreActionCallback eachCallback = null;
@@ -738,12 +787,13 @@
         }
     }
 
-    /** Fire the post-action callbacks.
-     *
-     *  @throws Exception if an error occurs while firing a callback.
+    /**
+     * Fire the post-action callbacks.
+     * 
+     * @throws Exception
+     *             if an error occurs while firing a callback.
      */
-    void firePostActionCallbacks()
-        throws Exception
+    void firePostActionCallbacks() throws Exception
     {
         Iterator callbackIter = this.postActionCallbacks.iterator();
         PostActionCallback eachCallback = null;
@@ -757,34 +807,34 @@
     }
 
     // ------------------------------------------------------------
-    //     java.lang.Object implementation
+    // java.lang.Object implementation
     // ------------------------------------------------------------
 
-    /** Retrieve the hash-code of this object.
-     *
-     *  <p>
-     *  The hash-code is derrived <b>only</b> from the name of
-     *  the <code>Goal</code> as returned by [EMAIL PROTECTED] #getName}.
-     *  </p>
-     *
-     *  @return The hash-code of this object.
+    /**
+     * Retrieve the hash-code of this object.
+     * 
+     * <p>
+     * The hash-code is derrived <b>only</b> from the name of the 
<code>Goal</code> as returned by [EMAIL PROTECTED] #getName}.
+     * </p>
+     * 
+     * @return The hash-code of this object.
      */
     public int hashCode()
     {
         return getName().hashCode();
     }
 
-    /** Determine if two <code>Goal</code> objects are 
-     *  equivelant.
-     *
-     *  <p>
-     *  Equivelancy is determined <b>only</b> from the names
-     *  of the <code>Goal</code>s as return by [EMAIL PROTECTED] #getName}.
-     *  </p>
-     *
-     *  @param thatObj The object to compare to this object.
-     *
-     *  @return The hash-code of this object.
+    /**
+     * Determine if two <code>Goal</code> objects are equivelant.
+     * 
+     * <p>
+     * Equivelancy is determined <b>only</b> from the names of the 
<code>Goal</code>s as return by [EMAIL PROTECTED] #getName}.
+     * </p>
+     * 
+     * @param thatObj
+     *            The object to compare to this object.
+     * 
+     * @return The hash-code of this object.
      */
     public boolean equals( Object thatObj )
     {
@@ -793,9 +843,10 @@
         return this.getName().equals( that.getName() );
     }
 
-    /** Produce a textual representation suitable for debugging.
-     *
-     *  @return A textual representation suitable for debugging.
+    /**
+     * Produce a textual representation suitable for debugging.
+     * 
+     * @return A textual representation suitable for debugging.
      */
     public String toString()
     {


Reply via email to