类 ProtobufHttpMessageWriter

java.lang.Object
cn.taketoday.http.codec.EncoderHttpMessageWriter<com.google.protobuf.Message>
cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter
所有已实现的接口:
HttpMessageWriter<com.google.protobuf.Message>

public class ProtobufHttpMessageWriter extends EncoderHttpMessageWriter<com.google.protobuf.Message>
HttpMessageWriter that can write a protobuf Message and adds X-Protobuf-Schema, X-Protobuf-Message headers and a delimited=true parameter is added to the content type if a flux is serialized.

For HttpMessageReader, just use new DecoderHttpMessageReader(new ProtobufDecoder()).

从以下版本开始:
4.0
作者:
Sebastien Deleuze
另请参阅:
  • 字段详细资料

    • X_PROTOBUF_SCHEMA_HEADER

      private static final String X_PROTOBUF_SCHEMA_HEADER
      另请参阅:
    • X_PROTOBUF_MESSAGE_HEADER

      private static final String X_PROTOBUF_MESSAGE_HEADER
      另请参阅:
    • methodCache

      private static final cn.taketoday.util.ConcurrentReferenceHashMap<Class<?>,Method> methodCache
  • 构造器详细资料

    • ProtobufHttpMessageWriter

      public ProtobufHttpMessageWriter()
      Create a new ProtobufHttpMessageWriter with a default ProtobufEncoder.
    • ProtobufHttpMessageWriter

      public ProtobufHttpMessageWriter(cn.taketoday.core.codec.Encoder<com.google.protobuf.Message> encoder)
      Create a new ProtobufHttpMessageWriter with the given encoder.
      参数:
      encoder - the Protobuf message encoder to use
  • 方法详细资料

    • write

      public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends com.google.protobuf.Message> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
      从接口复制的说明: HttpMessageWriter
      Write an given stream of object to the output message.
      指定者:
      write 在接口中 HttpMessageWriter<com.google.protobuf.Message>
      覆盖:
      write 在类中 EncoderHttpMessageWriter<com.google.protobuf.Message>
      参数:
      inputStream - the objects to write
      elementType - the type of objects in the stream which must have been previously checked via HttpMessageWriter.canWrite(ResolvableType, MediaType)
      mediaType - the content type for the write (possibly null to indicate that the default content type of the writer must be used)
      message - the message to write to
      hints - additional information about how to encode and write
      返回:
      indicates completion or error
    • getMessageBuilder

      private static com.google.protobuf.Message.Builder getMessageBuilder(Class<?> clazz) throws Exception
      Create a new Message.Builder instance for the given class.

      This method uses a ConcurrentHashMap for caching method lookups.

      抛出:
      Exception