org.ocd.msgbus
Class MessageBus

java.lang.Object
  |
  +--org.ocd.msgbus.MessageBus
All Implemented Interfaces:
IMessageBus

public final class MessageBus
extends java.lang.Object
implements IMessageBus


Fields inherited from interface org.ocd.msgbus.IMessageBus
TOPIC_SEP
 
Constructor Summary
MessageBus()
           
 
Method Summary
 void addListener(java.lang.String topic, IMsgBusListener listener)
          The Listeners are added in a Soft Reference so that they can come and go with out references being kept on them.
 void fireMessage(java.lang.String topic, MsgBusMessage msg)
          Fire a message onto the bus for the given Topic.
 MsgBusMessage fireMessage(java.lang.String topic, MsgBusMessage msg, boolean resultRequired)
          Fire a message onto the bus.
 MsgBusMessage fireMessage(java.lang.String topic, MsgBusMessage msg, boolean resultRequired, boolean unicast)
          Fire a message onto the bus.
 void fireMessage(java.lang.String topic, MsgBusMessage msg, IMsgBusListener resultListener)
          Fire a message onto the bus for the given Topic.
static IMessageBus getDefaultBus()
          Get the Default Message Bus
 void removeListener(java.lang.String topic, IMsgBusListener listener)
          Remove a Listener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBus

public MessageBus()
Method Detail

getDefaultBus

public static IMessageBus getDefaultBus()
Get the Default Message Bus

removeListener

public void removeListener(java.lang.String topic,
                           IMsgBusListener listener)
Remove a Listener
Specified by:
removeListener in interface IMessageBus

addListener

public void addListener(java.lang.String topic,
                        IMsgBusListener listener)
The Listeners are added in a Soft Reference so that they can come and go with out references being kept on them. This allows the objects to be garbage collected
Specified by:
addListener in interface IMessageBus
Following copied from interface: org.ocd.msgbus.IMessageBus
Parameters:
topic - name of topic
listener -  

fireMessage

public void fireMessage(java.lang.String topic,
                        MsgBusMessage msg)
Fire a message onto the bus for the given Topic.
Specified by:
fireMessage in interface IMessageBus
Parameters:
topic - topic to pass the message on
pMsg - message to pass

fireMessage

public void fireMessage(java.lang.String topic,
                        MsgBusMessage msg,
                        IMsgBusListener resultListener)
Fire a message onto the bus for the given Topic.
Specified by:
fireMessage in interface IMessageBus
Parameters:
topic - to pass the message on
message - to pass
pResultListener - listeners to return a result to

fireMessage

public MsgBusMessage fireMessage(java.lang.String topic,
                                 MsgBusMessage msg,
                                 boolean resultRequired)
Fire a message onto the bus. For the given Topic. This method does not use the MessageBus Processor and therefore it will block until all listeners have recieved the message. The Result from Each Listener is merged into one result and returned to this methods caller
Specified by:
fireMessage in interface IMessageBus
Parameters:
topic - to pass the message on
message - to pass
true - if a result should be returned from this method
Returns:
result of firing the message

fireMessage

public MsgBusMessage fireMessage(java.lang.String topic,
                                 MsgBusMessage msg,
                                 boolean resultRequired,
                                 boolean unicast)
Fire a message onto the bus. For the given Topic. This method does not use the MessageBus Processor and therefore it will block until all listeners have recieved the message. The Result from Each Listener is merged into one result and returned to this methods caller If pUnicast is set to true only the first Listener will receive the Message
Specified by:
fireMessage in interface IMessageBus
Parameters:
topic - to pass the message on
msg - to pass
pResultRequired - true if a result should be returned from this method
pUnicast - true if only first listener should receive the message
Returns:
result of firing the message