All Packages Class Hierarchy This Package Previous Next Index
Class uhr.core.msg.MessageRouterStd
java.lang.Object
|
+----uhr.core.msg.MessageRouterStd
- public class MessageRouterStd
- extends Object
- implements MessageRouter
This routes Messages from senders to receivers, handles
connections and provides related services such as for tools
needing to know things about circuits. Messages are multicast
events used for part Anonymous Collaboration.
See full documentation. This
is NOT a thread safe implementation.
IMPLEMENTATION STATUS - Monitor not yet implemented. Service
message signals and interests not published. Tool methods are
undesigned and unimplemented.
-
MessageRouterStd()
-
-
connect(Connection)
- This creates a connection.
-
disconnect(Connection)
- This disconnects a connection previously made with
connect(Connection).
-
enumerateMessageNames()
- Returns all the message names currently connected.
-
enumerateMessageNamesWithReceiver(MessageReceiver)
- Returns all message names the receiver is connected to.
-
enumerateMessageReceivers(String)
- Returns all receivers for the messageName.
-
getParentRouter()
- Returns the parent router or null if this is the root router.
-
receive(Message)
- The router receives the message and routes it to its connected
receivers (InterestOut), or in some cases handles the
message itself.
-
replicate()
- Returns a copy of itself without mission state.
-
sendMessage(Message,
MessageSender, String)
- Sends the message from the sender on to its destinations.
-
serviceMessage(Message,
MessageSender)
- Allows a router to handle a "service message".
-
setMessageReceiver(MessageReceiver)
- Sets the receiver to use when sending messages, which for routers
is the parent router.
-
setParentRouter(MessageRouter)
- Sets the MessageRouter in the parent cell of this router.
MessageRouterStd
public MessageRouterStd()
connect
public void connect(Connection connection)
- This creates a connection.
- Parameters:
- connection - the connection to connect.
disconnect
public Connection disconnect(Connection connection)
- This disconnects a connection previously made with
connect(Connection).
- Parameters:
- connection - the connection to disconnect.
- Returns:
- the connection removed or null if none.
sendMessage
public void sendMessage(Message message,
MessageSender sender,
String senderName)
- Sends the message from the sender on to its destinations. See method
documentation.
- Parameters:
- message - the message to send.
- sender - the original sender of the message.
- senderName - the name of the sender part.
serviceMessage
public void serviceMessage(Message message,
MessageSender sender)
- Allows a router to handle a "service message". See the algorithm
in
sendMessage(...)
- Parameters:
- message - the message to send.
- sender - the original sender of the message.
setParentRouter
public void setParentRouter(MessageRouter parentRouter)
- Sets the MessageRouter in the parent cell of this router.
- Parameters:
- parentRouter - the parent router.
getParentRouter
public MessageRouter getParentRouter()
- Returns the parent router or null if this is the root router.
- Returns:
- the parent router.
enumerateMessageNames
public Enumeration enumerateMessageNames()
- Returns all the message names currently connected.
- Returns:
- an enumeration message names.
enumerateMessageReceivers
public Enumeration enumerateMessageReceivers(String messageName)
- Returns all receivers for the messageName.
- Returns:
- an enumeration of MessageReceivers.
enumerateMessageNamesWithReceiver
public Enumeration enumerateMessageNamesWithReceiver(MessageReceiver receiver)
- Returns all message names the receiver is connected to.
- Returns:
- an enumeration of message names.
receive
public void receive(Message message)
- The router receives the message and routes it to its connected
receivers (InterestOut), or in some cases handles the
message itself. The Messages handled by the router itself are:
Message Name - TurnRouterMonitoringOn
Message Name - TurnRouterMonitoringOff
Message Name - GetRouterMonitoringState
State = true or false
The initial monitoring state is false, aka turned off. Now, a
few words about the monitoring feature:
We offer support for animation of live systems and other things
via message monitoring. Turning monitoring on will cause the
router to begin being a MessageSender for Messages sent when
various things happen in the router. Currently these are before
and after a message is sent to a receiver, excluding the
monitor messages. We call the receiver of monitoring messages a
"monitor".
For example, to visually show the travel of messages in a System
Tree, the monitor could highlight the sender node when before
notification is received, sleep, then paint a line to the
receiving node when the after notification is received.
Note that monitoring will slow message transmission down, so
usually it's turned off.
- Parameters:
- message - the message to route.
setMessageReceiver
public void setMessageReceiver(MessageReceiver receiver)
- Sets the receiver to use when sending messages, which for routers
is the parent router. This allows a router to behave like any
other part. The Messages sent by the router itself are:
If monitoring is turned on these messages are sent:
Message Name - "MonitorBeforeReceive"
"Message" - The Message transmitted.
"MessageSender" - The source of the message.
"MessageReceiver" - The destination of the message.
"ConnectionType" - "Out" or "In".
//
Message Name - "MonitorAfterReceive"
(same properties)
We expect the monitor to be a message service, allowing a single
part to monitor an entire system. To start monitoring, the
monitor (or another part, or even a possessor of the root node)
would walk the System Tree, get each MessageRouter, and send it
the "TurnRouterMonitoringOn" message.
- Parameters:
- receiver - the MessageReceiver to use when sending Messages.
replicate
public Object replicate()
- Returns a copy of itself without mission state.
- Returns:
- the replication.
All Packages Class Hierarchy This Package Previous Next Index