Class PojoMessageHandlerWholeBase<T>
java.lang.Object
org.apache.tomcat.websocket.pojo.PojoMessageHandlerBase<T>
org.apache.tomcat.websocket.pojo.PojoMessageHandlerWholeBase<T>
- Type Parameters:
T- The type of message to handle
- All Implemented Interfaces:
MessageHandler, MessageHandler.Whole<T>, WrappedMessageHandler
- Direct Known Subclasses:
PojoMessageHandlerWholeBinary, PojoMessageHandlerWholePong, PojoMessageHandlerWholeText
public abstract class PojoMessageHandlerWholeBase<T>
extends PojoMessageHandlerBase<T>
implements MessageHandler.Whole<T>
Common implementation code for the POJO whole message handlers. All the real work is done in this class and in the
superclass.
-
Nested Class Summary
Nested classes/interfaces inherited from interface MessageHandler
MessageHandler.Partial<T>, MessageHandler.Whole<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of decoders for this message handler.Fields inherited from class PojoMessageHandlerBase
convert, indexPayload, indexSession, maxMessageSize, method, params, pojo, session -
Constructor Summary
ConstructorsConstructorDescriptionPojoMessageHandlerWholeBase(Object pojo, Method method, Session session, Object[] params, int indexPayload, boolean convert, int indexSession, long maxMessageSize) Create a whole message handler. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectConvert the message to the type expected by the target method.protected DecodercreateDecoderInstance(Class<? extends Decoder> clazz) Create an instance of the given decoder class.protected abstract ObjectDecode the message using the registered decoders.protected voidonClose()Called when the WebSocket session is closed.final voidCalled when a whole message is available to be processed.Methods inherited from class PojoMessageHandlerBase
getMaxMessageSize, getWrappedHandler, handlePojoMethodInvocationTargetException, processResult
-
Field Details
-
decoders
-
-
Constructor Details
-
PojoMessageHandlerWholeBase
public PojoMessageHandlerWholeBase(Object pojo, Method method, Session session, Object[] params, int indexPayload, boolean convert, int indexSession, long maxMessageSize) Create a whole message handler.- Parameters:
pojo- POJO instancemethod- Method to invokesession- WebSocket sessionparams- Pre-populated parameter arrayindexPayload- Index of the payload parameterconvert- Convert the message before passing to the methodindexSession- Index of the session parametermaxMessageSize- Maximum message size
-
-
Method Details
-
createDecoderInstance
protected Decoder createDecoderInstance(Class<? extends Decoder> clazz) throws ReflectiveOperationException, NamingException Create an instance of the given decoder class.- Parameters:
clazz- Decoder class- Returns:
- New decoder instance
- Throws:
ReflectiveOperationException- If the decoder cannot be instantiatedNamingException- If the instance manager fails to create the decoder
-
onMessage
Description copied from interface:jakarta.websocket.MessageHandler.WholeCalled when a whole message is available to be processed.- Specified by:
onMessagein interfaceMessageHandler.Whole<T>- Parameters:
message- The message
-
onClose
protected void onClose()Called when the WebSocket session is closed. Destroys all decoders. -
convert
-
decode
Decode the message using the registered decoders.- Parameters:
message- Message to decode- Returns:
- Decoded message or
nullif no decoder could decode it - Throws:
DecodeException- If the message cannot be decoded
-