Class PojoMessageHandlerBase<T>
java.lang.Object
org.apache.tomcat.websocket.pojo.PojoMessageHandlerBase<T>
- Type Parameters:
T- The type of message to handle
- All Implemented Interfaces:
WrappedMessageHandler
- Direct Known Subclasses:
PojoMessageHandlerPartialBase, PojoMessageHandlerWholeBase
Common implementation code for the POJO message handlers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanWhether the message payload should be converted to the method parameter type.protected final intThe index in the params array where the payload is stored.protected final intThe index in the params array where the session is stored.protected final longThe maximum message size supported by this handler.protected final MethodThe method to invoke when a message is received.protected final Object[]The parameter array used for method invocation.protected final ObjectThe POJO instance that contains the message handler method.protected final SessionThe WebSocket session associated with this handler. -
Constructor Summary
ConstructorsConstructorDescriptionPojoMessageHandlerBase(Object pojo, Method method, Session session, Object[] params, int indexPayload, boolean convert, int indexSession, long maxMessageSize) Constructs a new PojoMessageHandlerBase. -
Method Summary
Modifier and TypeMethodDescriptionfinal longReturns the maximum message size supported by this handler.final MessageHandlerExpose the POJO if it is a message handler so the Session is able to match requests to remove handlers if the original handler has been wrapped.protected final voidHandles anInvocationTargetExceptionthat occurred during POJO method invocation.protected final voidprocessResult(Object result) Processes the result of a POJO message handler method invocation by sending it back to the remote endpoint.
-
Field Details
-
pojo
The POJO instance that contains the message handler method. -
method
The method to invoke when a message is received. -
session
The WebSocket session associated with this handler. -
params
The parameter array used for method invocation. -
indexPayload
protected final int indexPayloadThe index in the params array where the payload is stored. -
convert
protected final boolean convertWhether the message payload should be converted to the method parameter type. -
indexSession
protected final int indexSessionThe index in the params array where the session is stored. -
maxMessageSize
protected final long maxMessageSizeThe maximum message size supported by this handler.
-
-
Constructor Details
-
PojoMessageHandlerBase
public PojoMessageHandlerBase(Object pojo, Method method, Session session, Object[] params, int indexPayload, boolean convert, int indexSession, long maxMessageSize) Constructs a new PojoMessageHandlerBase.- Parameters:
pojo- the POJO instance containing the message handler methodmethod- the method to invoke when a message is receivedsession- the WebSocket sessionparams- the parameter array for method invocationindexPayload- the index in the params array for the payloadconvert- whether to convert the payload to the method parameter typeindexSession- the index in the params array for the sessionmaxMessageSize- the maximum message size
-
-
Method Details
-
processResult
Processes the result of a POJO message handler method invocation by sending it back to the remote endpoint.- Parameters:
result- the result object to send
-
getWrappedHandler
Expose the POJO if it is a message handler so the Session is able to match requests to remove handlers if the original handler has been wrapped.- Specified by:
getWrappedHandlerin interfaceWrappedMessageHandler- Returns:
- the wrapped message handler
-
getMaxMessageSize
public final long getMaxMessageSize()Description copied from interface:WrappedMessageHandlerReturns the maximum message size supported by this handler.- Specified by:
getMaxMessageSizein interfaceWrappedMessageHandler- Returns:
- the maximum message size
-
handlePojoMethodInvocationTargetException
Handles anInvocationTargetExceptionthat occurred during POJO method invocation.- Parameters:
e- the invocation target exception
-