# 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

Fields
Modifier and Type
Field
Description
`protected final List<Decoder>`
`decoders`
The list of decoders for this message handler.

### Fields inherited from class PojoMessageHandlerBase

`convert, indexPayload, indexSession, maxMessageSize, method, params, pojo, session`

## Constructor Summary

Constructors
Constructor
Description
`PojoMessageHandlerWholeBase(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 Type
Method
Description
`protected Object`
`convert(T message)`
Convert the message to the type expected by the target method.
`protected Decoder`
`createDecoderInstance(Class<? extends Decoder> clazz)`
Create an instance of the given decoder class.
`protected abstract Object`
`decode(T message)`
Decode the message using the registered decoders.
`protected void`
`onClose()`
Called when the WebSocket session is closed.
`final void`
`onMessage(T message)`
Called when a whole message is available to be processed.

### Methods inherited from class PojoMessageHandlerBase

`getMaxMessageSize, getWrappedHandler, handlePojoMethodException, processResult`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### decoders

protected final List<Decoder> decoders
The list of decoders for this message handler.

## 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 instance
  `method` - Method to invoke
  `session` - WebSocket session
  `params` - Pre-populated parameter array
  `indexPayload` - Index of the payload parameter
  `convert` - Convert the message before passing to the method
  `indexSession` - Index of the session parameter
  `maxMessageSize` - 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 instantiated
  `NamingException` - If the instance manager fails to create the decoder

### onMessage

public final void onMessage(T message)
Description copied from interface: `javax.websocket.MessageHandler.Whole`
Called when a whole message is available to be processed.

Specified by:
  `onMessage` in interface `MessageHandler.Whole<T>`
Parameters:
  `message` - The message

### onClose

protected void onClose()
Called when the WebSocket session is closed. Destroys all decoders.

### convert

protected Object convert(T message)
Convert the message to the type expected by the target method.

Parameters:
  `message` - Message to convert
Returns:
  Converted message

### decode

protected abstract Object decode(T message) throws DecodeException
Decode the message using the registered decoders.

Parameters:
  `message` - Message to decode
Returns:
  Decoded message or `null` if no decoder could decode it
Throws:
  `DecodeException` - If the message cannot be decoded