public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<com.google.protobuf.Message>
com.google.protobuf.Messages を読み書きする HttpMessageConverter。Message Java クラスを生成するには、protoc バイナリをインストールする必要があります。
このコンバーターは、デフォルトで公式の "com.google.protobuf:protobuf-java" ライブラリで "application/x-protobuf" および "text/plain" をサポートします。クラスパス上の次の追加ライブラリのいずれかを使用して、他の形式をサポートできます。
"com.googlecode.protobuf-java-format:protobuf-java-format" サードパーティライブラリを使用した "application/json"、"application/xml"、"text/html" (書き込み専用)"com.google.protobuf:protobuf-java-util" と "application/json" (構成可能なバリアントについては、ProtobufJsonFormatHttpMessageConverter を参照してください)Protobuf 2.6 以上(およびフォーマットには Protobuf Java Format 1.4 以上)が必要です。このコンバーターは、Protobuf 2 ベースの protobuf-java-format が存在しない場合、Protobuf 3 およびそのデフォルトの protobuf-java-util JSON 形式に自動適応します。ただし、Protobuf 3 でより明示的な JSON セットアップを行うには、ProtobufJsonFormatHttpMessageConverter を検討してください。
FormatFactory, JsonFormat, ProtobufJsonFormatHttpMessageConverter| 修飾子と型 | フィールドと説明 |
|---|---|
static CharsetSE | DEFAULT_CHARSET コンバーターが使用するデフォルトの文字セット。 |
static MediaType | PROTOBUFprotobuf application/x-protobuf のメディア型。 |
static StringSE | X_PROTOBUF_MESSAGE_HEADERprotobuf メッセージを含む HTTP ヘッダー。 |
static StringSE | X_PROTOBUF_SCHEMA_HEADERprotobuf スキーマを含む HTTP ヘッダー。 |
logger| コンストラクターと説明 |
|---|
ProtobufHttpMessageConverter() 新しい ProtobufHttpMessageConverter を作成します。 |
ProtobufHttpMessageConverter(com.google.protobuf.ExtensionRegistry extensionRegistry) プロトコルメッセージ拡張を指定するレジストリを使用して、新しい ProtobufHttpMessageConverter を構築します。 |
ProtobufHttpMessageConverter(ExtensionRegistryInitializer registryInitializer) 使用すべきではありません。 Spring Framework 5.1 以降、代わりに ProtobufHttpMessageConverter(ExtensionRegistry) を使用 |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected boolean | canWrite(MediaType mediaType) 指定されたメディア型にサポートされているメディア型のいずれかが含まれている場合、 true を返します。 |
protected MediaType | getDefaultContentType(com.google.protobuf.Message message) 指定された型のデフォルトのコンテンツ型を返します。 |
protected com.google.protobuf.Message | readInternal(ClassSE<? extends com.google.protobuf.Message> clazz, HttpInputMessage inputMessage) 実際のオブジェクトを読み取る抽象テンプレートメソッド。 |
protected boolean | supports(ClassSE<?> clazz) 指定されたクラスがこのコンバーターでサポートされているかどうかを示します。 |
protected void | writeInternal(com.google.protobuf.Message message, HttpOutputMessage outputMessage) 実際の本文を書き込む抽象テンプレートメソッド。 |
addDefaultHeaders, canRead, canRead, canWrite, getContentLength, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writecloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEgetSupportedMediaTypespublic static final CharsetSE DEFAULT_CHARSET
public static final MediaType PROTOBUF
application/x-protobuf のメディア型。public static final StringSE X_PROTOBUF_SCHEMA_HEADER
public ProtobufHttpMessageConverter()
ProtobufHttpMessageConverter を作成します。@DeprecatedSE public ProtobufHttpMessageConverter(@Nullable ExtensionRegistryInitializer registryInitializer)
ProtobufHttpMessageConverter(ExtensionRegistry) を使用してください。ProtobufHttpMessageConverter を作成します。registryInitializer - メッセージ拡張機能の初期化子 public ProtobufHttpMessageConverter(com.google.protobuf.ExtensionRegistry extensionRegistry)
ProtobufHttpMessageConverter を構築します。extensionRegistry - 移入するレジストリ protected boolean supports(ClassSE<?> clazz)
AbstractHttpMessageConverterAbstractHttpMessageConverter<com.google.protobuf.Message> の supports clazz - サポートをテストするクラス true。それ以外の場合は false protected MediaType getDefaultContentType(com.google.protobuf.Message message)
AbstractHttpMessageConverterAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage) が呼び出されたときに呼び出されます。 デフォルトでは、supportedMediaTypes プロパティの最初の要素があれば、それを返します。サブクラスでオーバーライドできます。
AbstractHttpMessageConverter<com.google.protobuf.Message> の getDefaultContentType message - コンテンツ型を返す型 null protected com.google.protobuf.Message readInternal(ClassSE<? extends com.google.protobuf.Message> clazz, HttpInputMessage inputMessage) throws IOExceptionSE, HttpMessageNotReadableException
AbstractHttpMessageConverterAbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage) から呼び出されます。AbstractHttpMessageConverter<com.google.protobuf.Message> の readInternal clazz - 返すオブジェクトの型 inputMessage - 読み込む HTTP 入力メッセージ IOExceptionSE - I/O エラーの場合 HttpMessageNotReadableException - 変換エラーの場合 protected boolean canWrite(@Nullable MediaType mediaType)
AbstractHttpMessageConvertertrue を返します。AbstractHttpMessageConverter<com.google.protobuf.Message> の canWrite mediaType - 書き込むメディア型は、指定しない場合は null にできます。通常、Accept ヘッダーの値。null である場合は、true protected void writeInternal(com.google.protobuf.Message message,
HttpOutputMessage outputMessage)
throws IOExceptionSE,
HttpMessageNotWritableExceptionAbstractHttpMessageConverterAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage) から呼び出されます。AbstractHttpMessageConverter<com.google.protobuf.Message> の writeInternal message - 出力メッセージに書き込むオブジェクト outputMessage - 書き込む HTTP 出力メッセージ IOExceptionSE - I/O エラーの場合 HttpMessageNotWritableException - 変換エラーの場合