A data conversion that resolves the MediaTypeConverter
to use to encode or decode content based on an HTTP message payload media type or a WebSocket subprotocol.
It uses the list of media type converters
injected in the module.
- Since:
- 1.12
- Author:
- Jeremy Kuhn
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> InboundDataDecoder
<T> createDecoder
(InboundData<ByteBuf> rawData, String mediaType, Class<T> type) Creates an inbound data decoder.<T> InboundDataDecoder
<T> createDecoder
(InboundData<ByteBuf> rawData, String mediaType, Type type) Creates an inbound data decoder.<T> OutboundDataEncoder
<T> createEncoder
(OutboundData<ByteBuf> rawData, String mediaType) Creates an outbound data encoder.<T> OutboundDataEncoder
<T> createEncoder
(OutboundData<ByteBuf> rawData, String mediaType, Class<T> type) Creates an outbound data encoder.<T> OutboundDataEncoder
<T> createEncoder
(OutboundData<ByteBuf> rawData, String mediaType, Type type) Creates an outbound data encoder.createWebSocketDecodingInbound
(BaseWebSocketExchange.Inbound inbound, String subprotocol) Creates a decoding WebSocket inbound.createWebSocketEncodingOutbound
(BaseWebSocketExchange.Outbound outbound, String subprotocol) Creates an encoding WebSocket outbound.getConverter
(String mediaType) Returns the converter supporting the specified media type.
-
Method Details
-
getConverter
Returns the converter supporting the specified media type.
- Parameters:
mediaType
- a media type- Returns:
- a media type converter
- Throws:
MissingConverterException
- if no converter supporting the media type was found
-
createDecoder
<T> InboundDataDecoder<T> createDecoder(InboundData<ByteBuf> rawData, String mediaType, Class<T> type) throws MissingConverterException Creates an inbound data decoder.
- Type Parameters:
T
- the Java content type- Parameters:
rawData
- the raw inbound datamediaType
- the media typetype
- the Java content type- Returns:
- an inbound data decoder
- Throws:
MissingConverterException
- if no converter supporting the media type was found
-
createDecoder
<T> InboundDataDecoder<T> createDecoder(InboundData<ByteBuf> rawData, String mediaType, Type type) throws MissingConverterException Creates an inbound data decoder.
- Type Parameters:
T
- the Java content type- Parameters:
rawData
- the raw inbound datamediaType
- the media typetype
- the Java content type- Returns:
- an inbound data decoder
- Throws:
MissingConverterException
- if no converter supporting the media type was found
-
createEncoder
<T> OutboundDataEncoder<T> createEncoder(OutboundData<ByteBuf> rawData, String mediaType) throws MissingConverterException Creates an outbound data encoder.
- Type Parameters:
T
- the Java content type- Parameters:
rawData
- the raw outbound datamediaType
- the media type- Returns:
- an outbound data encoder
- Throws:
MissingConverterException
- if no converter supporting the media type was found
-
createEncoder
<T> OutboundDataEncoder<T> createEncoder(OutboundData<ByteBuf> rawData, String mediaType, Class<T> type) throws MissingConverterException Creates an outbound data encoder.
- Type Parameters:
T
- the Java content type- Parameters:
rawData
- the raw outbound datamediaType
- the media typetype
- the Java content type- Returns:
- an outbound data encoder
- Throws:
MissingConverterException
- if no converter supporting the media type was found
-
createEncoder
<T> OutboundDataEncoder<T> createEncoder(OutboundData<ByteBuf> rawData, String mediaType, Type type) throws MissingConverterException Creates an outbound data encoder.
- Type Parameters:
T
- the Java content type- Parameters:
rawData
- the raw outbound datamediaType
- the media typetype
- the Java content type- Returns:
- an outbound data encoder
- Throws:
MissingConverterException
- if no converter supporting the media type was found
-
createWebSocketDecodingInbound
BaseWeb2SocketExchange.Inbound createWebSocketDecodingInbound(BaseWebSocketExchange.Inbound inbound, String subprotocol) Creates a decoding WebSocket inbound.
In order to resolve a matching
MediaTypeConverter
, the subprotocol is considered as an application media type normalized withMediaTypes.normalizeApplicationMediaType(String)
.- Parameters:
inbound
- the raw WebSocket inboundsubprotocol
- the WebSocket subprotocol- Returns:
- a decoding WebSocket inbound
-
createWebSocketEncodingOutbound
BaseWeb2SocketExchange.Outbound createWebSocketEncodingOutbound(BaseWebSocketExchange.Outbound outbound, String subprotocol) Creates an encoding WebSocket outbound.
In order to resolve a matching
MediaTypeConverter
, the subprotocol is considered as an application media type normalized withMediaTypes.normalizeApplicationMediaType(String)
.- Parameters:
outbound
- the raw WebSocket outboundsubprotocol
- the WebSocket subprotocol- Returns:
- an encoding WebSocket outbound
-