/** * Returns a Configurer instance with default components configured, such as a {@link SimpleCommandBus} and * {@link SimpleEventBus}. * * @return Configurer instance for further configuration. */ public static Configurer defaultConfiguration() { return defaultConfiguration(true); }
/** * Returns a Configurer instance with default components configured, such as a {@link SimpleCommandBus} and * {@link SimpleEventBus}, indicating whether to {@code autoLocateConfigurerModules}. * * When {@code autoLocateConfigurerModules} is {@code true}, a ServiceLoader will be used to locate all declared * instances of type {@link ConfigurerModule}. Each of the discovered instances will be invoked, allowing it to * set default values for the configuration. * * @param autoLocateConfigurerModules flag indicating whether ConfigurerModules on the classpath should be * automatically retrieved. Should be set to {@code false} when using an * application container, such as Spring or CDI. * @return Configurer instance for further configuration. */ public static Configurer defaultConfiguration(boolean autoLocateConfigurerModules) { DefaultConfigurer configurer = new DefaultConfigurer(); if(autoLocateConfigurerModules) { ServiceLoader<ConfigurerModule> configurerModuleLoader = ServiceLoader.load(ConfigurerModule.class, configurer.getClass().getClassLoader()); List<ConfigurerModule> configurerModules = new ArrayList<>(); configurerModuleLoader.forEach(configurerModules::add); configurerModules.sort(Comparator.comparingInt(ConfigurerModule::order)); configurerModules.forEach(cm -> cm.configureModule(configurer)); } return configurer; }
@Override public Configurer configureEmbeddedEventStore(Function<Configuration, EventStorageEngine> storageEngineBuilder) { return configureEventStore(c -> { MessageMonitor<Message<?>> monitor = messageMonitorFactoryComponent.get().apply(EmbeddedEventStore.class, "eventStore"); EmbeddedEventStore eventStore = EmbeddedEventStore.builder() .storageEngine(storageEngineBuilder.apply(c)) .messageMonitor(monitor) .build(); c.onShutdown(eventStore::shutDown); return eventStore; }); }
@Override public Configuration buildConfiguration() { if (!initialized) { verifyIdentifierFactory(); prepareModules(); invokeInitHandlers(); } return config; }
@Override public Configuration buildConfiguration() { if (!initialized) { verifyIdentifierFactory(); boolean missingEventProcessingConfiguration = modules.stream() .noneMatch(m -> m.unwrap() instanceof EventProcessingConfiguration); if (missingEventProcessingConfiguration) { registerModule(new EventProcessingConfiguration()); } prepareModules(); invokeInitHandlers(); } return config; }
return new DefaultConfigurer() .registerComponent(EntityManagerProvider.class, c -> entityManagerProvider) .registerComponent(TransactionManager.class, c -> transactionManager) .configureEmbeddedEventStore(
@Override public void start() { invokeStartHandlers(); }
@Override public void shutdown() { invokeShutdownHandlers(); }
/** * Returns a Configurer instance which has JPA versions of building blocks configured, such as a JPA based Event * Store (see {@link JpaEventStorageEngine}), a {@link JpaTokenStore} and {@link JpaSagaStore}. * <br> * This configuration should be used with an entity manager running without JTA transaction. If you are using a * entity manager in JTA mode, please provide the corresponding {@link TransactionManager} in the * {@link DefaultConfigurer#jpaConfiguration(EntityManagerProvider, TransactionManager)} method. * * @param entityManagerProvider The instance that provides access to the JPA EntityManager. * @return A Configurer instance for further configuration. */ public static Configurer jpaConfiguration(EntityManagerProvider entityManagerProvider) { return jpaConfiguration(entityManagerProvider, NoTransactionManager.INSTANCE); }
@Override public Configuration buildConfiguration() { if (!initialized) { verifyIdentifierFactory(); prepareModules(); invokeInitHandlers(); } return config; }
return new DefaultConfigurer() .registerComponent(EntityManagerProvider.class, c -> entityManagerProvider) .registerComponent(TransactionManager.class, c -> transactionManager) .configureEmbeddedEventStore(c -> new JpaEventStorageEngine(
@Override public void start() { invokeStartHandlers(); }
@Override public void shutdown() { invokeShutdownHandlers(); }
/** * Returns a Configurer instance which has JPA versions of building blocks configured, such as a JPA based Event * Store (see {@link JpaEventStorageEngine}), a {@link JpaTokenStore} and {@link JpaSagaStore}. * <br> * This configuration should be used with an entity manager running without JTA transaction. If you are using a * entity manager in JTA mode, please provide the corresponding {@link TransactionManager} in the * {@link DefaultConfigurer#jpaConfiguration(EntityManagerProvider, TransactionManager)} method. * * @param entityManagerProvider The instance that provides access to the JPA EntityManager. * @return A Configurer instance for further configuration. */ public static Configurer jpaConfiguration(EntityManagerProvider entityManagerProvider) { return jpaConfiguration(entityManagerProvider, NoTransactionManager.INSTANCE); }
genericBeanDefinition(QueryHandlerSubscriber.class).getBeanDefinition()); Configurer configurer = DefaultConfigurer.defaultConfiguration(false);
return new DefaultConfigurer() .registerComponent(EntityManagerProvider.class, c -> entityManagerProvider) .registerComponent(TransactionManager.class, c -> transactionManager) .configureEmbeddedEventStore(
@Override public Configurer configureEmbeddedEventStore(Function<Configuration, EventStorageEngine> storageEngineBuilder) { return configureEventStore(c -> { MessageMonitor<Message<?>> monitor = messageMonitorFactoryComponent.get().apply(EmbeddedEventStore.class, "eventStore"); EmbeddedEventStore eventStore = new EmbeddedEventStore(storageEngineBuilder.apply(c), monitor); c.onShutdown(eventStore::shutDown); return eventStore; }); }
@Override public void start() { invokeStartHandlers(); }
@Override public void shutdown() { invokeShutdownHandlers(); }
/** * Returns a Configurer instance which has JPA versions of building blocks configured, such as a JPA based Event * Store (see {@link JpaEventStorageEngine}), a {@link JpaTokenStore} and {@link JpaSagaStore}. * <br> * This configuration should be used with an entity manager running without JTA transaction. If you are using a * entity manager in JTA mode, please provide the corresponding {@link TransactionManager} in the * {@link DefaultConfigurer#jpaConfiguration(EntityManagerProvider, TransactionManager)} method. * * @param entityManagerProvider The instance that provides access to the JPA EntityManager. * @return A Configurer instance for further configuration. */ public static Configurer jpaConfiguration(EntityManagerProvider entityManagerProvider) { return jpaConfiguration(entityManagerProvider, NoTransactionManager.INSTANCE); }