Package org.apache.tomcat.websocket.pojo
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
public abstract class PojoMessageHandlerBase<T> extends java.lang.Object implements WrappedMessageHandler
Common implementation code for the POJO message handlers.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanconvertWhether the message payload should be converted to the method parameter type.protected intindexPayloadThe index in the params array where the payload is stored.protected intindexSessionThe index in the params array where the session is stored.protected longmaxMessageSizeThe maximum message size supported by this handler.protected java.lang.reflect.MethodmethodThe method to invoke when a message is received.protected java.lang.Object[]paramsThe parameter array used for method invocation.protected java.lang.ObjectpojoThe POJO instance that contains the message handler method.protected SessionsessionThe WebSocket session associated with this handler.
-
Constructor Summary
Constructors Constructor Description PojoMessageHandlerBase(java.lang.Object pojo, java.lang.reflect.Method method, Session session, java.lang.Object[] params, int indexPayload, boolean convert, int indexSession, long maxMessageSize)Constructs a new PojoMessageHandlerBase.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetMaxMessageSize()Returns the maximum message size supported by this handler.MessageHandlergetWrappedHandler()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.protected voidhandlePojoMethodException(java.lang.Throwable t)protected voidprocessResult(java.lang.Object result)Processes the result of a POJO message handler method invocation by sending it back to the remote endpoint.
-
-
-
Field Detail
-
pojo
protected final java.lang.Object pojo
The POJO instance that contains the message handler method.
-
method
protected final java.lang.reflect.Method method
The method to invoke when a message is received.
-
session
protected final Session session
The WebSocket session associated with this handler.
-
params
protected final java.lang.Object[] params
The parameter array used for method invocation.
-
indexPayload
protected final int indexPayload
The index in the params array where the payload is stored.
-
convert
protected final boolean convert
Whether the message payload should be converted to the method parameter type.
-
indexSession
protected final int indexSession
The index in the params array where the session is stored.
-
maxMessageSize
protected final long maxMessageSize
The maximum message size supported by this handler.
-
-
Constructor Detail
-
PojoMessageHandlerBase
public PojoMessageHandlerBase(java.lang.Object pojo, java.lang.reflect.Method method, Session session, java.lang.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 Detail
-
processResult
protected final void processResult(java.lang.Object result)
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
public final MessageHandler 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
-
handlePojoMethodException
protected final void handlePojoMethodException(java.lang.Throwable t)
-
-