クラス JsonMessageRowMapper

java.lang.ObjectSE
org.springframework.integration.jdbc.store.channel.JsonMessageRowMapper
実装済みのインターフェース一覧:
RowMapper<Message<?>>

public class JsonMessageRowMapper extends ObjectSE implements RowMapper<Message<?>>
データベースに保存されている JSON 形式から Message オブジェクトを逆直列化する RowMapper 実装。

このマッパーは JsonChannelMessageStorePreparedStatementSetter と連携して、Spring Integration の JDBC チャネルメッセージストアの JSON 直列化を提供します。

Java 直列化を使用するデフォルトの MessageRowMapper とは異なり、この実装では JSON を使用して MESSAGE_CONTENT 列からのメッセージ文字列を逆直列化します。

基盤となる JsonObjectMapper は、セキュリティの脆弱性を防ぐために、すべてのデ直列化されたクラスを信頼できるパッケージリストに対して検証します。

使用例:

&#64;Bean
JdbcChannelMessageStore messageStore(DataSource dataSource) {
    JdbcChannelMessageStore store = new JdbcChannelMessageStore(dataSource);
    store.setChannelMessageStoreQueryProvider(new PostgresChannelMessageStoreQueryProvider());

    // Enable JSON serialization
    store.setPreparedStatementSetter(
        new JsonChannelMessageStorePreparedStatementSetter());
    store.setMessageRowMapper(
        new JsonMessageRowMapper("com.example"));

    return store;
}
導入:
7.0
作成者:
Yoobin Yoon
  • コンストラクターの詳細

    • JsonMessageRowMapper

      public JsonMessageRowMapper(StringSE @Nullable ... trustedPackages)
      デシリアライズ用の信頼できるパッケージを追加して、新しい JsonMessageRowMapper を作成します。

      提供されたパッケージはデフォルトの信頼済みパッケージに追加され、セキュリティを維持しながらカスタムペイロード型のデシリアライズを可能にします。パッケージが提供されない場合は、デフォルトの信頼済みパッケージのみが使用されます。

      パラメーター:
      trustedPackages - デシリアライズ時に信頼する追加パッケージ。null を指定するか、空にするとデフォルトのパッケージのみが使用されます。
    • JsonMessageRowMapper

      public JsonMessageRowMapper(JsonObjectMapper<?,?> jsonObjectMapper)
      カスタム JsonObjectMapper を使用して新しい JsonMessageRowMapper を作成します。

      このコンストラクターを使用すると、JSON デシリアライゼーション構成を完全に制御できます。

      注意 : 一貫した直列化とデ直列化を実現するには、対応する JsonChannelMessageStorePreparedStatementSetter でも同じ JsonObjectMapper 構成を使用する必要があります。

      パラメーター:
      jsonObjectMapper - JSON デシリアライゼーションに使用する JsonObjectMapper
  • 方法の詳細