public class DefaultConfigurer extends Object implements Configurer
Using defaultConfiguration(), you will get a Configurer instance with default components configured. You
will need to register your Aggregates (using configureAggregate(AggregateConfiguration) and provide a
repository implementation for each of them, or if you wish to use event sourcing, register your aggregates through
Configurer.configureAggregate(Class) and configure an Event Store (Configurer.configureEventStore(Function) or
configureEmbeddedEventStore(Function)).
Use buildConfiguration() to build the configuration, which provides access to the configured building
blocks, such as the CommandBus and EventBus.
Note that this Configurer implementation is not thread-safe.
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultConfigurer()
Initialize the Configurer.
|
| Modifier and Type | Method and Description |
|---|---|
Configuration |
buildConfiguration()
Returns the completely initialized Configuration built using this configurer.
|
<A> Configurer |
configureAggregate(AggregateConfiguration<A> aggregateConfiguration)
Configures an Aggregate in this configuration based on the given
aggregateConfiguration. |
Configurer |
configureCorrelationDataProviders(Function<Configuration,List<CorrelationDataProvider>> correlationDataProviderBuilder)
Configures the CorrelationDataProviders that Message processing components should use to attach correlation data
to outgoing messages.
|
Configurer |
configureEmbeddedEventStore(Function<Configuration,EventStorageEngine> storageEngineBuilder)
Configures an Embedded Event Store which uses the given Event Storage Engine to store its events.
|
Configurer |
configureEventSerializer(Function<Configuration,Serializer> eventSerializerBuilder)
Configures the given event Serializer to use in this configuration.
|
Configurer |
configureMessageMonitor(Class<?> componentType,
MessageMonitorFactory messageMonitorFactory)
Configures the factory to create the Message Monitor for the Message processing components in this configuration
that match the given componentType, unless more specific configuration based on both type and name is available.
|
Configurer |
configureMessageMonitor(Class<?> componentType,
String componentName,
MessageMonitorFactory messageMonitorFactory)
Configures the factory create the Message Monitor for those Message processing components in this configuration
that match the given class and name.
|
Configurer |
configureMessageMonitor(Function<Configuration,BiFunction<Class<?>,String,MessageMonitor<Message<?>>>> builder)
Configures the Message Monitor to use for the Message processing components in this configuration, unless more
specific configuration based on the component's type, or type and name is available.
|
protected CommandBus |
defaultCommandBus(Configuration config)
Provides the default CommandBus implementation.
|
protected CommandGateway |
defaultCommandGateway(Configuration config)
Returns a
DefaultCommandGateway that will use the configuration's CommandBus to dispatch
commands. |
static Configurer |
defaultConfiguration()
Returns a Configurer instance with default components configured, such as a
SimpleCommandBus and
SimpleEventBus. |
protected EventBus |
defaultEventBus(Configuration config)
Provides the default EventBus implementation.
|
protected ParameterResolverFactory |
defaultParameterResolverFactory(Configuration config)
Provides the default ParameterResolverFactory.
|
protected QueryBus |
defaultQueryBus(Configuration config)
Provides the default QueryBus implementations.
|
protected QueryGateway |
defaultQueryGateway(Configuration config)
Returns a
DefaultQueryGateway that will use the configuration's QueryBus to dispatch queries. |
protected ResourceInjector |
defaultResourceInjector(Configuration config)
Returns a
ConfigurationResourceInjector that injects resources defined in the given config
Configuration. |
protected Serializer |
defaultSerializer(Configuration config)
Provides the default Serializer implementation.
|
Map<Class<?>,Component<?>> |
getComponents()
Returns a map of all registered components in this configuration.
|
protected Configuration |
getConfig()
Returns the current Configuration object being built by this Configurer, without initializing it.
|
protected void |
invokeInitHandlers()
Calls all registered init handlers.
|
protected void |
invokeShutdownHandlers()
Invokes all registered shutdown handlers.
|
protected void |
invokeStartHandlers()
Invokes all registered start handlers.
|
static Configurer |
jpaConfiguration(EntityManagerProvider entityManagerProvider)
Returns a Configurer instance which has JPA versions of building blocks configured, such as a JPA based Event
Store (see
JpaEventStorageEngine), a JpaTokenStore and JpaSagaStore. |
static Configurer |
jpaConfiguration(EntityManagerProvider entityManagerProvider,
TransactionManager transactionManager)
Returns a Configurer instance which has JPA versions of building blocks configured, such as a JPA based Event
Store (see
JpaEventStorageEngine), a JpaTokenStore and JpaSagaStore. |
Configurer |
registerCommandHandler(Function<Configuration,Object> annotatedCommandHandlerBuilder)
Registers a command handler bean with this configuration.
|
<C> Configurer |
registerComponent(Class<C> componentType,
Function<Configuration,? extends C> componentBuilder)
Registers a component which should be made available to other components or modules in this Configuration.
|
Configurer |
registerEventUpcaster(Function<Configuration,EventUpcaster> upcasterBuilder)
Registers an upcaster to be used to upcast Events to a newer version
|
Configurer |
registerModule(ModuleConfiguration module)
Registers an Axon module with this configuration.
|
Configurer |
registerQueryHandler(Function<Configuration,Object> annotatedQueryHandlerBuilder)
Registers a query handler bean with this configuration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconfigureAggregate, configureCommandBus, configureEventBus, configureEventStore, configureMessageMonitor, configureMessageMonitor, configureQueryBus, configureResourceInjector, configureSerializer, configureTransactionManager, startpublic static Configurer defaultConfiguration()
SimpleCommandBus and
SimpleEventBus.public static Configurer jpaConfiguration(EntityManagerProvider entityManagerProvider, TransactionManager transactionManager)
JpaEventStorageEngine), a JpaTokenStore and JpaSagaStore.
entityManagerProvider - The instance that provides access to the JPA EntityManager.transactionManager - TransactionManager to be used for accessing the entity manager.public static Configurer jpaConfiguration(EntityManagerProvider entityManagerProvider)
JpaEventStorageEngine), a JpaTokenStore and JpaSagaStore.
TransactionManager in the
jpaConfiguration(EntityManagerProvider, TransactionManager) method.entityManagerProvider - The instance that provides access to the JPA EntityManager.protected CommandGateway defaultCommandGateway(Configuration config)
DefaultCommandGateway that will use the configuration's CommandBus to dispatch
commands.config - The configuration that supplies the command bus.protected QueryGateway defaultQueryGateway(Configuration config)
DefaultQueryGateway that will use the configuration's QueryBus to dispatch queries.config - The configuration that supplies the query bus.protected QueryBus defaultQueryBus(Configuration config)
config - The configuration based on which the component is initialized.protected ParameterResolverFactory defaultParameterResolverFactory(Configuration config)
config - The configuration based on which the component is initialized.protected CommandBus defaultCommandBus(Configuration config)
config - The configuration based on which the component is initialized.protected ResourceInjector defaultResourceInjector(Configuration config)
ConfigurationResourceInjector that injects resources defined in the given config
Configuration.config - The configuration that supplies registered components.protected EventBus defaultEventBus(Configuration config)
config - The configuration based on which the component is initialized.protected Serializer defaultSerializer(Configuration config)
config - The configuration based on which the component is initialized.public Configurer registerEventUpcaster(Function<Configuration,EventUpcaster> upcasterBuilder)
ConfigurerregisterEventUpcaster in interface ConfigurerupcasterBuilder - The function that returns an EventUpcaster based on the configurationpublic Configurer configureMessageMonitor(Function<Configuration,BiFunction<Class<?>,String,MessageMonitor<Message<?>>>> builder)
ConfigurerconfigureMessageMonitor in interface Configurerbuilder - The MessageMonitor builder functionpublic Configurer configureMessageMonitor(Class<?> componentType, MessageMonitorFactory messageMonitorFactory)
Configurer
A component matches componentType if componentType is assignable from the component's class. If a component matches multiple types, and the types derive from each other, the configuration from the most derived type is used. If the matching types do not derive from each other, the result is unspecified.
For example: in case a monitor is configured for CommandBus and another monitor is configured for
SimpleCommandBus), components of type
AsynchronousCommandBus will use the monitor
configured for the SimpleCommandBus.
A component's name matches componentName if they are identical; i.e. they are compared case sensitively.
configureMessageMonitor in interface ConfigurercomponentType - The declared type of the componentmessageMonitorFactory - The factory to usepublic Configurer configureMessageMonitor(Class<?> componentType, String componentName, MessageMonitorFactory messageMonitorFactory)
Configurer
A component matches componentType if componentType is assignable from the component's class. If a component matches multiple types, and the types derive from each other, the configuration from the most derived type is used. If the matching types do not derive from each other, the result is unspecified.
For example: in case a monitor is configured for CommandBus and another monitor is configured for
SimpleCommandBus), components of type
AsynchronousCommandBus will use the monitor
configured for the SimpleCommandBus.
A component's name matches componentName if they are identical; i.e. they are compared case sensitively.
configureMessageMonitor in interface ConfigurercomponentType - The declared type of the componentcomponentName - The name of the componentmessageMonitorFactory - The factory to usepublic Configurer configureCorrelationDataProviders(Function<Configuration,List<CorrelationDataProvider>> correlationDataProviderBuilder)
ConfigurerconfigureCorrelationDataProviders in interface ConfigurercorrelationDataProviderBuilder - the builder function returning the CorrelationDataProvider listpublic Configurer registerModule(ModuleConfiguration module)
ConfigurerTypically, modules are registered for Event Handling components or Sagas.
registerModule in interface Configurermodule - The module to registerSagaConfiguration,
EventHandlingConfigurationpublic Configurer registerCommandHandler(Function<Configuration,Object> annotatedCommandHandlerBuilder)
ConfigurerThe builder function receives the Configuration as input, and is expected to return a fully initialized instance of the command handler bean.
registerCommandHandler in interface ConfigurerannotatedCommandHandlerBuilder - The builder function of the Command Handler beanpublic Configurer registerQueryHandler(Function<Configuration,Object> annotatedQueryHandlerBuilder)
ConfigurerThe builder function receives the Configuration as input, and is expected to return a fully initialized instance of the query handler bean.
registerQueryHandler in interface ConfigurerannotatedQueryHandlerBuilder - The builder function of the Query Handler beanpublic <C> Configurer registerComponent(Class<C> componentType, Function<Configuration,? extends C> componentBuilder)
Configurer
Where possible, it is recommended to use the explicit configure... and register... methods.
registerComponent in interface ConfigurerC - The type of componentcomponentType - The declared type of the component, typically an interfacecomponentBuilder - The builder function of this componentpublic Configurer configureEmbeddedEventStore(Function<Configuration,EventStorageEngine> storageEngineBuilder)
ConfigurerEventStorageEngine
instance.configureEmbeddedEventStore in interface ConfigurerstorageEngineBuilder - The builder function for the EventStorageEnginepublic Configurer configureEventSerializer(Function<Configuration,Serializer> eventSerializerBuilder)
ConfigurerSerializer instance.
This Serializer is specifically used to serialize events and their metadata.configureEventSerializer in interface ConfigurereventSerializerBuilder - The builder function for the Serializer.public <A> Configurer configureAggregate(AggregateConfiguration<A> aggregateConfiguration)
ConfigureraggregateConfiguration. This method
allows for more fine-grained configuration compared to the Configurer.configureAggregate(Class) method.configureAggregate in interface ConfigurerA - The type of aggregate the configuration is foraggregateConfiguration - The instance describing the configuration of an AggregateAggregateConfigurerpublic Configuration buildConfiguration()
ConfigurerbuildConfiguration in interface Configurerprotected void invokeInitHandlers()
protected void invokeStartHandlers()
protected void invokeShutdownHandlers()
protected Configuration getConfig()
public Map<Class<?>,Component<?>> getComponents()
Component.get() may prematurely initialize a component.Copyright © 2010–2017. All rights reserved.