类 ProtobufDecoder
- 所有已实现的接口:
cn.taketoday.core.codec.Decoder<com.google.protobuf.Message>
Decoder that reads Messages using
Google Protocol Buffers.
Flux deserialized via
decode(Publisher, ResolvableType, MimeType, Map) are expected to use
delimited Protobuf messages with the size of each message specified before
the message itself. Single values deserialized via
decodeToMono(Publisher, ResolvableType, MimeType, Map) are expected
to use regular Protobuf message format (without the size prepended before
the message).
Notice that default instance of Protobuf message produces empty byte
array, so Mono.just(Msg.getDefaultInstance()) sent over the network
will be deserialized as an empty Mono.
To generate Message Java classes, you need to install the
protoc binary.
This decoder requires Protobuf 3 or higher, and supports
"application/x-protobuf" and "application/octet-stream" with
the official "com.google.protobuf:protobuf-java" library.
- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明protected static final intThe default max size for aggregating messages.private final com.google.protobuf.ExtensionRegistryprivate intprivate static final ConcurrentMap<Class<?>,Method> 从类继承的字段 cn.taketoday.http.codec.protobuf.ProtobufCodecSupport
DELIMITED_KEY, DELIMITED_VALUE, MIME_TYPES -
构造器概要
构造器构造器说明Construct a newProtobufDecoder.ProtobufDecoder(com.google.protobuf.ExtensionRegistry extensionRegistry) Construct a newProtobufDecoderwith an initializer that allows the registration of message extensions. -
方法概要
修饰符和类型方法说明booleancanDecode(cn.taketoday.core.ResolvableType elementType, cn.taketoday.util.MimeType mimeType) com.google.protobuf.Messagedecode(cn.taketoday.core.io.buffer.DataBuffer dataBuffer, cn.taketoday.core.ResolvableType targetType, cn.taketoday.util.MimeType mimeType, Map<String, Object> hints) reactor.core.publisher.Flux<com.google.protobuf.Message>decode(org.reactivestreams.Publisher<cn.taketoday.core.io.buffer.DataBuffer> inputStream, cn.taketoday.core.ResolvableType elementType, cn.taketoday.util.MimeType mimeType, Map<String, Object> hints) reactor.core.publisher.Mono<com.google.protobuf.Message>decodeToMono(org.reactivestreams.Publisher<cn.taketoday.core.io.buffer.DataBuffer> inputStream, cn.taketoday.core.ResolvableType elementType, cn.taketoday.util.MimeType mimeType, Map<String, Object> hints) List<cn.taketoday.util.MimeType>intReturn theconfiguredmessage size limit.private static com.google.protobuf.Message.BuildergetMessageBuilder(Class<?> clazz) Create a newMessage.Builderinstance for the given class.voidsetMaxMessageSize(int maxMessageSize) The max size allowed per message.从类继承的方法 cn.taketoday.http.codec.protobuf.ProtobufCodecSupport
getMimeTypes, supportsMimeType从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.core.codec.Decoder
getDecodableMimeTypes
-
字段详细资料
-
DEFAULT_MESSAGE_MAX_SIZE
protected static final int DEFAULT_MESSAGE_MAX_SIZEThe default max size for aggregating messages.- 另请参阅:
-
methodCache
-
extensionRegistry
private final com.google.protobuf.ExtensionRegistry extensionRegistry -
maxMessageSize
private int maxMessageSize
-
-
构造器详细资料
-
ProtobufDecoder
public ProtobufDecoder()Construct a newProtobufDecoder. -
ProtobufDecoder
public ProtobufDecoder(com.google.protobuf.ExtensionRegistry extensionRegistry) Construct a newProtobufDecoderwith an initializer that allows the registration of message extensions.- 参数:
extensionRegistry- a message extension registry
-
-
方法详细资料
-
setMaxMessageSize
public void setMaxMessageSize(int maxMessageSize) The max size allowed per message.By default, this is set to 256K.
- 参数:
maxMessageSize- the max size per message, or -1 for unlimited
-
getMaxMessageSize
public int getMaxMessageSize()Return theconfiguredmessage size limit. -
canDecode
public boolean canDecode(cn.taketoday.core.ResolvableType elementType, @Nullable cn.taketoday.util.MimeType mimeType) - 指定者:
canDecode在接口中cn.taketoday.core.codec.Decoder<com.google.protobuf.Message>
-
decode
public reactor.core.publisher.Flux<com.google.protobuf.Message> decode(org.reactivestreams.Publisher<cn.taketoday.core.io.buffer.DataBuffer> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable cn.taketoday.util.MimeType mimeType, @Nullable Map<String, Object> hints) - 指定者:
decode在接口中cn.taketoday.core.codec.Decoder<com.google.protobuf.Message>
-
decodeToMono
public reactor.core.publisher.Mono<com.google.protobuf.Message> decodeToMono(org.reactivestreams.Publisher<cn.taketoday.core.io.buffer.DataBuffer> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable cn.taketoday.util.MimeType mimeType, @Nullable Map<String, Object> hints) - 指定者:
decodeToMono在接口中cn.taketoday.core.codec.Decoder<com.google.protobuf.Message>
-
decode
public com.google.protobuf.Message decode(cn.taketoday.core.io.buffer.DataBuffer dataBuffer, cn.taketoday.core.ResolvableType targetType, @Nullable cn.taketoday.util.MimeType mimeType, @Nullable Map<String, Object> hints) throws cn.taketoday.core.codec.DecodingException- 指定者:
decode在接口中cn.taketoday.core.codec.Decoder<com.google.protobuf.Message>- 抛出:
cn.taketoday.core.codec.DecodingException
-
getMessageBuilder
private static com.google.protobuf.Message.Builder getMessageBuilder(Class<?> clazz) throws Exception Create a newMessage.Builderinstance for the given class.This method uses a ConcurrentHashMap for caching method lookups.
- 抛出:
Exception
-
getDecodableMimeTypes
- 指定者:
getDecodableMimeTypes在接口中cn.taketoday.core.codec.Decoder<com.google.protobuf.Message>
-