ist.palcom.discovery
Class DiscoveryManager

java.lang.Object
  extended by ist.palcom.discovery.DiscoveryManager
All Implemented Interfaces:
IHgraphNode

public class DiscoveryManager
extends java.lang.Object
implements IHgraphNode


Field Summary
protected  HgraphNode _node
           
static java.lang.String DISCOVERY_VERSION
           
static java.lang.String TOPIC
          The pub/sub topic to use for discovery.
 
Fields inherited from interface ist.palcom.hgraph.IHgraphNode
CHILD_NAME_CLASH, CIRCULARITY_CLASH, COMMAND_OR_NODE_MISSING, ERROR, HANDLER_MISSING, INVOKATOR_MISSING, LISTENER_MISSING, NODE_NOT_CHILD, PATH_MISSING, SIBLING_ALREADY_EXISTS, SIBLING_NONEXISTENT, SIBLING_REFERENCE_ALREADY_EXISTS, SIBLING_REFERENCE_NONEXISTENT, STATUS_OK, VALUE_ALREADY_EXISTS, VALUE_NOT_PRESENT
 
Constructor Summary
DiscoveryManager(PalcomScheduler scheduler, PointToPointManager pointToPointManager, CommunicationManager communicationManager, PRDDevice localDeviceInfo)
          Create a DiscoveryManager. localDeviceinfo is the info about the local device.
 
Method Summary
 int addNodeChild(IHgraphNode node, Path callerPath)
          Adds a child to the node's private list of children.
 java.util.Iterator getChildIterator()
           
 FuncFunc getFuncFunc()
           
 java.lang.String getNodeName()
          hgraph impl below
 IHgraphNode getNodeParent()
           
 Path getPath()
           
 SiblingFunc getSiblingFunc()
           
 ValueFunc getValueFunc()
           
 boolean hasChildNamed(java.lang.String name)
          Checks whether the node has a child with a given name
 boolean isAncestorOf(IHgraphNode node)
          Checks whether this node is an ancestor of the parameter node.
 void removeLocalConnectionInfo(PRDConnection ci)
          Remove a local ConnectionInfo from the DiscoveryManager.
 void removeLocalSelector(LocalSID localSID)
          Remove a local Selector for Service with ID localSID from the DiscoveryManager.
 void removeLocalServiceDescription(PRDServiceFMDescription sd)
          Remove a local ServiceDescription from the DiscoveryManager.
 void removeLocalServiceInstanceID(LocalSID localSID)
          Remove a local ServiceInstanceID for Service with ID localSID from the DiscoveryManager.
 void removeLocalServiceList(PRDServiceList list)
          Remove a local ServiceList from the DiscoveryManager.
 boolean removeLocalServiceOrSubList(PRDServiceListItem listItem)
          Remove a local Service or SubList from the service list in the DiscoveryManager.
 void removeLocalSID(ServiceInstanceID serviceInstanceID)
          Remove a LocalSID for Service with ID ServiceInstanceID from the DiscoveryManager.
 int removeNodeChild(java.lang.String name, Path callerPath)
          Removes a child based on its name.
 void removeServiceStatus(LocalSID localSID)
          Remove the status info for Service with ID localSID from the DiscoveryManager.
 int setNodeName(java.lang.String name, Path callerPath)
          Sets the name of the node.
 int setNodeParent(IHgraphNode newParent, Path callerPath)
          Sets the parent of the HgraphNode.
 void start()
          Start the DiscoveryManager.
 void stop()
          Stop the DiscoveryManager.
 java.lang.String toXML()
           
 java.lang.String toXMLFull()
           
 java.lang.String toXMLFullRecursively()
           
 java.lang.String toXMLRecursively()
           
 void updateLocalConnectionInfo(PRDConnection ci)
          Add a local ConnectionInfo to the DiscoveryManager.
 void updateLocalSelector(LocalSID localSID, Selector selector)
          Add or change a local Selector to the DiscoveryManager.
 void updateLocalServiceDescription(PRDServiceFMDescription sd)
          Add a local ServiceDescription to the DiscoveryManager.
 void updateLocalServiceInstanceID(LocalSID localSID, ServiceInstanceID serviceInstanceID)
          Add or change a local ServiceInstanceID to the DiscoveryManager.
 void updateLocalServiceList(PRDServiceList list)
          Add a local ServiceList to the DiscoveryManager.
 void updateLocalSID(ServiceInstanceID serviceInstanceID, LocalSID localSID)
          Add or change a LocalSID to the DiscoveryManager.
 void updatePath()
          Updates the path of the H-Graph node along with its offspring recursively.
 void updateServiceStatus(LocalSID localSID, byte status, java.lang.String helpText)
          Add or change the status of a service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_node

protected HgraphNode _node

TOPIC

public static final java.lang.String TOPIC
The pub/sub topic to use for discovery.

See Also:
Constant Field Values

DISCOVERY_VERSION

public static final java.lang.String DISCOVERY_VERSION
See Also:
Constant Field Values
Constructor Detail

DiscoveryManager

public DiscoveryManager(PalcomScheduler scheduler,
                        PointToPointManager pointToPointManager,
                        CommunicationManager communicationManager,
                        PRDDevice localDeviceInfo)
Create a DiscoveryManager. localDeviceinfo is the info about the local device.

Method Detail

start

public void start()
Start the DiscoveryManager. Listening for remote info requests will begin, and an initial announcement about this device will be sent out (the DeviceInfo sent out in an InfoEvent with keepinfo=true).

The PubSubManager that was passed to the constructor must be started before this call.


stop

public void stop()
Stop the DiscoveryManager. A HeartAttack message will be sent out, so other devices can remove information about this device.

The PubSubManager that was passed to the constructor will not be stopped.


updateLocalServiceList

public void updateLocalServiceList(PRDServiceList list)
Add a local ServiceList to the DiscoveryManager. The list will be sent out in response to future requests from other devices.


removeLocalServiceList

public void removeLocalServiceList(PRDServiceList list)
Remove a local ServiceList from the DiscoveryManager. The ServiceList will no longer be sent out in response to requests.


removeLocalServiceOrSubList

public boolean removeLocalServiceOrSubList(PRDServiceListItem listItem)
Remove a local Service or SubList from the service list in the DiscoveryManager. The item will no longer be sent out in response to requests.


updateLocalServiceDescription

public void updateLocalServiceDescription(PRDServiceFMDescription sd)
Add a local ServiceDescription to the DiscoveryManager. The ServiceDescription will be sent out in response to future requests from other devices.


removeLocalServiceDescription

public void removeLocalServiceDescription(PRDServiceFMDescription sd)
Remove a local ServiceDescription from the DiscoveryManager. The ServiceDescription will no longer be sent out in response to requests.


updateLocalConnectionInfo

public void updateLocalConnectionInfo(PRDConnection ci)
Add a local ConnectionInfo to the DiscoveryManager. The list will be sent out in response to future requests from other devices.


removeLocalConnectionInfo

public void removeLocalConnectionInfo(PRDConnection ci)
Remove a local ConnectionInfo from the DiscoveryManager. The ConnectionInfo will no longer be sent out in response to requests.


updateLocalSelector

public void updateLocalSelector(LocalSID localSID,
                                Selector selector)
Add or change a local Selector to the DiscoveryManager. The Selector will be sent out in response to future requests from other devices.


removeLocalSelector

public void removeLocalSelector(LocalSID localSID)
Remove a local Selector for Service with ID localSID from the DiscoveryManager. The Selector will no longer be sent out in response to requests.


updateLocalServiceInstanceID

public void updateLocalServiceInstanceID(LocalSID localSID,
                                         ServiceInstanceID serviceInstanceID)
Add or change a local ServiceInstanceID to the DiscoveryManager. The ServiceInstanceID will be sent out in response to future requests from other devices.


removeLocalServiceInstanceID

public void removeLocalServiceInstanceID(LocalSID localSID)
Remove a local ServiceInstanceID for Service with ID localSID from the DiscoveryManager. The ServiceInstanceID will no longer be sent out in response to requests.


updateLocalSID

public void updateLocalSID(ServiceInstanceID serviceInstanceID,
                           LocalSID localSID)
Add or change a LocalSID to the DiscoveryManager. The LocalSID will be sent out in response to future requests from other devices.


removeLocalSID

public void removeLocalSID(ServiceInstanceID serviceInstanceID)
Remove a LocalSID for Service with ID ServiceInstanceID from the DiscoveryManager. The LocalSID will no longer be sent out in response to requests.


updateServiceStatus

public void updateServiceStatus(LocalSID localSID,
                                byte status,
                                java.lang.String helpText)
Add or change the status of a service. The status will be sent out in response to future requests from other devices.


removeServiceStatus

public void removeServiceStatus(LocalSID localSID)
Remove the status info for Service with ID localSID from the DiscoveryManager. The status will no longer be sent out in response to requests.


getNodeName

public java.lang.String getNodeName()
hgraph impl below

Specified by:
getNodeName in interface IHgraphNode
Returns:
The name of the node.

setNodeName

public int setNodeName(java.lang.String name,
                       Path callerPath)
Description copied from interface: IHgraphNode
Sets the name of the node. If a sibling already has the name, an error control message is returned

Specified by:
setNodeName in interface IHgraphNode
Parameters:
name - The new name
Returns:
IHgraphNode.STATUS_OK if the change succeeded. IHgraphNode.CHILD_NAME_CLASH if a sibling with the given name already exists.

getPath

public Path getPath()
Specified by:
getPath in interface IHgraphNode
Returns:
the Path object pertaining to the path of the node

updatePath

public void updatePath()
Description copied from interface: IHgraphNode
Updates the path of the H-Graph node along with its offspring recursively. The path is updated when the node name and the node parent is sat.

Specified by:
updatePath in interface IHgraphNode

hasChildNamed

public boolean hasChildNamed(java.lang.String name)
Description copied from interface: IHgraphNode
Checks whether the node has a child with a given name

Specified by:
hasChildNamed in interface IHgraphNode
Parameters:
name - The name to check
Returns:
True iff the node has an actual child with the given name. False if not.

isAncestorOf

public boolean isAncestorOf(IHgraphNode node)
Description copied from interface: IHgraphNode
Checks whether this node is an ancestor of the parameter node. It does so with a depth-first sharch of its offspring (children etc.)

Specified by:
isAncestorOf in interface IHgraphNode
Returns:
true if this node is an ancestor of the parameter node. false if not.

removeNodeChild

public int removeNodeChild(java.lang.String name,
                           Path callerPath)
Description copied from interface: IHgraphNode
Removes a child based on its name.

Specified by:
removeNodeChild in interface IHgraphNode
Parameters:
name - The name of the child to be removed
Returns:
IHgraphNode.STATUS_OK if the operation succeeds

toXML

public java.lang.String toXML()
Specified by:
toXML in interface IHgraphNode
Returns:
A simple xml'ified String of the node (type, name, path, children)

toXMLFull

public java.lang.String toXMLFull()
Specified by:
toXMLFull in interface IHgraphNode
Returns:
A complete xml'ified String of the node (same as simple + handlers, invokators, listeners, values)

toXMLRecursively

public java.lang.String toXMLRecursively()
Specified by:
toXMLRecursively in interface IHgraphNode
Returns:
A simple recursive xml'ified String of the node (type, name, path, children)

toXMLFullRecursively

public java.lang.String toXMLFullRecursively()
Specified by:
toXMLFullRecursively in interface IHgraphNode
Returns:
A complete recursive xml'ified String of the node (same as simple + handlers, invokators, listeners, values) HEAVY!!!

setNodeParent

public int setNodeParent(IHgraphNode newParent,
                         Path callerPath)
Description copied from interface: IHgraphNode
Sets the parent of the HgraphNode. This triggers a recalculation of the path of the node and its offspring

Specified by:
setNodeParent in interface IHgraphNode
Parameters:
newParent - the new parent
Returns:
IHgraphNode.STATUS_OK if the operation succeeds. IHgraphNode.CIRCULARITY_CLASH if the operation causes a circularity.

addNodeChild

public int addNodeChild(IHgraphNode node,
                        Path callerPath)
Description copied from interface: IHgraphNode
Adds a child to the node's private list of children. Ensures that names amongst children are unique

Specified by:
addNodeChild in interface IHgraphNode
Parameters:
node - The new child to be added
Returns:
IHgraphNode.STATUS_OK if the change succeeded. IHgraphNode.CHILD_NAME_CLASH if a sibling with the given name already exists.

getSiblingFunc

public SiblingFunc getSiblingFunc()
Specified by:
getSiblingFunc in interface IHgraphNode
Returns:
The SiblingFunc Sibling functionality object for the given node.

getValueFunc

public ValueFunc getValueFunc()
Specified by:
getValueFunc in interface IHgraphNode
Returns:
The ValueFunc Value functionality object for the given node.

getFuncFunc

public FuncFunc getFuncFunc()
Specified by:
getFuncFunc in interface IHgraphNode
Returns:
The FuncFunc functional functionality (ie. handlers, invokators and listeners) object for the given node.

getNodeParent

public IHgraphNode getNodeParent()
Specified by:
getNodeParent in interface IHgraphNode
Returns:
The parent of the node. null if the parent is root

getChildIterator

public java.util.Iterator getChildIterator()
Specified by:
getChildIterator in interface IHgraphNode
Returns:
An Iterator over the children of the node