public class ServerSentEventHttpMessageReader extends java.lang.Object implements HttpMessageReader<java.lang.Object>
ServerSentEvent
s and also plain
Object
s which is the same as an ServerSentEvent
with data only.Modifier and Type | Field and Description |
---|---|
private static DataBufferFactory |
bufferFactory |
private Decoder<?> |
decoder |
private static java.util.function.IntPredicate |
NEWLINE_DELIMITER |
private static StringDecoder |
stringDecoder |
Constructor and Description |
---|
ServerSentEventHttpMessageReader()
Constructor without a
Decoder . |
ServerSentEventHttpMessageReader(Decoder<?> decoder)
Constructor with JSON
Decoder for decoding to Objects. |
Modifier and Type | Method and Description |
---|---|
private ServerSentEvent<java.lang.Object> |
buildEvent(java.lang.String[] lines,
ResolvableType valueType,
java.util.Map<java.lang.String,java.lang.Object> hints) |
boolean |
canRead(ResolvableType elementType,
MediaType mediaType)
Whether the given object type is supported by this reader.
|
private java.lang.Object |
decodeData(java.lang.String data,
ResolvableType dataType,
java.util.Map<java.lang.String,java.lang.Object> hints) |
Decoder<?> |
getDecoder()
Return the configured
Decoder . |
java.util.List<MediaType> |
getReadableMediaTypes()
Return the
MediaType 's that this reader supports. |
private boolean |
isServerSentEvent(ResolvableType elementType) |
<any> |
read(ResolvableType elementType,
ReactiveHttpInputMessage message,
java.util.Map<java.lang.String,java.lang.Object> hints)
Read from the input message and encode to a stream of objects.
|
<any> |
readMono(ResolvableType elementType,
ReactiveHttpInputMessage message,
java.util.Map<java.lang.String,java.lang.Object> hints)
Read from the input message and encode to a single object.
|
private static <any> |
splitOnNewline(DataBuffer dataBuffer) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
read, readMono
private static final java.util.function.IntPredicate NEWLINE_DELIMITER
private static final DataBufferFactory bufferFactory
private static final StringDecoder stringDecoder
public ServerSentEventHttpMessageReader()
Decoder
. In this mode only String
is supported as the data of an event.public java.util.List<MediaType> getReadableMediaTypes()
HttpMessageReader
MediaType
's that this reader supports.getReadableMediaTypes
in interface HttpMessageReader<java.lang.Object>
public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType)
HttpMessageReader
canRead
in interface HttpMessageReader<java.lang.Object>
elementType
- the type of object to checkmediaType
- the media type for the read (possibly null
)true
if readable, false
otherwiseprivate boolean isServerSentEvent(ResolvableType elementType)
public <any> read(ResolvableType elementType, ReactiveHttpInputMessage message, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageReader
read
in interface HttpMessageReader<java.lang.Object>
elementType
- the type of objects in the stream which must have been
previously checked via HttpMessageReader.canRead(ResolvableType, MediaType)
message
- the message to read fromhints
- additional information about how to read and decode the inputprivate static <any> splitOnNewline(DataBuffer dataBuffer)
private ServerSentEvent<java.lang.Object> buildEvent(java.lang.String[] lines, ResolvableType valueType, java.util.Map<java.lang.String,java.lang.Object> hints)
@Nullable private java.lang.Object decodeData(java.lang.String data, ResolvableType dataType, java.util.Map<java.lang.String,java.lang.Object> hints)
public <any> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageReader
readMono
in interface HttpMessageReader<java.lang.Object>
elementType
- the type of objects in the stream which must have been
previously checked via HttpMessageReader.canRead(ResolvableType, MediaType)
message
- the message to read fromhints
- additional information about how to read and decode the input