public abstract class AbstractMessageDelegator<S extends MessageConnection> extends java.lang.Object implements MessageListener<S>
Modifier | Constructor and Description |
---|---|
protected |
AbstractMessageDelegator(java.lang.Class delegateType,
boolean automap)
Creates an AbstractMessageDelegator that will forward received
messages to methods of the specified delegate type.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowName(java.lang.String name)
Returns true if the specified method name is allowed.
|
protected void |
automap()
Calls the map(Set) method with a null argument causing
all available matching methods to mapped to message types.
|
protected java.lang.reflect.Method |
findDelegate(java.lang.String name,
java.lang.Class messageType)
Goes through all of the delegate type's methods to find
a method of the specified name that may take the specified
message type.
|
protected java.lang.Class |
getMessageType(java.lang.reflect.Method m)
Convenience method that returns the message type as
reflectively determined for a particular method.
|
java.lang.Class[] |
getMessageTypes()
Returns the array of messages known to be handled by this message
delegator.
|
protected java.lang.reflect.Method |
getMethod(java.lang.Class c)
Returns the mapped method for the specified message type.
|
protected abstract java.lang.Object |
getSourceDelegate(S source)
Implemented by subclasses to provide the actual delegate object
against which the mapped message type methods will be called.
|
protected boolean |
isValidMethod(java.lang.reflect.Method m,
java.lang.Class messageType)
Returns true if the specified method is valid for the specified
message type.
|
AbstractMessageDelegator<S> |
map(java.lang.Class messageType,
java.lang.String methodName)
Manually maps a specified method to the specified message type.
|
protected void |
map(java.util.Set<java.lang.String> constraints)
Goes through all of the delegate type's declared methods
mapping methods that match the current constraints.
|
AbstractMessageDelegator<S> |
map(java.lang.String... methodNames)
Specifically maps the specified methods names, autowiring
the parameters.
|
void |
messageReceived(S source,
Message msg)
Implementation of the MessageListener's messageReceived()
method that will use the current message type mapping to
find an appropriate message handling method and call it
on the delegate returned by getSourceDelegate().
|
protected AbstractMessageDelegator(java.lang.Class delegateType, boolean automap)
public java.lang.Class[] getMessageTypes()
protected boolean isValidMethod(java.lang.reflect.Method m, java.lang.Class messageType)
protected java.lang.Class getMessageType(java.lang.reflect.Method m)
protected java.lang.reflect.Method findDelegate(java.lang.String name, java.lang.Class messageType)
protected boolean allowName(java.lang.String name)
protected final void automap()
public AbstractMessageDelegator<S> map(java.lang.String... methodNames)
protected void map(java.util.Set<java.lang.String> constraints)
public AbstractMessageDelegator<S> map(java.lang.Class messageType, java.lang.String methodName)
protected java.lang.reflect.Method getMethod(java.lang.Class c)
protected abstract java.lang.Object getSourceDelegate(S source)
public void messageReceived(S source, Message msg)
messageReceived
in interface MessageListener<S extends MessageConnection>