org.primordion.xholon.base
Class Port

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

public class Port
extends Xholon
implements IPort

Port is one type of concrete "port" in a xholon application. The other alternative is for a xholon to have a direct reference to another xholon. There is more flexibility using the Port class, but there is also more overhead.

Since:
0.4 (Created on August 21, 2006)
Author:
Ken Webb

Field Summary
 IXholon[] replication
          Replications of this port.
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.IPort
XPATH_EXPR_NO_INDEX, XPATH_EXPR_WILDCARD
 
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
Port()
           
 
Method Summary
static IPort createPort(IXholon portOwner, int multiplicity, int[] provIfSigs, java.lang.String[] provIfNames, int[] reqIfSigs, java.lang.String[] reqIfNames, boolean isConjugated)
          Create an instance of the Port class.
 boolean getIsConjugated()
          Get whether or not this is a conjugated port.
 IXholon getLink(int index)
          Get the link from a local port replication to a remote port or xholon.
 java.lang.String getName()
          Get name, unique within this application, of this Xholon instance.
 IXholon getPort(int portNum)
          Get the port that corresponds to this index (0 indexed).
 IPortInterface getProvidedInterface()
          Get the provided interface of this port.
 IPortInterface getRequiredInterface()
          Get the required interface of this port.
 boolean isBound(IXholon port)
          Is this port bound to anything? If a port is bound, then it will be possible for the local IXholon to send a message to, or get/set a val on, a remote IXholon.
 void postConfigure()
          Perform some action, typically once at start up; MAY be overridden.
 void sendMessage(int signal, java.lang.Object data, IXholon sender)
          Send a ROOM/UML2 message to a receiving Xholon instance.
 void sendMessage(int signal, java.lang.Object data, IXholon sender, int index)
          Send a ROOM/UML2 message through a local instance of a replicated port to a remote replicated port instance or directly to a remote xholon, or from a remote port replication to its owning xholon.
 void setIsConjugated(boolean isConjugated)
          Set whether or not this is a conjugated port.
 boolean setLink(int index, IXholon context, java.lang.String xpathExpressionIn)
          Set the link from a local port replication to a remote port or xholon.
 boolean setLink(int index, IXholon context, java.lang.String xpathExprTemplate, int xholonIx, int portIx, int replicationIx)
          Set the link from a local port replication to a remote port or xholon.
 void setProvidedInterface(IPortInterface providedInterface)
          Set the provided interface of this port.
 void setReplications(int multiplicity)
          Set the replication factor of a remote port, and create the remote port.
 void setRequiredInterface(IPortInterface requiredInterface)
          Set the required interface of this port.
 java.lang.String toString()
           
 
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, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, 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, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, 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, 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, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, 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, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, 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

replication

public IXholon[] replication
Replications of this port. ref to remote port(s), or to remote xholon(s) using its nextSibling as the actual ref

Constructor Detail

Port

public Port()
Method Detail

setProvidedInterface

public void setProvidedInterface(IPortInterface providedInterface)
Description copied from interface: IPort
Set the provided interface of this port. These are the behavioral features that the owning xholon provides to its environment through this port. In practical terms, on a non-conjugated port, these are the signals that are allowed in incoming messages received at this port. On a conjugated port, these are the signals that are allowed in outoing messages.

Specified by:
setProvidedInterface in interface IPort
Parameters:
providedInterface - An array of zero or more signal IDs.

getProvidedInterface

public IPortInterface getProvidedInterface()
Description copied from interface: IPort
Get the provided interface of this port. These are the behavioral features that the owning xholon provides to its environment through this port. In practical terms, on a non-conjugated port, these are the signals that are allowed in incoming messages received at this port. On a conjugated port, these are the signals that are allowed in outoing messages.

Specified by:
getProvidedInterface in interface IPort
Returns:
An array of zero or more signal IDs.

setRequiredInterface

public void setRequiredInterface(IPortInterface requiredInterface)
Description copied from interface: IPort
Set the required interface of this port. These are the services that the owning xholon expects from its environment through this port. In practical terms, on a non-conjugated port, these are the signals that are allowed in outgoing messages sent from this port. On a conjugated port, these are the signals that are allowed in incoming messages.

Specified by:
setRequiredInterface in interface IPort
Parameters:
requiredInterface - An array of zero or more signal IDs.

getRequiredInterface

public IPortInterface getRequiredInterface()
Description copied from interface: IPort
Get the required interface of this port. These are the services that the owning xholon expects from its environment through this port. In practical terms, on a non-conjugated port, these are the signals that are allowed in outgoing messages sent from this port. On a conjugated port, these are the signals that are allowed in incoming messages.

Specified by:
getRequiredInterface in interface IPort
Returns:
An array of zero or more signal IDs.

setIsConjugated

public void setIsConjugated(boolean isConjugated)
Description copied from interface: IPort
Set whether or not this is a conjugated port. In a non-conjugated port, the provided and required interfaces are as set. In a conjugated port, they are reversed.

Specified by:
setIsConjugated in interface IPort
Parameters:
isConjugated - true (conjugated) or false (non-conjugated). default: false

getIsConjugated

public boolean getIsConjugated()
Description copied from interface: IPort
Get whether or not this is a conjugated port.

Specified by:
getIsConjugated in interface IPort
Returns:
true (conjugated) or false (non-conjugated).

postConfigure

public void postConfigure()
Description copied from interface: IXholon
Perform some action, typically once at start up; MAY be overridden. Recursive; application should call this only for root.

Specified by:
postConfigure in interface IXholon
Overrides:
postConfigure in class Xholon

getName

public java.lang.String getName()
Description copied from interface: IXholon
Get name, unique within this application, of this Xholon instance. The name is a concatenation of the IXholonClass name and the Xholon unique ID. The first letter is converted to lowercase, and a "_" is used to separate the name and ID. ex: "helloWorld_123"

Specified by:
getName in interface IXholon
Overrides:
getName in class Xholon

createPort

public static IPort createPort(IXholon portOwner,
                               int multiplicity,
                               int[] provIfSigs,
                               java.lang.String[] provIfNames,
                               int[] reqIfSigs,
                               java.lang.String[] reqIfNames,
                               boolean isConjugated)
Create an instance of the Port class.

Parameters:
portOwner - The xholon that owns this port.
multiplicity - The number of replications of the port to create.
provIfSigs - Provided interface signal IDs.
provIfNames - Provided interface signal names.
reqIfSigs - Required interface signal IDs.
reqIfNames - Required interface signal names.
isConjugated - Whether or not the port instance is conjugated.
Returns:
A newly created instance of Port.

setReplications

public void setReplications(int multiplicity)
Description copied from interface: IPort
Set the replication factor of a remote port, and create the remote port.

Specified by:
setReplications in interface IPort
Parameters:
multiplicity - The maximum number of instances of the remote port.

setLink

public boolean setLink(int index,
                       IXholon context,
                       java.lang.String xpathExprTemplate,
                       int xholonIx,
                       int portIx,
                       int replicationIx)
Description copied from interface: IPort
Set the link from a local port replication to a remote port or xholon.

Specified by:
setLink in interface IPort
Parameters:
index - Index of the local replicated port on which the link is to be set.
context - The xholon that owns the port and port replication.
xpathExprTemplate - XPath expression template.
xholonIx - Remote xholon index, used to fill in a value in the template. If there is no index, then the value must be XPATH_EXPR_NO_INDEX.
portIx - Remote port index, used to fill in a value in the template. If there is no index, then the value must be XPATH_EXPR_NO_INDEX.
replicationIx - Remote replication index, used to fill in a value in the template. If there is no index, then the value must be XPATH_EXPR_NO_INDEX.

setLink

public boolean setLink(int index,
                       IXholon context,
                       java.lang.String xpathExpressionIn)
Description copied from interface: IPort
Set the link from a local port replication to a remote port or xholon. Only a client can set up a link, which must be a link to a server. A client is a port specified in UML as isService=false, and in Xholon as isConjugated=true. A server is a port specified in UML as isService=true, and in Xholon as isConjugated=false. A link will consist of two one-directional connections if both ends can legally send signals. The provided and required interfaces are specified in terms of the server. If a server has one or more signals specified for its provided interface, then a connection will be established from its client(s) to the server. If a server has one or more signals specified for its required interface, then a connection will be established from the server to its client(s). TODO How to handle a symmetrical link where provided and required IF are equal.

Specified by:
setLink in interface IPort
Parameters:
index - Index of the local replicated port on which the link is to be set.
context - The xholon that owns the port and port replication.
xpathExpressionIn - Complete XPath expression.
Returns:
false (remote port or xholon can't be found) or true (can be found)

getLink

public IXholon getLink(int index)
Description copied from interface: IPort
Get the link from a local port replication to a remote port or xholon. Hide the internal details of how this is done. Currently the nextSibling is being used internally to store the link, but this may change.

Specified by:
getLink in interface IPort
Parameters:
index - Index of the local replicated port.
Returns:
The remote port or xholon, or null if there is none.

getPort

public IXholon getPort(int portNum)
Description copied from interface: IXholon
Get the port that corresponds to this index (0 indexed).

Specified by:
getPort in interface IXholon
Overrides:
getPort in class Xholon

isBound

public boolean isBound(IXholon port)
Description copied from interface: IXholon
Is this port bound to anything? If a port is bound, then it will be possible for the local IXholon to send a message to, or get/set a val on, a remote IXholon.

If the port is intended to be a direct reference to another IXholon, then isBound() will return true if the port actually references a concrete IXholon, and will return false if the port value is null.

If the port is intended to be an IPort, then isBound() will return true if there is an end-to-end connection to a remote IXholon, and will return false if the port value is null or if it does not connect all the way through to a remote IXholon.

Specified by:
isBound in interface IXholon
Overrides:
isBound in class Xholon

sendMessage

public void sendMessage(int signal,
                        java.lang.Object data,
                        IXholon sender)
Description copied from interface: IXholon
Send a ROOM/UML2 message to a receiving Xholon instance.

Specified by:
sendMessage in interface IXholon
Overrides:
sendMessage in class Xholon

sendMessage

public void sendMessage(int signal,
                        java.lang.Object data,
                        IXholon sender,
                        int index)
Description copied from interface: IPort
Send a ROOM/UML2 message through a local instance of a replicated port to a remote replicated port instance or directly to a remote xholon, or from a remote port replication to its owning xholon.

Specified by:
sendMessage in interface IPort
Overrides:
sendMessage in class Xholon

toString

public java.lang.String toString()
Overrides:
toString in class Xholon