クラス ProtobufDecoder
java.lang.ObjectSE
org.springframework.http.codec.protobuf.ProtobufCodecSupport
org.springframework.http.codec.protobuf.ProtobufDecoder
- 実装されているすべてのインターフェース:
- Decoder<com.google.protobuf.Message>
public class ProtobufDecoder
extends ProtobufCodecSupport
implements Decoder<com.google.protobuf.Message>
Google プロトコルバッファを使用して 
Message を読み取る Decoder。decode(Publisher, ResolvableType, MimeType, Map) を介してデシリアライズされた Flux は、各メッセージのサイズがメッセージ自体の前に指定された、区切られたProtobuf メッセージを使用することが想定されています。decodeToMono(Publisher, ResolvableType, MimeType, Map) を介してデシリアライズされた単一の値は、通常の Protobuf メッセージ形式 (メッセージの前にサイズが付加されない) を使用することが想定されています。
Protobuf メッセージのデフォルトインスタンスは空のバイト配列を生成するため、ネットワーク経由で送信される Mono.just(Msg.getDefaultInstance()) は空の Mono としてデシリアライズされます。
Message Java クラスを生成するには、protoc バイナリをインストールする必要があります。
 このデコーダーは Protobuf 3 以降を必要とし、公式 "com.google.protobuf:protobuf-java" ライブラリで "application/x-protobuf" および "application/octet-stream" をサポートします。
- 導入:
- 5.1
- 作成者:
- Sebastien Deleuze
- 関連事項:
- フィールドのサマリーフィールド
- コンストラクターの概要コンストラクターコンストラクター説明新しい- ProtobufDecoderを作成します。- ProtobufDecoder- (com.google.protobuf.ExtensionRegistry extensionRegistry) メッセージ拡張の登録を許可する初期化子を使用して、新しい- ProtobufDecoderを作成します。
- メソッドのサマリー修飾子と型メソッド説明- boolean- canDecode- (ResolvableType elementType, MimeType mimeType) デコーダーが特定のターゲット要素型とソースストリームの MIME 型をサポートするかどうか。- reactor.core.publisher.Flux<com.google.protobuf.Message>- decode- (Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, MapSE<StringSE, - ObjectSE> hints) - DataBuffer入力ストリームを- Tの Flux にデコードします。- com.google.protobuf.Message- decode- (DataBuffer dataBuffer, ResolvableType targetType, MimeType mimeType, MapSE<StringSE, - ObjectSE> hints) データバッファを型 T のオブジェクトにデコードします。- reactor.core.publisher.Mono<com.google.protobuf.Message>- decodeToMono- (Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, MapSE<StringSE, - ObjectSE> hints) - DataBuffer入力ストリームを- Tの Mono にデコードします。このデコーダーでサポートされている MIME 型のリストを返します。- int- configuredメッセージのサイズ制限を返します。- void- setMaxMessageSize- (int maxMessageSize) メッセージごとに許可される最大サイズ。- クラス org.springframework.http.codec.protobuf.ProtobufCodecSupport から継承されたメソッド- getMimeTypes, supportsMimeType- クラス java.lang.ObjectSE から継承されたメソッド- clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE- インターフェース org.springframework.core.codec.Decoder から継承されたメソッド- getDecodableMimeTypes
- フィールドの詳細- DEFAULT_MESSAGE_MAX_SIZEprotected static final int DEFAULT_MESSAGE_MAX_SIZEメッセージを集約するためのデフォルトの最大サイズ。- 関連事項:
 
 
- コンストラクターの詳細- ProtobufDecoderpublic ProtobufDecoder()新しい- ProtobufDecoderを作成します。
- ProtobufDecoderpublic ProtobufDecoder- (com.google.protobuf.ExtensionRegistry extensionRegistry) メッセージ拡張の登録を許可する初期化子を使用して、新しい- ProtobufDecoderを作成します。- パラメーター:
- extensionRegistry- メッセージ拡張レジストリ
 
 
- メソッドの詳細- setMaxMessageSizepublic void setMaxMessageSize- (int maxMessageSize) メッセージごとに許可される最大サイズ。- デフォルトでは、これは 256K に設定されています。 - パラメーター:
- maxMessageSize- メッセージごとの最大サイズ、または無制限の場合は -1
 
- getMaxMessageSizepublic int getMaxMessageSize()- configuredメッセージのサイズ制限を返します。- 導入:
- 5.1.11
 
- canDecodeインターフェースからコピーされた説明:- Decoderデコーダーが特定のターゲット要素型とソースストリームの MIME 型をサポートするかどうか。
- decodepublic reactor.core.publisher.Flux<com.google.protobuf.Message> decode- (Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE, - ObjectSE> hints) インターフェースからコピーされた説明:- Decoder- DataBuffer入力ストリームを- Tの Flux にデコードします。- 次で指定:
-  インターフェース Decoder<com.google.protobuf.Message>のdecode
- パラメーター:
- inputStream- デコードする- DataBuffer入力ストリーム
- elementType- 出力ストリーム内の要素の予想される型。この型は、事前に- Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)メソッドに渡されている必要があり、- trueを返している必要があります。
- mimeType- 入力ストリームに関連付けられた MIME 型 (オプション)
- hints- デコード方法に関する追加情報
- 戻り値:
- デコードされた要素を含む出力ストリーム
 
- decodeToMonopublic 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- デコード方法に関する追加情報
- 戻り値:
- デコードされた要素を持つ出力ストリーム
 
- decodepublic 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
 
- getDecodableMimeTypesインターフェースからコピーされた説明:- Decoderこのデコーダーでサポートされている MIME 型のリストを返します。このリストは、考えられるすべてのターゲット要素型に適用されるとは限らないため、このメソッドの呼び出しは通常、- canDecode(elementType, null)を介して保護する必要があります。このリストでは、特定の要素型でのみサポートされている MIME 型を除外することもできます。または、- Decoder.getDecodableMimeTypes(ResolvableType)を使用してより正確なリストを作成します。- 次で指定:
-  インターフェース Decoder<com.google.protobuf.Message>のgetDecodableMimeTypes
- 戻り値:
- サポートされている MIME 型のリスト