Class PojoMethodMapping


  • public class PojoMethodMapping
    extends java.lang.Object
    For a POJO class annotated with ServerEndpoint, an instance of this class creates and caches the method handler, method information and parameter information for the onXXX calls.
    • Constructor Summary

      Constructors 
      Constructor Description
      PojoMethodMapping​(java.lang.Class<?> clazzPojo, java.util.List<java.lang.Class<? extends Decoder>> decoderClazzes, java.lang.String wsPath, InstanceManager instanceManager)
      Create a method mapping for the given POJO
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<MessageHandler> getMessageHandlers​(java.lang.Object pojo, java.util.Map<java.lang.String,​java.lang.String> pathParameters, Session session, EndpointConfig config)
      Create the message handlers for the given POJO instance.
      java.lang.reflect.Method getOnClose()
      Return the method annotated with OnClose.
      java.lang.Object[] getOnCloseArgs​(java.util.Map<java.lang.String,​java.lang.String> pathParameters, Session session, CloseReason closeReason)
      Build the arguments for the onClose method.
      java.lang.reflect.Method getOnError()
      Return the method annotated with OnError.
      java.lang.Object[] getOnErrorArgs​(java.util.Map<java.lang.String,​java.lang.String> pathParameters, Session session, java.lang.Throwable throwable)
      Build the arguments for the onError method.
      java.lang.reflect.Method getOnOpen()
      Return the method annotated with OnOpen.
      java.lang.Object[] getOnOpenArgs​(java.util.Map<java.lang.String,​java.lang.String> pathParameters, Session session, EndpointConfig config)
      Build the arguments for the onOpen method.
      java.lang.String getWsPath()
      Return the WebSocket path for this endpoint.
      boolean hasMessageHandlers()
      Check if there are any message handlers defined.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PojoMethodMapping

        public PojoMethodMapping​(java.lang.Class<?> clazzPojo,
                                 java.util.List<java.lang.Class<? extends Decoder>> decoderClazzes,
                                 java.lang.String wsPath,
                                 InstanceManager instanceManager)
                          throws DeploymentException
        Create a method mapping for the given POJO
        Parameters:
        clazzPojo - POJO implementation class
        decoderClazzes - Set of potential decoder classes
        wsPath - Path at which the endpoint will be deployed
        instanceManager - Instance manager to use to create Decoder instances
        Throws:
        DeploymentException - If the mapping cannot be completed
    • Method Detail

      • getWsPath

        public java.lang.String getWsPath()
        Return the WebSocket path for this endpoint.
        Returns:
        WebSocket path
      • getOnOpen

        public java.lang.reflect.Method getOnOpen()
        Return the method annotated with OnOpen.
        Returns:
        OnOpen method or null if not defined
      • getOnOpenArgs

        public java.lang.Object[] getOnOpenArgs​(java.util.Map<java.lang.String,​java.lang.String> pathParameters,
                                                Session session,
                                                EndpointConfig config)
                                         throws DecodeException
        Build the arguments for the onOpen method.
        Parameters:
        pathParameters - Path parameters
        session - WebSocket session
        config - Endpoint configuration
        Returns:
        Arguments for the onOpen method
        Throws:
        DecodeException - If a path parameter cannot be decoded
      • getOnClose

        public java.lang.reflect.Method getOnClose()
        Return the method annotated with OnClose.
        Returns:
        OnClose method or null if not defined
      • getOnCloseArgs

        public java.lang.Object[] getOnCloseArgs​(java.util.Map<java.lang.String,​java.lang.String> pathParameters,
                                                 Session session,
                                                 CloseReason closeReason)
                                          throws DecodeException
        Build the arguments for the onClose method.
        Parameters:
        pathParameters - Path parameters
        session - WebSocket session
        closeReason - Reason for the close
        Returns:
        Arguments for the onClose method
        Throws:
        DecodeException - If a path parameter cannot be decoded
      • getOnError

        public java.lang.reflect.Method getOnError()
        Return the method annotated with OnError.
        Returns:
        OnError method or null if not defined
      • getOnErrorArgs

        public java.lang.Object[] getOnErrorArgs​(java.util.Map<java.lang.String,​java.lang.String> pathParameters,
                                                 Session session,
                                                 java.lang.Throwable throwable)
                                          throws DecodeException
        Build the arguments for the onError method.
        Parameters:
        pathParameters - Path parameters
        session - WebSocket session
        throwable - Throwable that triggered the error
        Returns:
        Arguments for the onError method
        Throws:
        DecodeException - If a path parameter cannot be decoded
      • hasMessageHandlers

        public boolean hasMessageHandlers()
        Check if there are any message handlers defined.
        Returns:
        true if there are message handlers
      • getMessageHandlers

        public java.util.Set<MessageHandler> getMessageHandlers​(java.lang.Object pojo,
                                                                java.util.Map<java.lang.String,​java.lang.String> pathParameters,
                                                                Session session,
                                                                EndpointConfig config)
        Create the message handlers for the given POJO instance.
        Parameters:
        pojo - POJO instance
        pathParameters - Path parameters
        session - WebSocket session
        config - Endpoint configuration
        Returns:
        Set of message handlers