Package org.apache.tomcat.websocket.pojo
Class PojoMethodMapping
- java.lang.Object
-
- org.apache.tomcat.websocket.pojo.PojoMethodMapping
-
public class PojoMethodMapping extends java.lang.ObjectFor a POJO class annotated withServerEndpoint, 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.MethodgetOnClose()Return the method annotated withOnClose.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.MethodgetOnError()Return the method annotated withOnError.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.MethodgetOnOpen()Return the method annotated withOnOpen.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.StringgetWsPath()Return the WebSocket path for this endpoint.booleanhasMessageHandlers()Check if there are any message handlers defined.
-
-
-
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 DeploymentExceptionCreate 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 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 withOnOpen.- Returns:
- OnOpen method or
nullif not defined
-
getOnOpenArgs
public java.lang.Object[] getOnOpenArgs(java.util.Map<java.lang.String,java.lang.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
public java.lang.reflect.Method getOnClose()
Return the method annotated withOnClose.- Returns:
- OnClose method or
nullif not defined
-
getOnCloseArgs
public java.lang.Object[] getOnCloseArgs(java.util.Map<java.lang.String,java.lang.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
public java.lang.reflect.Method getOnError()
Return the method annotated withOnError.- Returns:
- OnError method or
nullif 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 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 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 instancepathParameters- Path parameterssession- WebSocket sessionconfig- Endpoint configuration- Returns:
- Set of message handlers
-
-