public class MessageInformer
extends java.lang.Object
listeners for messages crossing the JMEDS framework. This
is especially useful for clients interested in receiving specific types of messages or for traffic analyzers willing
to get notified about each message sent or received.
When registering, a listener can declare its interest for certain messages by passing a MessageSelector to
the method addMessageListener(MessageListener, MessageSelector). The MessageSelector's MessageSelector.matches(Message) method is used to determine whether a given message matches this interest or not.
The JMEDS framework provides two standard implementations of MessageSelector: AllMessageSelector, which simply marks every message as interesting, and DefaultMessageSelector allowing
discrimination based on a message's type and/or its target endpoint address (i.e. the WS-Addressing [destination]
property of the message).
| Modifier and Type | Method and Description |
|---|---|
void |
addMessageListener(MessageListener listener,
MessageSelector sel)
Adds the specified message listener to this message informer.
|
void |
forwardMessage(Message msg,
ConnectionInfo connectionInfo,
AttributedURI optionalMessageId)
Forwards a single message to all registered listeners.
|
static MessageInformer |
getInstance()
Returns the singleton instance of this class.
|
MessageListener[] |
getMessageListeners()
Returns an array containing all currently registered message listeners.
|
void |
removeMessageListener(MessageListener listener)
Removes the specified message listener, if it was previously registered within this message informer.
|
void |
start()
Starts the message delivery loop of this message informer instance.
|
void |
stop()
Stops the message informer, i.e.
|
public static MessageInformer getInstance()
public void start()
public void stop()
public void addMessageListener(MessageListener listener, MessageSelector sel)
sel is
null, the listener will be registered with an AllMessageSelector associated to it and thus
will receive notifications about every message.listener - the listener to registersel - the selector determining which messages to deliver to the newly registered listenerpublic void removeMessageListener(MessageListener listener)
listener - the listener to removepublic MessageListener[] getMessageListeners()
public void forwardMessage(Message msg, ConnectionInfo connectionInfo, AttributedURI optionalMessageId)
msg - the message to forwardconnectionInfo - transport-specific addressing information attached to the message