org.apache.maven.werkz
Class WerkzProject

java.lang.Object
  extended byorg.apache.maven.werkz.WerkzProject

public class WerkzProject
extends java.lang.Object

General Goal manager.

It is not strictly necessary to maintain a Goal graph, it does assist in organizing and administering a group of Goals.

Author:
bob mcwhirter
See Also:
Goal

Constructor Summary
WerkzProject()
          Construct.
 
Method Summary
 void addGoal(Goal goal)
          Add a Goal to this manager.
 void attainGoal(java.lang.String name)
          Attempt to attain the specified goal.
 void attainGoal(java.lang.String name, Session session)
          Attempt to attain the specified goal.
 Goal getDefaultGoal()
          Retrieve the default goal.
 java.lang.String getDefaultGoalName()
          Retrieve the default goal name.
 Goal[] getExecutionChain(java.lang.String name)
          Retrieve a valid execution chain to attain the specified goal.
 Goal getGoal(java.lang.String name)
          Retrieve a Goal by name from this manager.
 Goal getGoal(java.lang.String name, boolean create)
          Retrieve a Goal by name from this manager.
 java.util.Collection getGoals()
          Retrieve an unmodifiable collection of all Goals that are a part of this Project.
 void percolateGoal(java.lang.String name)
          Attempt to percolate the specified goal.
 void percolateGoal(java.lang.String name, Session session)
          Attempt to percolate the specified goal.
 void removeGoal(java.lang.String name)
           
 void setDefaultGoalName(java.lang.String defaultGoalName)
          Set the default goal name.
 java.lang.String toString()
          Produce a textual representation suitable for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WerkzProject

public WerkzProject()
Construct.

Method Detail

getExecutionChain

public Goal[] getExecutionChain(java.lang.String name)
                         throws NoSuchGoalException
Retrieve a valid execution chain to attain the specified goal.

This method returns one of possibly many different valid execution chains. All chains will be of the same length. This implementation happens to perform a breadth-first walk, so the chain will grow from the deepest sections to the showllowest instead of plunging/surging upwards.

        B - D
      /       \
    A           F
      \       /
        C - E
  
will result in either FEDCBA or FDEBCA but will not result in the equally valid FECDBA or FDBECA sequences.

The ordering of the array is such that the index length - 1 (the last index of the array) points to the Goal specified as the parameter to the method.

Parameters:
name - The name of the goal.
Returns:
The array of goals in the execution chain, terminating with the requested goal as the last member.
Throws:
NoSuchGoalException - if the name refers to no known goal.

attainGoal

public void attainGoal(java.lang.String name,
                       Session session)
                throws NoSuchGoalException,
                       UnattainableGoalException,
                       NoActionDefinitionException
Attempt to attain the specified goal.

Parameters:
name - The name of the goal to attain.
session - The context in which to attain goals.
Throws:
NoSuchGoalException - if the name refers to no known goal.
UnattainableGoalException - if a precursor or the goal itself had an error.
NoActionDefinitionException - if a goal contains no action definition.

percolateGoal

public void percolateGoal(java.lang.String name,
                          Session session)
                   throws NoSuchGoalException,
                          UnattainableGoalException,
                          NoActionDefinitionException
Attempt to percolate the specified goal.

Parameters:
name - The name of the goal to percolate.
session - The context in which to percolate goals.
Throws:
NoSuchGoalException - if the name refers to no known goal.
UnattainableGoalException - if a postcursor or the goal itself had an error.
NoActionDefinitionException - if a goal contains no action definition.

attainGoal

public void attainGoal(java.lang.String name)
                throws NoSuchGoalException,
                       UnattainableGoalException,
                       NoActionDefinitionException
Attempt to attain the specified goal.

Parameters:
name - The name of the goal to attain.
Throws:
NoSuchGoalException - if the name refers to no known goal.
UnattainableGoalException - if a precursor or the goal itself had an error.
NoActionDefinitionException - if a goal contains no action definition.

percolateGoal

public void percolateGoal(java.lang.String name)
                   throws NoSuchGoalException,
                          UnattainableGoalException,
                          NoActionDefinitionException
Attempt to percolate the specified goal.

Parameters:
name - The name of the goal to percolate.
Throws:
NoSuchGoalException - if the name refers to no known goal.
UnattainableGoalException - if a postcursor or the goal itself had an error.
NoActionDefinitionException - if a goal contains no action definition.

addGoal

public void addGoal(Goal goal)
Add a Goal to this manager.

Parameters:
goal - The Goal to add.

getGoal

public Goal getGoal(java.lang.String name)
Retrieve a Goal by name from this manager.

Parameters:
name - The name of the goal to retrieve.
Returns:
The Goal associated with the name, or null if there is no such Goal.

getGoal

public Goal getGoal(java.lang.String name,
                    boolean create)
Retrieve a Goal by name from this manager.

Parameters:
name - The name of the goal to retrieve.
create - Flag indicating if a new Goal should be created and returned if none currently exists bound to name.
Returns:
The existing Goal associated with the name, or a new Goal if none was previously associated with name.

setDefaultGoalName

public void setDefaultGoalName(java.lang.String defaultGoalName)
Set the default goal name.

Parameters:
defaultGoalName - The name of the default goal.

getDefaultGoalName

public java.lang.String getDefaultGoalName()
Retrieve the default goal name.

Returns:
The namee of the default goal, or null if not set.

getDefaultGoal

public Goal getDefaultGoal()
Retrieve the default goal.

Returns:
The default Goal or null if a valid default goal name has not been previously specified using setDefaultGoalName(java.lang.String).

getGoals

public java.util.Collection getGoals()
Retrieve an unmodifiable collection of all Goals that are a part of this Project.

Returns:
An unmodifiable collection of all Goals that are members of this Project.

toString

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

Returns:
A textual representation suitable for debugging.

removeGoal

public void removeGoal(java.lang.String name)


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