Class LegacyJpaSagaStoreAutoConfiguration

java.lang.Object
org.axonframework.extension.springboot.autoconfig.LegacyJpaSagaStoreAutoConfiguration

@AutoConfiguration(afterName={"org.axonframework.extension.springboot.autoconfig.JpaAutoConfiguration","org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration","org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfiguration"}) @ConditionalOnClass({JpaSagaStore.class,jakarta.persistence.EntityManagerFactory.class}) @ConditionalOnBean(jakarta.persistence.EntityManagerFactory.class) @Import(org.axonframework.extension.springboot.autoconfig.LegacySagaJpaEntityRegistrar.class) public class LegacyJpaSagaStoreAutoConfiguration extends Object
Autoconfiguration class that registers a JpaSagaStore when JPA infrastructure is available, ported from Axon Framework 4's JPA saga store wiring onto axon-legacy's JpaSagaStore builder.

Registers the SagaEntry and AssociationValueEntry entities defined in org.axonframework.modelling.saga.repository.jpa with the persistence unit via LegacySagaJpaEntityRegistrar, so they are picked up even though they live outside the application's own base packages.

The sagaStore(GeneralConverter, EntityManagerProvider) bean is Lazy: JpaSagaStore's constructor eagerly registers named queries against the EntityManager, which requires a fully initialized persistence unit. Axon Framework 4 deferred this bean the same way for the same reason.

Runs after org.axonframework.extension.springboot.autoconfig.JpaAutoConfiguration so the EntityManagerProvider bean it provides is available, and before LegacySagaAutoConfiguration so this bean is visible when that class's in-memory fallback checks for an existing SagaStore. The ordering reference to JpaAutoConfiguration uses AutoConfiguration.afterName() rather than AutoConfiguration.after() so that axon-legacy carries no compile-time dependency on the axon-spring-boot-autoconfigure module.

Since:
5.4.0
Author:
Mateusz Nowak
  • Constructor Details

    • LegacyJpaSagaStoreAutoConfiguration

      public LegacyJpaSagaStoreAutoConfiguration()
  • Method Details

    • sagaStore

      @Lazy @Bean @ConditionalOnMissingBean(SagaStore.class) public JpaSagaStore sagaStore(GeneralConverter converter, EntityManagerProvider entityManagerProvider)
      Provides a JpaSagaStore using the given converter and entityManagerProvider.

      Named sagaStore, matching Axon Framework 4's bean name, so a manually declared SagaStore bean of that same name (rather than type) still triggers ConditionalOnMissingBean's type-based check correctly since SagaStore is the condition target, not the bean name.

      Parameters:
      converter - the converter used to convert a saga instance to and from its serialized form
      entityManagerProvider - the provider of the EntityManager used to access the underlying database
      Returns:
      a JPA-backed SagaStore