ist.palcom.routing.util
Class SimpleRoutingManager

java.lang.Object
  extended by ist.palcom.routing.AbstractRoutingManager2
      extended by ist.palcom.routing.util.SimpleRoutingManager
All Implemented Interfaces:
IHgraphNode, RoutingManager

public class SimpleRoutingManager
extends AbstractRoutingManager2

This class handles simple routing with multiple MediaManagers. The policy is to choose the first found manager that has the device registered.


Nested Class Summary
 
Nested classes/interfaces inherited from class ist.palcom.routing.AbstractRoutingManager2
AbstractRoutingManager2.ChoppedMessageHandler
 
Field Summary
 
Fields inherited from class ist.palcom.routing.AbstractRoutingManager2
_node
 
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
SimpleRoutingManager(java.util.ArrayList mediaManagers, PalcomScheduler scheduler, java.lang.String mark)
           
 
Method Summary
 void addErrorHandler(PalcomThread handler)
          Subscribe to error events from all media managers.
 void addMediaManager(MediaManager manager)
          Add another mediamanager and start to listen for events from it.
 URL[] getDefaultGroupAddresses()
          Deprecated.  
 java.lang.String getLocalDeviceCache()
          Returns the device cache for the first found media manager.
 void registerAsListener(PalcomThread communicationManager)
          Registers as a listener to messages received by this manager from the network.
 void registerForHeartBeats(PalcomThread resourceManager)
          Register as a listener for heartBeatEvents.
 boolean removeMediaManager(MediaManager manager)
          Remove a mediamanager.
 boolean send(Message message, java.lang.String receiverDeviceID)
          Send a message to a specified deviceID.
 boolean send(Message msg, URN urn1, Selector selector1, URN urn2, Selector selector2)
          Deprecated.  
 void sendBroadcast(Message message)
          Send a message to all devices.
 void sendHeartAttack()
          Send a message saying that the device will close down
 void sendHeartBeat(boolean isHeartBeatAck)
          Send a heartbeat message to all devices saying that this device is still active.
 void setDiscoverySelector(Selector selector)
          Set the discovery selector in all media managers for this device.
 void setLocalDeviceCache(java.lang.String localDeviceCache)
          Set the device cache information in all media managers for this device.
 void setLocalDeviceID(java.lang.String localDeviceID)
          Set the device ID in all media managers for this device.
 void setLocalDiscoveryVersion(java.lang.String discoveryVersion)
          Set the discovery version in all media managers for this device.
 void setLocalStatusFlag(byte statusFlag)
          Set the status flag in all media managers for this device.
 void setLocalStatusFlag(int statusFlag)
           
 URL startReceiving(PalcomThread receiver)
          Deprecated.  
 URL startReceiving(URL url, PalcomThread receiver)
          Deprecated.  
 Selector startReceiving2(PalcomThread receiver)
          Deprecated.  
 void stop()
          Stop all MediaManagers and the internal thread.
 void stopReceiving(PalcomThread receiver)
          Deprecated.  
 void stopReceiving(Selector selector)
          Deprecated.  
 void stopReceiving(URL url)
          Deprecated.  
 void stopReceiving(URL url, PalcomThread receiver)
          Deprecated.  
 void unregisterDevice(java.lang.String deviceID)
          Remove the device with ID deviceID from the list of registered devices.
 
Methods inherited from class ist.palcom.routing.AbstractRoutingManager2
addNodeChild, adjustMessageRawData, getChildIterator, getChoppedMessageHandler, getFuncFunc, getNodeName, getNodeParent, getPath, getSiblingFunc, getValueFunc, hasChildNamed, isAncestorOf, removeNodeChild, sendGroupJoinMessage, sendGroupLeaveMessage, setNodeName, setNodeParent, toXML, toXMLFull, toXMLFullRecursively, toXMLRecursively, updatePath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleRoutingManager

public SimpleRoutingManager(java.util.ArrayList mediaManagers,
                            PalcomScheduler scheduler,
                            java.lang.String mark)
Method Detail

stop

public void stop()
Stop all MediaManagers and the internal thread.

Specified by:
stop in interface RoutingManager
Overrides:
stop in class AbstractRoutingManager2

addErrorHandler

public void addErrorHandler(PalcomThread handler)
Subscribe to error events from all media managers. Unhandled errors within the MediaManagers will be send to the handler in the form of MALErrorEvent events. Notice: Currently, only one error handler at a time is supported

Specified by:
addErrorHandler in interface RoutingManager
Specified by:
addErrorHandler in class AbstractRoutingManager2

addMediaManager

public void addMediaManager(MediaManager manager)
Add another mediamanager and start to listen for events from it.


removeMediaManager

public boolean removeMediaManager(MediaManager manager)
Remove a mediamanager.

Returns:
true if the remove was successful

setLocalDeviceCache

public void setLocalDeviceCache(java.lang.String localDeviceCache)
Set the device cache information in all media managers for this device.

Specified by:
setLocalDeviceCache in interface RoutingManager
Specified by:
setLocalDeviceCache in class AbstractRoutingManager2

getLocalDeviceCache

public java.lang.String getLocalDeviceCache()
Returns the device cache for the first found media manager. This works since they all have the same information in their device cache.

Specified by:
getLocalDeviceCache in interface RoutingManager
Specified by:
getLocalDeviceCache in class AbstractRoutingManager2

setLocalDeviceID

public void setLocalDeviceID(java.lang.String localDeviceID)
Set the device ID in all media managers for this device.

Specified by:
setLocalDeviceID in interface RoutingManager
Specified by:
setLocalDeviceID in class AbstractRoutingManager2

setLocalStatusFlag

public void setLocalStatusFlag(byte statusFlag)
Set the status flag in all media managers for this device.

Specified by:
setLocalStatusFlag in interface RoutingManager
Specified by:
setLocalStatusFlag in class AbstractRoutingManager2

setLocalStatusFlag

public void setLocalStatusFlag(int statusFlag)

setLocalDiscoveryVersion

public void setLocalDiscoveryVersion(java.lang.String discoveryVersion)
Set the discovery version in all media managers for this device.

Specified by:
setLocalDiscoveryVersion in interface RoutingManager
Specified by:
setLocalDiscoveryVersion in class AbstractRoutingManager2

setDiscoverySelector

public void setDiscoverySelector(Selector selector)
Set the discovery selector in all media managers for this device.

Specified by:
setDiscoverySelector in interface RoutingManager
Specified by:
setDiscoverySelector in class AbstractRoutingManager2

send

public boolean send(Message message,
                    java.lang.String receiverDeviceID)
Send a message to a specified deviceID.

Specified by:
send in interface RoutingManager
Specified by:
send in class AbstractRoutingManager2

sendBroadcast

public void sendBroadcast(Message message)
Send a message to all devices.

Specified by:
sendBroadcast in interface RoutingManager
Specified by:
sendBroadcast in class AbstractRoutingManager2

sendHeartAttack

public void sendHeartAttack()
Send a message saying that the device will close down

Specified by:
sendHeartAttack in interface RoutingManager
Specified by:
sendHeartAttack in class AbstractRoutingManager2

registerForHeartBeats

public void registerForHeartBeats(PalcomThread resourceManager)
Register as a listener for heartBeatEvents. This method is used by test programs and the ResourceManager. Currently only one listener at a time is supported.

Specified by:
registerForHeartBeats in interface RoutingManager
Specified by:
registerForHeartBeats in class AbstractRoutingManager2

sendHeartBeat

public void sendHeartBeat(boolean isHeartBeatAck)
Send a heartbeat message to all devices saying that this device is still active.

Specified by:
sendHeartBeat in interface RoutingManager
Specified by:
sendHeartBeat in class AbstractRoutingManager2

unregisterDevice

public void unregisterDevice(java.lang.String deviceID)
Remove the device with ID deviceID from the list of registered devices.

Specified by:
unregisterDevice in interface RoutingManager
Overrides:
unregisterDevice in class AbstractRoutingManager2

registerAsListener

public void registerAsListener(PalcomThread communicationManager)
Registers as a listener to messages received by this manager from the network. Currently only one listener at a time is supported.

Specified by:
registerAsListener in interface RoutingManager
Specified by:
registerAsListener in class AbstractRoutingManager2
Parameters:
communicationManager - The DistributorThread used in CommunicationManager

getDefaultGroupAddresses

public URL[] getDefaultGroupAddresses()
Deprecated. 


stopReceiving

public void stopReceiving(URL url,
                          PalcomThread receiver)
Deprecated. 


startReceiving

public URL startReceiving(URL url,
                          PalcomThread receiver)
Deprecated. 


stopReceiving

public void stopReceiving(PalcomThread receiver)
Deprecated. 

Specified by:
stopReceiving in interface RoutingManager
Specified by:
stopReceiving in class AbstractRoutingManager2

startReceiving

public URL startReceiving(PalcomThread receiver)
Deprecated. 


startReceiving2

public Selector startReceiving2(PalcomThread receiver)
Deprecated. 


stopReceiving

public void stopReceiving(Selector selector)
Deprecated. 

Specified by:
stopReceiving in interface RoutingManager
Specified by:
stopReceiving in class AbstractRoutingManager2

stopReceiving

public void stopReceiving(URL url)
Deprecated. 


send

public boolean send(Message msg,
                    URN urn1,
                    Selector selector1,
                    URN urn2,
                    Selector selector2)
Deprecated. 

Specified by:
send in interface RoutingManager
Specified by:
send in class AbstractRoutingManager2