public class MessageCenter
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
class |
MessageCenter.MessageCenterException
Generic class for all MessageCenter related exceptions
|
class |
MessageCenter.NullSourceException
Exception when an attempt is made to register a null source
|
class |
MessageCenter.NullTargetException
Exception when an attempt is made to register a null source
|
class |
MessageCenter.UnimplementedProtocolException
Exception when an attempt is made to register a target for a protocol not implemented by its class.
|
Modifier and Type | Field and Description |
---|---|
static int |
ASYNCHRONOUS
forward events from a new thread
|
static int |
FRESH
forward fresh events (drop old unprocessed pending events) on a common thread per protocol
|
static int |
SYNCHRONOUS
forward events on the invoking thread
|
Constructor and Description |
---|
MessageCenter()
Creates new MessageCenter
|
MessageCenter(int threadPoolSize)
Create a new MessageCenter with given thread pool size
|
MessageCenter(java.lang.String newName)
Create a new MessageCenter with given name
|
MessageCenter(java.lang.String newName,
int newThreadPoolSize)
Create a new MessageCenter with given name and thread pool size
|
Modifier and Type | Method and Description |
---|---|
static MessageCenter |
defaultCenter()
default message center instance
|
<T> T |
getProxy(java.lang.Object source,
java.lang.Class<T> protocol)
get the proxy for the specified source and protocol
|
java.lang.String |
name()
get the name of the MessageCenter instance
|
static MessageCenter |
newCenter()
Create a new MessageCenter
|
static MessageCenter |
newCenter(int newThreadPoolSize)
Create a new MessageCenter
|
static MessageCenter |
newCenter(java.lang.String newName)
Create a new MessageCenter
|
static MessageCenter |
newCenter(java.lang.String newName,
int newThreadPoolSize)
Create a new MessageCenter
|
<T> T |
registerSource(java.lang.Object source,
java.lang.Class<T> protocol)
register the specified source to be associated with the specified event protocol
defaults to synchronous messaging
|
<T> T |
registerSource(java.lang.Object source,
java.lang.Class<T> protocol,
boolean isSynchronous)
Deprecated.
Use the version of this method that takes the synchronous type instead
|
<T> T |
registerSource(java.lang.Object source,
java.lang.Class<T> protocol,
int synchronousType)
Register the specified source to be associated with the specified event protocol and processed as the synchronous type
|
<T> void |
registerTarget(T target,
java.lang.Class<T> protocol)
register target for messages from any source which posts to the interface
|
<T> void |
registerTarget(T target,
java.lang.Object source,
java.lang.Class<T> protocol)
register target for messages from the source and for the specified interface
|
<T> void |
removeSource(java.lang.Object source,
java.lang.Class<T> protocol)
Remove source registration which means the proxy for the source/protocol pair
is no longer able to broadcast messages.
|
<T> void |
removeTarget(T target,
java.lang.Class<T> protocol)
Removes the target from listening for the specified protocol.
|
<T> void |
removeTarget(T target,
java.util.Collection<? extends java.lang.Object> sources,
java.lang.Class<T> protocol)
Unregister the target from listening to the specified protocol from the specified collection
of sources.
|
<T> void |
removeTarget(T target,
java.lang.Object source,
java.lang.Class<T> protocol)
remove target from listening to specified source with specified protocol
|
<T> void |
removeTargetFromAllSources(T target,
java.lang.Class<T> protocol)
Remove the target from every source that broadcasts the specified protocol
|
java.lang.String |
toString()
Override toString() to return a description of the message center.
|
public static final int SYNCHRONOUS
public static final int ASYNCHRONOUS
public static final int FRESH
public MessageCenter()
public MessageCenter(java.lang.String newName)
newName
- The name of this Message Center.public MessageCenter(int threadPoolSize)
threadPoolSize
- The thread pool size of this message centerpublic MessageCenter(java.lang.String newName, int newThreadPoolSize)
newName
- The name of this message centernewThreadPoolSize
- The thread pool size of this message centerpublic static MessageCenter defaultCenter()
public static MessageCenter newCenter()
public static MessageCenter newCenter(java.lang.String newName)
newName
- the name to assign this message centerpublic static MessageCenter newCenter(int newThreadPoolSize)
newThreadPoolSize
- The thread pool size of this message centerpublic static MessageCenter newCenter(java.lang.String newName, int newThreadPoolSize)
newName
- The name of this message centernewThreadPoolSize
- The thread pool size of this message centerpublic <T> void registerTarget(T target, java.lang.Object source, java.lang.Class<T> protocol)
target
- The target to receive messagessource
- The source from which we wish to receive messagesprotocol
- The protocol identifying the message type to receivepublic <T> void registerTarget(T target, java.lang.Class<T> protocol)
target
- The target to receive messagesprotocol
- The protocol identifying the message type to receivepublic <T> void removeTarget(T target, java.lang.Object source, java.lang.Class<T> protocol)
target
- The target receiving messagessource
- The source from which we are receiving messagesprotocol
- The protocol identifying the message type being receivedpublic <T> void removeTargetFromAllSources(T target, java.lang.Class<T> protocol)
target
- The target receiving messagesprotocol
- The protocol identifying the message type being receivedpublic <T> void removeTarget(T target, java.util.Collection<? extends java.lang.Object> sources, java.lang.Class<T> protocol)
target
- The target receiving messagessources
- The sources from which we are receiving messagesprotocol
- The protocol identifying the message type being receivedpublic <T> void removeTarget(T target, java.lang.Class<T> protocol)
target
- The target receiving messagesprotocol
- The protocol identifying the message type being receivedpublic <T> T registerSource(java.lang.Object source, java.lang.Class<T> protocol)
source
- The source of the messageprotocol
- The type and interface of the messages the source will send@Deprecated public <T> T registerSource(java.lang.Object source, java.lang.Class<T> protocol, boolean isSynchronous)
source
- The source of the messageprotocol
- The type and interface of the messages the source will sendisSynchronous
- true to enable synchronous messaging and false for asynchronous messagingpublic <T> T registerSource(java.lang.Object source, java.lang.Class<T> protocol, int synchronousType)
source
- The source of the messageprotocol
- The type and interface of the messages the source will sendsynchronousType
- one of SYNCHRONOUS, ASYNCHRONOUS or FRESH to indicate how events are processedpublic <T> void removeSource(java.lang.Object source, java.lang.Class<T> protocol)
source
- The source of messagesprotocol
- The interface/type of messagespublic <T> T getProxy(java.lang.Object source, java.lang.Class<T> protocol)
source
- The source on behalf of which messages will be broadcastprotocol
- The interface/type of message implemented by the proxypublic java.lang.String name()
public java.lang.String toString()
toString
in class java.lang.Object