Package com.jme3.network.util
Class AbstractMessageDelegator<S extends MessageConnection>
java.lang.Object
com.jme3.network.util.AbstractMessageDelegator<S>
- All Implemented Interfaces:
- MessageListener<S>
- Direct Known Subclasses:
- ObjectMessageDelegator,- SessionDataDelegator
public abstract class AbstractMessageDelegator<S extends MessageConnection>
extends Object
implements MessageListener<S>
A MessageListener implementation that will forward messages to methods
  of a delegate object.  These methods can be automapped or manually
  specified.  Subclasses provide specific implementations for how to
  find the actual delegate object.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractMessageDelegator(Class delegateType, boolean automap) Creates an AbstractMessageDelegator that will forward received messages to methods of the specified delegate type.
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleanReturns true if the specified method name is allowed.protected final voidautomap()Calls the map(Set) method with a null argument causing all available matching methods to mapped to message types.protected MethodfindDelegate(String name, 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 ClassConvenience method that returns the message type as reflectively determined for a particular method.Class[]Returns the array of messages known to be handled by this message delegator.protected MethodReturns the mapped method for the specified message type.protected abstract ObjectgetSourceDelegate(S source) Implemented by subclasses to provide the actual delegate object against which the mapped message type methods will be called.protected booleanisValidMethod(Method m, Class messageType) Returns true if the specified method is valid for the specified message type.Manually maps a specified method to the specified message type.Specifically maps the specified methods names, autowiring the parameters.protected voidGoes through all of the delegate type's declared methods mapping methods that match the current constraints.voidmessageReceived(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().
- 
Constructor Details- 
AbstractMessageDelegatorCreates an AbstractMessageDelegator that will forward received messages to methods of the specified delegate type. If automap is true then reflection is used to lookup probably message handling methods.
 
- 
- 
Method Details- 
getMessageTypesReturns the array of messages known to be handled by this message delegator.
- 
isValidMethodReturns true if the specified method is valid for the specified message type. This is used internally during automapping to provide implementation specific filtering of methods. This implementation checks for methods that take either the connection and message type arguments (in that order) or just the message type.
- 
getMessageTypeConvenience method that returns the message type as reflectively determined for a particular method. This only works with methods that actually have arguments. This implementation returns the last element of the method's getParameterTypes() array, thus supporting both method(connection, messageType) and method(messageType) calling forms.
- 
findDelegateGoes through all of the delegate type's methods to find a method of the specified name that may take the specified message type.
- 
allowNameReturns true if the specified method name is allowed. This is used by automapping to determine if a method should be rejected purely on name. Default implementation always returns true.
- 
automapprotected final void automap()Calls the map(Set) method with a null argument causing all available matching methods to mapped to message types.
- 
mapSpecifically maps the specified methods names, autowiring the parameters.
- 
mapGoes through all of the delegate type's declared methods mapping methods that match the current constraints. If the constraints set is null then allowName() is checked for names otherwise only names in the constraints set are allowed. For each candidate method that passes the above checks, isValidMethod() is called with a null message type argument. All methods are made accessible thus supporting non-public methods as well as public methods.
- 
mapManually maps a specified method to the specified message type.
- 
getMethodReturns the mapped method for the specified message type.
- 
getSourceDelegateImplemented by subclasses to provide the actual delegate object against which the mapped message type methods will be called.
- 
messageReceivedImplementation 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().- Specified by:
- messageReceivedin interface- MessageListener<S extends MessageConnection>
 
 
-