org.apache.anteater.test
Class Group

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.types.DataType
              |
              +--org.apache.anteater.test.BaseDataType
                    |
                    +--org.apache.anteater.test.Group
All Implemented Interfaces:
Groupable
Direct Known Subclasses:
DefaultGroup

public class Group
extends BaseDataType

A Group is a scoping mechanism for Anteater data types and tasks. A group acts as a container for sets of Anteater objects, where member objects can access each other. So, for example, ActionTask tasks will automatically use any Loggers or Sessions defined in the group they belong to.

Since a Group is a BaseDataType, and that implements Groupable, Groups can belong to groups. This is exploited to implement group inheritance, where Groups inherit properties, loggers and sessions from their "parent" Group, where a Group's "parent" is the Group it belongs to.

The inheritance rules are as follows:

There is a default, primordial Group to which all Groups and Tasks belong, unless otherwise specified. This is defined in DefaultGroup.getDefaultGroup(org.apache.tools.ant.Project), and is overridden by any group defined with id 'default'.

Since:
July 2, 2002
Version:
$Revision: 1.15 $ $Date: 2002/10/17 13:17:41 $
Author:
Jeff Turner

Field Summary
protected  String _id
           
protected  ArrayList _loggers
          List of LoggerFactory objects.
protected  ArrayList _namespaces
          List of Namespace objects.
protected  ArrayList _props
          List of Property objects.
protected  ArrayList _sessions
          List of Session objects.
protected  ArrayList _tasks
          List of BaseTask objects.
protected  ArrayList _uses
          List of Features required by this group's actions.
 
Fields inherited from class org.apache.anteater.test.BaseDataType
debug, debugWasSet
 
Fields inherited from class org.apache.tools.ant.types.DataType
checked, description, ref
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Group()
           
 
Method Summary
 void add(Groupable o)
          Add a Groupable Anteater object to this group.
 void addConfiguredGroup(Group childGroup)
          Set this object as the ancestor of a group.
 void addLogger(LoggerFactory loggerFactory)
          Add a <logger .../> to the group.
 void addNamespace(Namespace ns)
          Add a <namespace/> to the group.
 void addProperty(org.apache.tools.ant.taskdefs.Property p)
          Add an Ant Property to the group.
 void addSession(Session session)
          Add a <session/> to the group.
 void addTask(BaseTask task)
          Add a BaseTask, eg <httpRequest>, to the session.
 void addUses(Uses uses)
           
 Group getGroup()
          Return our ancestor Group, or a DefaultGroup if we are group with id 'default'.
 String getId()
          Retrieve the id which Ant refers to this object by.
 ArrayList getLoggers()
          Retrieve Loggers.
 ArrayList getNamespaces()
          Return a set of Properties, representing those either native to this Group, or inherited from a subgroup.
 ArrayList getProperties()
          Return a set of Properties, representing those either native to this Group, or inherited from a subgroup.
 Session getSession()
           
 ArrayList getUses()
           
 void setGroup(Group group)
          Set the parent group of this group.
 void setId(String id)
          Set Ant id.
 void setInherits(String group)
          Set the parent group of this group.
 String toString()
          String representation of the group, for debugging.
 
Methods inherited from class org.apache.anteater.test.BaseDataType
debug, getDataTypeName, getDebug, getRef, print, println, setDebug, setGroup, setRefid
 
Methods inherited from class org.apache.tools.ant.types.DataType
circularReference, dieOnCircularReference, getCheckedRef, getDescription, isReference, noChildrenAllowed, setDescription, tooManyAttributes
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, log, log, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_sessions

protected ArrayList _sessions
List of Session objects.


_loggers

protected ArrayList _loggers
List of LoggerFactory objects.


_tasks

protected ArrayList _tasks
List of BaseTask objects.


_props

protected ArrayList _props
List of Property objects.


_namespaces

protected ArrayList _namespaces
List of Namespace objects.


_uses

protected ArrayList _uses
List of Features required by this group's actions.


_id

protected String _id
Constructor Detail

Group

public Group()
Method Detail

setGroup

public void setGroup(Group group)
Set the parent group of this group. Objects will be inherited from the parent.

Specified by:
setGroup in interface Groupable
Overrides:
setGroup in class BaseDataType
Parameters:
group - Group object to add this task to.
See Also:
addConfiguredGroup(org.apache.anteater.test.Group)

setInherits

public void setInherits(String group)
Set the parent group of this group. Alias for setGroup(org.apache.anteater.test.Group).


add

public void add(Groupable o)
Add a Groupable Anteater object to this group. This method is called mainly from BaseTask.setGroup(Group).

Parameters:
o - A Session, LoggerFactory, Task or Namespace.


addConfiguredGroup

public void addConfiguredGroup(Group childGroup)
Set this object as the ancestor of a group.

Parameters:
childGroup - the group which will have this object as an ancestor.
See Also:
setGroup(org.apache.anteater.test.Group)

addSession

public void addSession(Session session)
Add a <session/> to the group.


addLogger

public void addLogger(LoggerFactory loggerFactory)
Add a <logger .../> to the group.


addUses

public void addUses(Uses uses)

addTask

public void addTask(BaseTask task)
Add a BaseTask, eg <httpRequest>, to the session. Or conversely, make available all objects in the Group (loggers, sessions and properties to the Task.

Parameters:
task - Task to add to group.

addProperty

public void addProperty(org.apache.tools.ant.taskdefs.Property p)
Add an Ant Property to the group. Eg, <property name="host" value="myhost.com"/>


addNamespace

public void addNamespace(Namespace ns)
Add a <namespace/> to the group.


getUses

public ArrayList getUses()

getLoggers

public ArrayList getLoggers()
Retrieve Loggers. If any loggers were added specifically to this group, they will be returned, otherwise this group's parents' loggers will be returned.


getNamespaces

public ArrayList getNamespaces()
Return a set of Properties, representing those either native to this Group, or inherited from a subgroup. Thus this function will recurse through the Group hierarchy, and "higher" groups' Properties will mask those of lower groups'.


getProperties

public ArrayList getProperties()
Return a set of Properties, representing those either native to this Group, or inherited from a subgroup. Thus this function will recurse through the Group hierarchy, and "higher" groups' Properties will mask those of lower groups'.


getSession

public Session getSession()

getGroup

public Group getGroup()
Return our ancestor Group, or a DefaultGroup if we are group with id 'default'. our ancestor will just blindly adopt a 'default' group as parent. However in our case, we could BE the 'default' group, so we check for that here.

Overrides:
getGroup in class BaseDataType

toString

public String toString()
String representation of the group, for debugging.

Overrides:
toString in class Object

setId

public void setId(String id)
Set Ant id.


getId

public String getId()
Retrieve the id which Ant refers to this object by.



Ant Functional Tester -- see Project home page for details