Class PojoMethodMapping
java.lang.Object
org.apache.tomcat.websocket.pojo.PojoMethodMapping
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
ConstructorsConstructorDescriptionPojoMethodMapping(Class<?> clazzPojo, List<Class<? extends Decoder>> decoderClazzes, String wsPath, InstanceManager instanceManager) Create a method mapping for the given POJO -
Method Summary
Modifier and TypeMethodDescriptiongetMessageHandlers(Object pojo, Map<String, String> pathParameters, Session session, EndpointConfig config) Create the message handlers for the given POJO instance.Return the method annotated withOnClose.Object[]getOnCloseArgs(Map<String, String> pathParameters, Session session, CloseReason closeReason) Build the arguments for the onClose method.Return the method annotated withOnError.Object[]Build the arguments for the onError method.Return the method annotated withOnOpen.Object[]getOnOpenArgs(Map<String, String> pathParameters, Session session, EndpointConfig config) Build the arguments for the onOpen method.Return the WebSocket path for this endpoint.booleanCheck if there are any message handlers defined.
-
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 classdecoderClazzes- Set of potential decoder classeswsPath- Path at which the endpoint will be deployedinstanceManager- Instance manager to use to create Decoder instances- Throws:
DeploymentException- If the mapping cannot be completed
-
-
Method Details
-
getWsPath
-
getOnOpen
-
getOnOpenArgs
public Object[] getOnOpenArgs(Map<String, String> pathParameters, Session session, EndpointConfig config) throws DecodeExceptionBuild the arguments for the onOpen method.- Parameters:
pathParameters- Path parameterssession- WebSocket sessionconfig- Endpoint configuration- Returns:
- Arguments for the onOpen method
- Throws:
DecodeException- If a path parameter cannot be decoded
-
getOnClose
-
getOnCloseArgs
public Object[] getOnCloseArgs(Map<String, String> pathParameters, Session session, CloseReason closeReason) throws DecodeExceptionBuild the arguments for the onClose method.- Parameters:
pathParameters- Path parameterssession- WebSocket sessioncloseReason- Reason for the close- Returns:
- Arguments for the onClose method
- Throws:
DecodeException- If a path parameter cannot be decoded
-
getOnError
-
getOnErrorArgs
public Object[] getOnErrorArgs(Map<String, String> pathParameters, Session session, Throwable throwable) throws DecodeExceptionBuild the arguments for the onError method.- Parameters:
pathParameters- Path parameterssession- WebSocket sessionthrowable- 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:
trueif 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 instancepathParameters- Path parameterssession- WebSocket sessionconfig- Endpoint configuration- Returns:
- Set of message handlers
-