Class SessionDataDelegator

All Implemented Interfaces:
MessageListener<HostedConnection>

public class SessionDataDelegator extends AbstractMessageDelegator<HostedConnection>
A MessageListener implementation that will forward messages to methods of a delegate specified as a HostedConnection session attribute. This is useful for handling connection-specific messages from clients that must delegate to client-specific data objects. The delegate methods can be automapped or manually specified.
  • Constructor Details

    • SessionDataDelegator

      public SessionDataDelegator(Class delegateType, String attributeName, boolean automap)
      Creates a MessageListener that will forward mapped message types to methods of an object specified as a HostedConnection attribute. If automap is true then all methods with the proper signature will be mapped.

      Methods of the following signatures are allowed:

      • void someName(S conn, SomeMessage msg)
      • void someName(Message msg)
      Where S is the type of MessageConnection and SomeMessage is some specific concrete Message subclass.
  • Method Details

    • getAttributeName

      public String getAttributeName()
      Returns the attribute name that will be used to look up the delegate object.
    • miss

      protected void miss(HostedConnection source)
      Called internally when there is no session object for the current attribute name attached to the passed source HostConnection. Default implementation logs a warning.
    • getSourceDelegate

      protected Object getSourceDelegate(HostedConnection source)
      Returns the attributeName attribute of the supplied source HostConnection. If there is no value at that attribute then the miss() method is called.
      Specified by:
      getSourceDelegate in class AbstractMessageDelegator<HostedConnection>