Class PojoMethodMapping

java.lang.Object
org.apache.tomcat.websocket.pojo.PojoMethodMapping

public class PojoMethodMapping extends 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 Details

    • PojoMethodMapping

      public PojoMethodMapping(Class<?> clazzPojo, List<Class<? extends Decoder>> decoderClazzes, 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 Details

    • getWsPath

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

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

      public Object[] getOnOpenArgs(Map<String,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 Method getOnClose()
      Return the method annotated with OnClose.
      Returns:
      OnClose method or null if not defined
    • getOnCloseArgs

      public Object[] getOnCloseArgs(Map<String,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 Method getOnError()
      Return the method annotated with OnError.
      Returns:
      OnError method or null if not defined
    • getOnErrorArgs

      public Object[] getOnErrorArgs(Map<String,String> pathParameters, Session session, 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 Set<MessageHandler> getMessageHandlers(Object pojo, Map<String,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