Class JdbcSagaStore.Builder

java.lang.Object
org.axonframework.modelling.saga.repository.jdbc.JdbcSagaStore.Builder
Enclosing class:
JdbcSagaStore

public static class JdbcSagaStore.Builder extends Object
Builder class to instantiate a JdbcSagaStore.

The SagaSqlSchema is defaulted to an GenericSagaSqlSchema.

The ConnectionProvider and Serializer are hard requirements and as such should be provided.

You can choose to provide a DataSource instead of a ConnectionProvider, but in that case the used ConnectionProvider will be a DataSourceConnectionProvider wrapped by a UnitOfWorkAwareConnectionProviderWrapper.

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • connectionProvider

      public JdbcSagaStore.Builder connectionProvider(org.axonframework.common.jdbc.ConnectionProvider connectionProvider)
      Sets the ConnectionProvider which provides access to a JDBC connection.
      Parameters:
      connectionProvider - a ConnectionProvider which provides access to a JDBC connection
      Returns:
      the current Builder instance, for fluent interfacing
    • dataSource

      public JdbcSagaStore.Builder dataSource(DataSource dataSource)
      Sets the ConnectionProvider by providing a DataSource. The given dataSource in turn will added to a DataSourceConnectionProvider, which is wrapped by a UnitOfWorkAwareConnectionProviderWrapper. This will provide access to a JDBC connection for this SagaStore implementation.
      Parameters:
      dataSource - a DataSource which ends up in a DataSourceConnectionProvider, wrapped by a UnitOfWorkAwareConnectionProviderWrapper as the ConnectionProvider for this SagaStore implementation
      Returns:
      the current Builder instance, for fluent interfacing
    • sqlSchema

      public JdbcSagaStore.Builder sqlSchema(SagaSqlSchema sqlSchema)
      Sets the SagaSqlSchema defining the SQL operations to execute for this SagaStore implementation. Defaults to a GenericSagaSqlSchema.
      Parameters:
      sqlSchema - the SagaSqlSchema defining the SQL operations to execute for this SagaStore implementation
      Returns:
      the current Builder instance, for fluent interfacing
    • serializer

      public JdbcSagaStore.Builder serializer(org.axonframework.serialization.Serializer serializer)
      Sets the Serializer used to de-/serialize a Saga instance.
      Parameters:
      serializer - a Serializer used to de-/serialize a Saga instance
      Returns:
      the current Builder instance, for fluent interfacing
    • build

      public JdbcSagaStore build()
      Initializes a JdbcSagaStore as specified through this Builder.
      Returns:
      a JdbcSagaStore as specified through this Builder
    • validate

      protected void validate() throws org.axonframework.common.AxonConfigurationException
      Validates whether the fields contained in this Builder are set accordingly.
      Throws:
      org.axonframework.common.AxonConfigurationException - if one field is asserted to be incorrect according to the Builder's specifications