org.primordion.xholon.base
Class TreeNodeFactoryStatic

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.TreeNodeFactoryStatic
All Implemented Interfaces:
ITreeNodeFactory, IXholon

public class TreeNodeFactoryStatic
extends Xholon
implements ITreeNodeFactory

TreeNodeFactoryStatic manages concrete instances of TreeNode subclasses. A finite number of reusable entities are allocated when the app starts up. Call the various get methods to get instances of Xholon, XholonClass, StateMachineEntity, and Activity. Call the return method to return any of these to the factory for reuse. This is a Singleton class. Internally, the TreeNode instances are maintained in arrays, one for each subclass. This could be changed later if necessary, while having no effect on the rest of the system.

Since:
0.1 (Created on Jun 8, 2005)
Author:
Ken Webb

Field Summary
static int RESOURCE_ACTIVITY
           
static int RESOURCE_STATEMACHINEENTITY
           
static int RESOURCE_XHOLON
           
static int RESOURCE_XHOLONCLASS
           
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Constructor Summary
TreeNodeFactoryStatic(java.lang.Class xholonSubclass, java.lang.Class xholonClassSubclass)
          Default constructor.
TreeNodeFactoryStatic(int maxXholons, int maxXholonClasses, int maxActivities, int maxStateMachineEntities, java.lang.Class xholonSubclass, java.lang.Class xholonClassSubclass)
          Preferred constructor.
TreeNodeFactoryStatic(int maxXholons, int maxXholonClasses, int maxActivities, int maxStateMachineEntities, java.lang.Class xholonSubclass, java.lang.Class xholonClassSubclass, java.lang.Class activitySubclass)
          Constructor for apps that need to use a subclass of Activity.
 
Method Summary
 Activity getActivityNode()
          Get a Activity node from the factory.
 AbstractGrid getGridEntityNode()
          Get a GridEntity node from the factory.
 IXholon getNode(java.lang.Class xholonSubclass)
          Get a node instance of the specified Java class.
 IXholon getNode(int xhType)
          Get a node instance of the specified Xholon Type.
 int getNumAvailNodes(int resourceType)
          Get number of treeNodes available for use.
 StateMachineEntity getStateMachineEntityNode()
          Get a StateMaqchineEntity node from the factory.
 IXholonClass getXholonClassNode()
          Get a XholonClass instance from the factory.
 IXholon getXholonNode()
          Get a Xholon instance from the factory.
 IXholon getXholonNode(java.lang.String implName)
          Get a Xholon instance from the factory, based on its full package name.
 void returnTreeNode(IXholon node)
          Return a TreeNode to the factory.
 
Methods inherited from class org.primordion.xholon.base.Xholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getSizeMessageQ, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setSizeMessageQ, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, toString, treeSize, writeXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize, writeXml
 

Field Detail

RESOURCE_XHOLON

public static final int RESOURCE_XHOLON
See Also:
Constant Field Values

RESOURCE_XHOLONCLASS

public static final int RESOURCE_XHOLONCLASS
See Also:
Constant Field Values

RESOURCE_ACTIVITY

public static final int RESOURCE_ACTIVITY
See Also:
Constant Field Values

RESOURCE_STATEMACHINEENTITY

public static final int RESOURCE_STATEMACHINEENTITY
See Also:
Constant Field Values
Constructor Detail

TreeNodeFactoryStatic

public TreeNodeFactoryStatic(java.lang.Class xholonSubclass,
                             java.lang.Class xholonClassSubclass)
Default constructor. Uses default array and queue sizes. TODO Handle Q_FULL condition in constructors, although it shouldn't occur.


TreeNodeFactoryStatic

public TreeNodeFactoryStatic(int maxXholons,
                             int maxXholonClasses,
                             int maxActivities,
                             int maxStateMachineEntities,
                             java.lang.Class xholonSubclass,
                             java.lang.Class xholonClassSubclass)
Preferred constructor.

Parameters:
maxXholons - Maximum number of Xholons in the application.
maxXholonClasses - Maximum number of XholonClasses in the application.
maxActivities - Maximum number of Activities in the application.
maxStateMachineEntities - Maximum number of StateMachineEntities in the application.
xholonSubclass - Which subclass of Xholon should be instantiated.
xholonClassSubclass - Which subclass of XholonClass should be instantiated.

TreeNodeFactoryStatic

public TreeNodeFactoryStatic(int maxXholons,
                             int maxXholonClasses,
                             int maxActivities,
                             int maxStateMachineEntities,
                             java.lang.Class xholonSubclass,
                             java.lang.Class xholonClassSubclass,
                             java.lang.Class activitySubclass)
Constructor for apps that need to use a subclass of Activity.

Parameters:
maxXholons - Maximum number of Xholons in the application.
maxXholonClasses - Maximum number of XholonClasses in the application.
maxActivities - Maximum number of Activities in the application.
maxStateMachineEntities - Maximum number of StateMachineEntities in the application.
xholonSubclass - Which subclass of Xholon should be instantiated.
xholonClassSubclass - Which subclass of XholonClass should be instantiated.
activitySubclass - Which subclass of Activity should be instantiated.
Method Detail

getNumAvailNodes

public int getNumAvailNodes(int resourceType)
Description copied from interface: ITreeNodeFactory
Get number of treeNodes available for use.

Specified by:
getNumAvailNodes in interface ITreeNodeFactory
Parameters:
resourceType - The type of node: Xholon, XholonClass, StateMachineEntity, or Activity.
Returns:
Number of available nodes.

getNode

public IXholon getNode(java.lang.Class xholonSubclass)
Description copied from interface: ITreeNodeFactory
Get a node instance of the specified Java class.

Specified by:
getNode in interface ITreeNodeFactory
Parameters:
xholonSubclass -
Returns:
An IXholon instance.

getNode

public IXholon getNode(int xhType)
Description copied from interface: ITreeNodeFactory
Get a node instance of the specified Xholon Type.

Specified by:
getNode in interface ITreeNodeFactory
Parameters:
xhType -
Returns:
An IXholon instance.

getXholonNode

public IXholon getXholonNode()
Description copied from interface: ITreeNodeFactory
Get a Xholon instance from the factory.

Specified by:
getXholonNode in interface ITreeNodeFactory
Returns:
The next available instance, or null. TODO Need to handle null (Q_EMPTY) condition gracefully.

getXholonNode

public IXholon getXholonNode(java.lang.String implName)
Description copied from interface: ITreeNodeFactory
Get a Xholon instance from the factory, based on its full package name.

Specified by:
getXholonNode in interface ITreeNodeFactory
Parameters:
implName - The name of a Java class.
Returns:
An instance of that class, or null.

getXholonClassNode

public IXholonClass getXholonClassNode()
Description copied from interface: ITreeNodeFactory
Get a XholonClass instance from the factory.

Specified by:
getXholonClassNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

getActivityNode

public Activity getActivityNode()
Description copied from interface: ITreeNodeFactory
Get a Activity node from the factory.

Specified by:
getActivityNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

getStateMachineEntityNode

public StateMachineEntity getStateMachineEntityNode()
Description copied from interface: ITreeNodeFactory
Get a StateMaqchineEntity node from the factory.

Specified by:
getStateMachineEntityNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

getGridEntityNode

public AbstractGrid getGridEntityNode()
Description copied from interface: ITreeNodeFactory
Get a GridEntity node from the factory.

Specified by:
getGridEntityNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

returnTreeNode

public void returnTreeNode(IXholon node)
Description copied from interface: ITreeNodeFactory
Return a TreeNode to the factory.

Specified by:
returnTreeNode in interface ITreeNodeFactory
Parameters:
node - The TreeNode being returned.