org.apache.maven.werkz
Class Goal

java.lang.Object
  extended byorg.apache.maven.werkz.Goal
Direct Known Subclasses:
ProjectGoal

public class Goal
extends java.lang.Object

Abstract Goal to attain.

A Goal embodies both an action and the precursors for that action. A Goal's precursors will be satisfied before attempting to perform the target Goal'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 Goal.

A Goal's postcursors are also tracked so that if a Goal's state has been changed and the Goals ahead of it in the hierarchy need to be notified, it can percolate forward and have it's postcursors satisfied.

Author:
bob mcwhirter
See Also:
WerkzProject, Action

Field Summary
static Goal[] EMPTY_ARRAY
          Empty Goal array.
 
Constructor Summary
Goal(java.lang.String name)
          Construct a new Goal with the specified name.
Goal(java.lang.String name, Action action)
          Construct a new Goal with the specified name and Action.
 
Method Summary
 void addPostActionCallback(PostActionCallback callback)
          Add a post-action callback to this Goal.
 void addPostcursor(Goal postcursor)
          Add a postcursor Goal to this Goal.
 void addPostGoalCallback(PostGoalCallback callback)
          Add a post-goal callback to this Goal.
 void addPreActionCallback(PreActionCallback callback)
          Add a pre-action callback to this Goal.
 void addPrecursor(Goal precursor)
          Add a precursor Goal to this Goal.
 void addPreGoalCallback(PreGoalCallback callback)
          Add a pre-goal callback to this Goal.
 void attain(Session session)
          Attempt to attain this Goal.
(package private)  void attainPrecursors(Session session)
          Attempt to attain this Goal's precursor Goals.
(package private)  void checkForCycles()
          Perform a cyclic dependency check.
(package private)  void checkForCycles(Goal initialGoal, java.util.Set visited)
          Perform a cyclic dependency check.
 boolean equals(java.lang.Object thatObj)
          Determine if two Goal objects are equivelant.
(package private)  void firePostActionCallbacks()
          Fire the post-action callbacks.
(package private)  void firePostGoalCallbacks()
          Fire the post-goal callbacks.
(package private)  void firePreActionCallbacks()
          Fire the pre-action callbacks.
(package private)  void firePreGoalCallbacks()
          Fire the pre-goal callbacks.
 Action getAction()
          Retrieve the Action of this Goal.
 java.lang.String getDescription()
          Retrieve the description of this Goal.
 java.lang.String getName()
          Retrieve the name of this Goal.
 java.util.List getPostActionCallbacks()
          Retrieve an unmodifiable list of the post-action callbacks.
 java.util.List getPostcursors()
          Retrive an unmodifiable List of this Goal's postcursor Goals.
 java.util.List getPostGoalCallbacks()
          Retrieve an unmodifiable list of the post-goal callbacks.
 java.util.List getPreActionCallbacks()
          Retrieve an unmodifiable list of the pre-action callbacks.
 java.util.List getPrecursors()
          Retrieve an unmodifiable List of this Goal's precursor Goals.
 java.util.List getPreGoalCallbacks()
          Retrieve an unmodifiable list of the pre-goal callbacks.
 int hashCode()
          Retrieve the hash-code of this object.
 boolean isSatisfied(Session session)
          Determine if this Goal has been satisfied for the specified Session.
 void percolate(Session session)
          Attempt to percolate this Goal through to its Postcursors.
(package private)  void percolatePostcursors(Session session)
          Attempt to attain this Goal's postcursor Goals.
 void removePostActionCallback(PostActionCallback callback)
          Remove all occurences of a post-action callback from this Goal.
 void removePostGoalCallback(PostGoalCallback callback)
          Remove all occurences of a post-goal callback from this Goal.
 void removePreActionCallback(PreActionCallback callback)
          Remove all occurences of a pre-action callback from this Goal.
 void removePreGoalCallback(PreGoalCallback callback)
          Remove all occurences of a pre-goal callback from this Goal.
 void setAction(Action action)
          Set the Action of this Goal.
 void setDescription(java.lang.String description)
          Set the description for this Goal.
 java.lang.String toString()
          Produce a textual representation suitable for debugging.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final Goal[] EMPTY_ARRAY
Empty Goal array.

Constructor Detail

Goal

public Goal(java.lang.String name)
Construct a new Goal with the specified name.

Parameters:
name - The name of the Goal.

Goal

public Goal(java.lang.String name,
            Action action)
Construct a new Goal with the specified name and Action.

Parameters:
name - The name of the Goal.
action - The Action for this Goal.
Method Detail

getName

public java.lang.String getName()
Retrieve the name of this Goal.

Returns:
This Goal's name.

getDescription

public java.lang.String getDescription()
Retrieve the description of this Goal.

Returns:
The description of this goal.

setDescription

public void setDescription(java.lang.String description)
Set the description for this Goal.

Parameters:
description - The description of this goal.

getAction

public Action getAction()
Retrieve the Action of this Goal.

Returns:
The Action of this Goal.

setAction

public void setAction(Action action)
Set the Action of this Goal.

Parameters:
action - The Action of this Goal.

addPreGoalCallback

public void addPreGoalCallback(PreGoalCallback callback)
Add a pre-goal callback to this Goal.

Parameters:
callback - The callback to add.

removePreGoalCallback

public void removePreGoalCallback(PreGoalCallback callback)
Remove all occurences of a pre-goal callback from this Goal.

Parameters:
callback - The callback to remove.

getPreGoalCallbacks

public java.util.List getPreGoalCallbacks()
Retrieve an unmodifiable list of the pre-goal callbacks.

Returns:
An unmodifiable List of PreGoalCallbacks.

addPostGoalCallback

public void addPostGoalCallback(PostGoalCallback callback)
Add a post-goal callback to this Goal.

Parameters:
callback - The callback to add.

removePostGoalCallback

public void removePostGoalCallback(PostGoalCallback callback)
Remove all occurences of a post-goal callback from this Goal.

Parameters:
callback - The callback to remove.

getPostGoalCallbacks

public java.util.List getPostGoalCallbacks()
Retrieve an unmodifiable list of the post-goal callbacks.

Returns:
An unmodifiable List of PostGoalCallbacks.

addPreActionCallback

public void addPreActionCallback(PreActionCallback callback)
Add a pre-action callback to this Goal.

Parameters:
callback - The callback to add.

removePreActionCallback

public void removePreActionCallback(PreActionCallback callback)
Remove all occurences of a pre-action callback from this Goal.

Parameters:
callback - The callback to remove.

getPreActionCallbacks

public java.util.List getPreActionCallbacks()
Retrieve an unmodifiable list of the pre-action callbacks.

Returns:
An unmodifiable List of PreActionCallbacks.

addPostActionCallback

public void addPostActionCallback(PostActionCallback callback)
Add a post-action callback to this Goal.

Parameters:
callback - The callback to add.

removePostActionCallback

public void removePostActionCallback(PostActionCallback callback)
Remove all occurences of a post-action callback from this Goal.

Parameters:
callback - The callback to remove.

getPostActionCallbacks

public java.util.List getPostActionCallbacks()
Retrieve an unmodifiable list of the post-action callbacks.

Returns:
An unmodifiable List of PostActionCallbacks.

isSatisfied

public boolean isSatisfied(Session session)
Determine if this Goal has been satisfied for the specified Session.

Parameters:
session - The Session context in which to test for goal satisfaction.
Returns:
true if this Goal has been satisfied within the Session, otherwise false.

addPrecursor

public void addPrecursor(Goal precursor)
                  throws CyclicGoalChainException
Add a precursor Goal to this Goal.

Parameters:
precursor - The precursor Goal that must be satisfied before performing this Goal.
Throws:
CyclicGoalChainException - if adding the precursor would result in a cyclic dependency.

addPostcursor

public void addPostcursor(Goal postcursor)
                   throws CyclicGoalChainException
Add a postcursor Goal to this Goal.

Parameters:
postcursor - The postcursor Goal that depends on this Goal.
Throws:
CyclicGoalChainException - if adding the postcursor would result in a cyclic dependency.

getPrecursors

public java.util.List getPrecursors()
Retrieve an unmodifiable List of this Goal's precursor Goals.

Returns:
The List of precursor Goals.

getPostcursors

public java.util.List getPostcursors()
Retrive an unmodifiable List of this Goal's postcursor Goals.

Returns:
The List of postcursor Goals.

attainPrecursors

void attainPrecursors(Session session)
                throws UnattainableGoalException,
                       NoActionDefinitionException
Attempt to attain this Goal's precursor Goals.

Parameters:
session - The context in which to attain goals.
Throws:
UnattainableGoalException - if unable to satisfy a precursor.
NoActionDefinitionException - if this goal contains no action definition.

percolatePostcursors

void percolatePostcursors(Session session)
                    throws UnattainableGoalException,
                           NoActionDefinitionException
Attempt to attain this Goal's postcursor Goals.

Parameters:
session - The context in which to attain goals.
Throws:
UnattainableGoalException - if unable to satisfy a postcursor.
NoActionDefinitionException - if this goal contains no action definition.

checkForCycles

void checkForCycles()
              throws CyclicGoalChainException
Perform a cyclic dependency check.

Throws:
CyclicGoalChainException - if a dependency cycle is discovered.

checkForCycles

void checkForCycles(Goal initialGoal,
                    java.util.Set visited)
              throws CyclicGoalChainException
Perform a cyclic dependency check.

Parameters:
initialGoal - The root Goal initiating the cycle check.
visited - The Set of all Goals visited between the root initialGoal and this Goal.
Throws:
CyclicGoalChainException - if a cyclic dependency is detected.

attain

public final void attain(Session session)
                  throws UnattainableGoalException,
                         NoActionDefinitionException
Attempt to attain this Goal.

Parameters:
session - The context in which to attain goals.
Throws:
UnattainableGoalException - if unable to attain this Goal or one of its precursor Goals.
NoActionDefinitionException - if this goal contains no action definition.

percolate

public final void percolate(Session session)
                     throws UnattainableGoalException,
                            NoActionDefinitionException
Attempt to percolate this Goal through to its Postcursors.

Parameters:
session - The context in which to percolate goals.
Throws:
UnattainableGoalException - if unable to attain this Goal or one of its precursor Goals.
NoActionDefinitionException - if this goal contains no action definition.

firePreGoalCallbacks

void firePreGoalCallbacks()
                    throws java.lang.Exception
Fire the pre-goal callbacks.

Throws:
java.lang.Exception - if an error occurs while firing a callback.

firePostGoalCallbacks

void firePostGoalCallbacks()
                     throws java.lang.Exception
Fire the post-goal callbacks.

Throws:
java.lang.Exception - if an error occurs while firing a callback.

firePreActionCallbacks

void firePreActionCallbacks()
                      throws java.lang.Exception
Fire the pre-action callbacks.

Throws:
java.lang.Exception - if an error occurs while firing a callback.

firePostActionCallbacks

void firePostActionCallbacks()
                       throws java.lang.Exception
Fire the post-action callbacks.

Throws:
java.lang.Exception - if an error occurs while firing a callback.

hashCode

public int hashCode()
Retrieve the hash-code of this object.

The hash-code is derrived only from the name of the Goal as returned by getName().

Returns:
The hash-code of this object.

equals

public boolean equals(java.lang.Object thatObj)
Determine if two Goal objects are equivelant.

Equivelancy is determined only from the names of the Goals as return by getName().

Parameters:
thatObj - The object to compare to this object.
Returns:
The hash-code of this object.

toString

public java.lang.String toString()
Produce a textual representation suitable for debugging.

Returns:
A textual representation suitable for debugging.


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.