クラス ProtobufJsonDecoder

java.lang.ObjectSE
org.springframework.http.codec.protobuf.ProtobufJsonDecoder
実装されたすべてのインターフェース:
Decoder<com.google.protobuf.Message>

public class ProtobufJsonDecoder extends ObjectSE implements Decoder<com.google.protobuf.Message>
JSON バイトストリームを読み取り、それを Google プロトコルバッファ Message に変換する Decoder

decode(Publisher, ResolvableType, MimeType, Map) 経由でデシリアライズされた Flux は、Protobuf Java Util ライブラリが JSON ストリームをトークンに分割するノンブロッキングパーサーを提供しないため、サポートされていません。アプリケーションは、サポートされている decodeToMono(Publisher, ResolvableType, MimeType, Map) を使用する Mono<Message> または Mono<List<Message>> へのデコードを検討する必要があります。

Message Java クラスを生成するには、protoc バイナリをインストールする必要があります。

このデコーダーには Protobuf 3.29 以上が必要であり、公式の "com.google.protobuf:protobuf-java-util" ライブラリを使用して "application/json" および "application/*+json" をサポートします。

導入:
6.2
作成者:
Brian Clozel
関連事項:
  • フィールドの詳細

    • DEFAULT_MESSAGE_MAX_SIZE

      protected static final int DEFAULT_MESSAGE_MAX_SIZE
      メッセージを集約するためのデフォルトの最大サイズ。
      関連事項:
  • コンストラクターの詳細

    • ProtobufJsonDecoder

      public ProtobufJsonDecoder()
      デフォルトの JsonFormat.Parser インスタンスを使用して新しい ProtobufJsonDecoder を構築します。
    • ProtobufJsonDecoder

      public ProtobufJsonDecoder(com.google.protobuf.util.JsonFormat.Parser parser)
      指定された JsonFormat.Parser インスタンスを使用して新しい ProtobufJsonDecoder を構築します。
  • メソッドの詳細

    • getMaxMessageSize

      public int getMaxMessageSize()
      configured メッセージのサイズ制限を返します。
    • setMaxMessageSize

      public void setMaxMessageSize(int maxMessageSize)
      メッセージごとに許可される最大サイズ。

      デフォルトでは、これは 256K に設定されています。

      パラメーター:
      maxMessageSize - メッセージごとの最大サイズ、または無制限の場合は -1
    • canDecode

      public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
      インターフェースからコピーされた説明: Decoder
      デコーダーが特定のターゲット要素型とソースストリームの MIME 型をサポートするかどうか。
      次で指定:
      インターフェース Decoder<com.google.protobuf.Message>canDecode 
      パラメーター:
      elementType - 出力ストリームのターゲット要素型
      mimeType - デコードするストリームに関連付けられた MIME 型 (指定しない場合は null にすることができます)
      戻り値:
      サポートされている場合は true、サポートされていない場合は false 
    • getDecodableMimeTypes

      public ListSE<MimeType> getDecodableMimeTypes()
      インターフェースからコピーされた説明: Decoder
      このデコーダーでサポートされている MIME 型のリストを返します。このリストは、考えられるすべてのターゲット要素型に適用されるとは限らないため、このメソッドの呼び出しは通常、canDecode(elementType, null) を介して保護する必要があります。このリストでは、特定の要素型でのみサポートされている MIME 型を除外することもできます。または、Decoder.getDecodableMimeTypes(ResolvableType) を使用してより正確なリストを作成します。
      次で指定:
      インターフェース Decoder<com.google.protobuf.Message>getDecodableMimeTypes 
      戻り値:
      サポートされている MIME 型のリスト
    • decode

      public reactor.core.publisher.Flux<com.google.protobuf.Message> decode(Publisher<DataBuffer> inputStream, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE,ObjectSE> hints)
      インターフェースからコピーされた説明: Decoder
      DataBuffer 入力ストリームを T の Flux にデコードします。
      次で指定:
      インターフェース Decoder<com.google.protobuf.Message>decode 
      パラメーター:
      inputStream - デコードする DataBuffer 入力ストリーム
      targetType - 出力ストリーム内の要素の予想される型。この型は、事前に Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType) メソッドに渡されている必要があり、true を返している必要があります。
      mimeType - 入力ストリームに関連付けられた MIME 型 (オプション)
      hints - デコード方法に関する追加情報
      戻り値:
      デコードされた要素を含む出力ストリーム
    • decode

      public com.google.protobuf.Message decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE,ObjectSE> hints) throws DecodingException
      インターフェースからコピーされた説明: Decoder
      データバッファーを型 T のオブジェクトにデコードします。これは、個別のメッセージ(またはイベント)が完全に集約された形式で個別にデコードおよび処理されるシナリオで役立ちます。
      次で指定:
      インターフェース Decoder<com.google.protobuf.Message>decode 
      パラメーター:
      dataBuffer - デコードする DataBuffer 
      targetType - 予想される出力型
      mimeType - データに関連付けられた MIME 型
      hints - デコード方法に関する追加情報
      戻り値:
      デコードされた値、おそらく null
      例外:
      DecodingException
    • decodeToMono

      public reactor.core.publisher.Mono<com.google.protobuf.Message> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE,ObjectSE> hints)
      インターフェースからコピーされた説明: Decoder
      DataBuffer 入力ストリームを T の Mono にデコードします。
      次で指定:
      インターフェース Decoder<com.google.protobuf.Message>decodeToMono 
      パラメーター:
      inputStream - デコードする DataBuffer 入力ストリーム
      elementType - 出力ストリーム内の要素の予想される型。この型は、事前に Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType) メソッドに渡されている必要があり、true を返している必要があります。
      mimeType - 入力ストリームに関連付けられた MIME 型 (オプション)
      hints - デコード方法に関する追加情報
      戻り値:
      デコードされた要素を持つ出力ストリーム