クラス EmbeddedHeadersJsonMessageMapper

java.lang.ObjectSE
org.springframework.integration.support.json.EmbeddedHeadersJsonMessageMapper
実装済みのインターフェース一覧:
BytesMessageMapper, InboundMessageMapper<byte[]>, OutboundMessageMapper<byte[]>

public class EmbeddedHeadersJsonMessageMapper extends ObjectSE implements BytesMessageMapper
For outbound messages, uses a message-aware Jackson JSON mapper to render the message as JSON. For messages with byte[] payloads, if rendered as JSON, Jackson performs Base64 conversion on the bytes. If payload is byte[] and the rawBytes property is true (default), the result has the form [headersLen][headers][payloadLen][payload]; with the headers rendered in JSON and the payload unchanged. Otherwise, the message is fully serialized and deserialized with Jackson JSON mapper.

デフォルトでは、標準の MessageHeaders.IDMessageHeaders.TIMESTAMPMessageHeaders.CONTENT_TYPE ヘッダー以外のヘッダーは埋め込みません。受信側で復元するために、これらのヘッダーが存在する場合は必ず埋め込みます。埋め込む追加ヘッダーを指定するための簡単なパターンを提供します。

予想される形式が検出されず、変換中にエラーも発生しない場合は、メッセージのペイロードは元の byte[] になります。

IMPORTANT

デフォルトの JSON マッパーは、特定のパッケージ内のクラスのみをデ直列化します。

"java.util",
"java.lang",
"org.springframework.messaging.support",
"org.springframework.integration.support",
"org.springframework.integration.message",
"org.springframework.integration.store",
"org.springframework.integration.history",
        "org.springframework.integration.handler"

さらにパッケージを追加するには、JacksonMessagingUtils.messagingAwareMapper(String...) を使用して JSON マッパーを作成します。

このように構成された JSON マッパーの提供を可能にするコンストラクターが提供されます。

導入:
7.0
作成者:
Jooyoung Pyoung, Glenn Renfro
  • フィールドの詳細

    • logger

      protected final org.apache.commons.logging.Log logger
  • コンストラクターの詳細

    • EmbeddedHeadersJsonMessageMapper

      public EmbeddedHeadersJsonMessageMapper()
      標準の MessageHeaders.IDMessageHeaders.TIMESTAMPMessageHeaders.CONTENT_TYPE 以外のヘッダーを埋め込まないインスタンスを構築し、デフォルトの JSON オブジェクトマッパーを使用します。
    • EmbeddedHeadersJsonMessageMapper

      public EmbeddedHeadersJsonMessageMapper(StringSE... headerPatterns)
      Construct an instance that embeds headers matching the supplied patterns; use the default JSON object mapper. Always embed the standard MessageHeaders.ID, MessageHeaders.TIMESTAMP and MessageHeaders.CONTENT_TYPE headers (when present) regardless of the supplied patterns.
      パラメーター:
      headerPatterns - パターン。
      関連事項:
    • EmbeddedHeadersJsonMessageMapper

      public EmbeddedHeadersJsonMessageMapper(tools.jackson.databind.json.JsonMapper jsonMapper)
      標準の MessageHeaders.IDMessageHeaders.TIMESTAMPMessageHeaders.CONTENT_TYPE 以外のヘッダーを埋め込まないインスタンスを構築します。提供されている JSON オブジェクトマッパーを使用します。
      パラメーター:
      jsonMapper - JSON マッパー。
    • EmbeddedHeadersJsonMessageMapper

      public EmbeddedHeadersJsonMessageMapper(tools.jackson.databind.json.JsonMapper jsonMapper, StringSE... headerPatterns)
      Construct an instance that embeds headers matching the supplied patterns; use the supplied JSON object mapper. Always embed the standard MessageHeaders.ID, MessageHeaders.TIMESTAMP and MessageHeaders.CONTENT_TYPE headers (when present) regardless of the supplied patterns.
      パラメーター:
      jsonMapper - JSON マッパー。
      headerPatterns - パターン。
  • 方法の詳細

    • setRawBytes

      public void setRawBytes(boolean rawBytes)
      byte[] ペイロードを持つメッセージの場合、JSON としてレンダリングされると、Jackson はバイトに対して Base64 変換を実行します。このプロパティが true (デフォルト) の場合、結果は [headersLen][headers][payloadLen][payload] の形式になり、ヘッダーは JSON でレンダリングされ、ペイロードは変更されません。バイトを base64 としてレンダリングするには、false に設定します。
      パラメーター:
      rawBytes - base64 としてエンコードする場合は false。
    • setCaseSensitive

      public void setCaseSensitive(boolean caseSensitive)
      ヘッダー名パターンの大文字と小文字を区別して一致させるには、true に設定します。デフォルトは false です。
      パラメーター:
      caseSensitive - 大文字と小文字を区別する場合は true です。
    • getHeaderPatterns

      public CollectionSE<StringSE> getHeaderPatterns()
    • fromMessage

      public byte[] fromMessage(Message<?> message)
      次で指定:
      インターフェース BytesMessageMapper 内の fromMessage 
      次で指定:
      インターフェース OutboundMessageMapper<byte[]> 内の fromMessage 
    • toMessage

      public Message<?> toMessage(byte[] bytes, @Nullable MapSE<StringSE,ObjectSE> headers)
      インターフェースからコピーされた説明: InboundMessageMapper
      提供されたオブジェクトを Message に変換し、必要に応じて提供されたヘッダーを提供します。
      次で指定:
      インターフェース BytesMessageMapper 内の toMessage 
      次で指定:
      インターフェース InboundMessageMapper<byte[]> 内の toMessage 
      パラメーター:
      bytes - メッセージペイロードまたはその他の変換ロジックのオブジェクト
      headers - メッセージを作成するための追加ヘッダー。null にすることができます
      戻り値:
      マッピングの結果としてのメッセージ