Class ConvertingEncoderDecoderSupport<T,M> 
- Type Parameters:
- T- the type being converted to (for Encoder) or from (for Decoder)
- M- the WebSocket message type (- Stringor- ByteBuffer)
- Direct Known Subclasses:
- ConvertingEncoderDecoderSupport.BinaryDecoder,- ConvertingEncoderDecoderSupport.BinaryEncoder,- ConvertingEncoderDecoderSupport.TextDecoder,- ConvertingEncoderDecoderSupport.TextEncoder
Encoder
 and/or Decoder. It provides encode and decode method
 implementations that delegate to a Spring ConversionService.
 By default, this class looks up a ConversionService registered in the
 active ApplicationContext under
 the name 'webSocketConversionService'. This works fine for both client
 and server endpoints, in a Servlet container environment. If not running in a
 Servlet container, subclasses will need to override the
 getConversionService() method to provide an alternative lookup strategy.
 
Subclasses can extend this class and should also implement one or
 both of Encoder and Decoder.
 For convenience ConvertingEncoderDecoderSupport.BinaryEncoder,
 ConvertingEncoderDecoderSupport.BinaryDecoder,
 ConvertingEncoderDecoderSupport.TextEncoder and
 ConvertingEncoderDecoderSupport.TextDecoder subclasses are provided.
 
Since JSR-356 only allows Encoder/Decoder to be registered by type, instances
 of this class are therefore managed by the WebSocket runtime, and do not need to
 be registered as Spring Beans. They can, however, by injected with Spring-managed
 dependencies via @Autowire.
 
Converters to convert between the type and String or
 ByteBuffer should be registered.
- Since:
- 4.0
- Author:
- Phillip Webb
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classA binaryjakarta.websocket.Encoderthat delegates to Spring's conversion service.static classA binaryjakarta.websocket.Encoderthat delegates to Spring's conversion service.static classA Textjakarta.websocket.Encoderthat delegates to Spring's conversion service.static classA textjakarta.websocket.Encoderthat delegates to Spring's conversion service.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionDecode the message into an object.voiddestroy()Called to destroy the encoder/decoder.Encode an object to a message.protected @Nullable ApplicationContextReturns the activeApplicationContext.protected ConversionServiceStrategy method used to obtain theConversionService.protected TypeDescriptorReturns the websocket message type.protected TypeDescriptorgetType()Returns the type being converted.voidinit(EndpointConfig config) Called to initialize the encoder/decoder.booleanwillDecode(M bytes) Determine if a given message can be decoded.
- 
Constructor Details- 
ConvertingEncoderDecoderSupportpublic ConvertingEncoderDecoderSupport()
 
- 
- 
Method Details- 
initCalled to initialize the encoder/decoder.
- 
destroypublic void destroy()Called to destroy the encoder/decoder.- See Also:
 
- 
getConversionServiceStrategy method used to obtain theConversionService. By default, this method expects a bean named'webSocketConversionService'in theactive ApplicationContext.- Returns:
- the ConversionService(never null)
 
- 
getApplicationContextReturns the activeApplicationContext. By default, this method obtains the context viaContextLoader.getCurrentWebApplicationContext(), which finds the ApplicationContext loaded viaContextLoadertypically in a Servlet container environment. When not running in a Servlet container and not usingContextLoader, this method should be overridden.- Returns:
- the ApplicationContextornull
 
- 
getTypeReturns the type being converted. By default, the type is resolved using the generic arguments of the class.
- 
getMessageTypeReturns the websocket message type. By default, the type is resolved using the generic arguments of the class.
- 
encodeEncode an object to a message.- Throws:
- EncodeException
- See Also:
 
- 
willDecodeDetermine if a given message can be decoded.
- 
decodeDecode the message into an object.- Throws:
- DecodeException
- See Also:
 
 
-