public class ProtobufEncoder extends ProtobufCodecSupport implements HttpMessageEncoder<com.google.protobuf.Message>
Encoder
that writes Message
s
using Google Protocol Buffers.
Flux are serialized using delimited Protobuf messages with the size of each message specified before the message itself. Single values are serialized using regular Protobuf message format (without the size prepended before the message).
To generate Message
Java classes, you need to install the protoc
binary.
This encoder requires Protobuf 3 or higher, and supports
"application/x-protobuf"
and "application/octet-stream"
with the official
"com.google.protobuf:protobuf-java"
library.
ProtobufDecoder
Constructor and Description |
---|
ProtobufEncoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
canEncode(org.springframework.core.ResolvableType elementType,
org.springframework.util.MimeType mimeType) |
reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> |
encode(org.reactivestreams.Publisher<? extends com.google.protobuf.Message> inputStream,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
org.springframework.core.ResolvableType elementType,
org.springframework.util.MimeType mimeType,
Map<String,Object> hints) |
org.springframework.core.io.buffer.DataBuffer |
encodeValue(com.google.protobuf.Message message,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
org.springframework.core.ResolvableType valueType,
org.springframework.util.MimeType mimeType,
Map<String,Object> hints) |
List<org.springframework.util.MimeType> |
getEncodableMimeTypes() |
List<MediaType> |
getStreamingMediaTypes()
Return "streaming" media types for which flushing should be performed
automatically vs at the end of the input stream.
|
getMimeTypes, supportsMimeType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEncodeHints
public boolean canEncode(org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType)
canEncode
in interface org.springframework.core.codec.Encoder<com.google.protobuf.Message>
public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> encode(org.reactivestreams.Publisher<? extends com.google.protobuf.Message> inputStream, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String,Object> hints)
encode
in interface org.springframework.core.codec.Encoder<com.google.protobuf.Message>
public org.springframework.core.io.buffer.DataBuffer encodeValue(com.google.protobuf.Message message, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType valueType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String,Object> hints)
encodeValue
in interface org.springframework.core.codec.Encoder<com.google.protobuf.Message>
public List<MediaType> getStreamingMediaTypes()
HttpMessageEncoder
getStreamingMediaTypes
in interface HttpMessageEncoder<com.google.protobuf.Message>
public List<org.springframework.util.MimeType> getEncodableMimeTypes()
getEncodableMimeTypes
in interface org.springframework.core.codec.Encoder<com.google.protobuf.Message>