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.
|
Configurer |
configureMessageSerializer(Function<Configuration,Serializer> messageSerializerBuilder)
Configures the given event Serializer to use in this configuration.
|
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 . |
static Configurer |
defaultConfiguration(boolean autoLocateConfigurerModules)
Returns a Configurer instance with default components configured, such as a
SimpleCommandBus and
SimpleEventBus , indicating whether to autoLocateConfigurerModules . |
protected DeadlineManager |
defaultDeadlineManager(Configuration config)
Provides the default
DeadlineManager implementation. |
protected EventBus |
defaultEventBus(Configuration config)
Provides the default EventBus implementation.
|
protected HandlerDefinition |
defaultHandlerDefinition(Class<?> inspectedClass)
Provides the default HandlerDefinition.
|
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 QueryUpdateEmitter |
defaultQueryUpdateEmitter(Configuration config)
Provides the default QueryUpdateEmitter implementation.
|
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.
|
EventProcessingConfigurer |
eventProcessing()
Retrievee the
EventProcessingConfigurer registered as a module with this Configurer. |
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 . |
protected void |
prepareModules()
Prepare the registered modules for initialization.
|
Configurer |
registerCommandHandler(int phase,
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 |
registerHandlerDefinition(BiFunction<Configuration,Class,HandlerDefinition> handlerDefinitionClass)
Registers the definition of a Handler class.
|
Configurer |
registerModule(ModuleConfiguration module)
Registers an Axon module with this configuration.
|
Configurer |
registerQueryHandler(int phase,
Function<Configuration,Object> annotatedQueryHandlerBuilder)
Registers a query handler bean with this configuration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configureAggregate, configureCommandBus, configureEventBus, configureEventStore, configureMessageMonitor, configureMessageMonitor, configureQueryBus, configureQueryUpdateEmitter, configureResourceInjector, configureSerializer, configureTransactionManager, eventProcessing, registerCommandHandler, registerQueryHandler, start
public static Configurer defaultConfiguration()
SimpleCommandBus
and
SimpleEventBus
.public static Configurer defaultConfiguration(boolean autoLocateConfigurerModules)
SimpleCommandBus
and
SimpleEventBus
, indicating whether to autoLocateConfigurerModules
.
When autoLocateConfigurerModules
is true
, a ServiceLoader will be used to locate all declared
instances of type ConfigurerModule
. Each of the discovered instances will be invoked, allowing it to
set default values for the configuration.autoLocateConfigurerModules
- flag indicating whether ConfigurerModules on the classpath should be
automatically retrieved. Should be set to false
when using an
application container, such as Spring or CDI.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 QueryUpdateEmitter defaultQueryUpdateEmitter(Configuration config)
config
- The configuration based on which the component is initializedprotected ParameterResolverFactory defaultParameterResolverFactory(Configuration config)
config
- The configuration based on which the component is initialized.protected HandlerDefinition defaultHandlerDefinition(Class<?> inspectedClass)
inspectedClass
- The class being inspected for handlersprotected 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 DeadlineManager defaultDeadlineManager(Configuration config)
DeadlineManager
implementation. Subclasses may override this method to provide their
own default.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 EventProcessingConfigurer eventProcessing()
Configurer
EventProcessingConfigurer
registered as a module with this Configurer. If there aren't
any, it will create an EventProcessingModule
and register it as a module. If there are multiple,
an AxonConfigurationException
is thrown.eventProcessing
in interface Configurer
public Configurer registerEventUpcaster(Function<Configuration,EventUpcaster> upcasterBuilder)
Configurer
registerEventUpcaster
in interface Configurer
upcasterBuilder
- The function that returns an EventUpcaster based on the configurationpublic Configurer configureMessageMonitor(Function<Configuration,BiFunction<Class<?>,String,MessageMonitor<Message<?>>>> builder)
Configurer
configureMessageMonitor
in interface Configurer
builder
- 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 Configurer
componentType
- 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 Configurer
componentType
- The declared type of the componentcomponentName
- The name of the componentmessageMonitorFactory
- The factory to usepublic Configurer configureCorrelationDataProviders(Function<Configuration,List<CorrelationDataProvider>> correlationDataProviderBuilder)
Configurer
configureCorrelationDataProviders
in interface Configurer
correlationDataProviderBuilder
- the builder function returning the CorrelationDataProvider listpublic Configurer registerModule(ModuleConfiguration module)
Configurer
Typically, modules are registered for Event Handling components or Sagas.
registerModule
in interface Configurer
module
- The module to registerSagaConfiguration
public Configurer registerCommandHandler(int phase, Function<Configuration,Object> annotatedCommandHandlerBuilder)
Configurer
The builder function receives the Configuration as input, and is expected to return a fully initialized instance of the command handler bean.
registerCommandHandler
in interface Configurer
phase
- defines a phase in which the command handler builder will be invoked during
Configuration.start()
and Configuration.shutdown()
. When
starting the configuration handlers are ordered in ascending, when shutting
down the configuration, descending order is used.annotatedCommandHandlerBuilder
- The builder function of the Command Handler beanpublic Configurer registerQueryHandler(int phase, Function<Configuration,Object> annotatedQueryHandlerBuilder)
Configurer
The builder function receives the Configuration as input, and is expected to return a fully initialized instance of the query handler bean.
registerQueryHandler
in interface Configurer
phase
- defines a phase in which the query handler builder will be invoked during
Configuration.start()
and Configuration.shutdown()
. When
starting the configuration handlers are ordered in ascending, when shutting
down the configuration, descending order is used.annotatedQueryHandlerBuilder
- 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 Configurer
C
- 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)
Configurer
EventStorageEngine
instance.configureEmbeddedEventStore
in interface Configurer
storageEngineBuilder
- The builder function for the EventStorageEngine
public Configurer configureEventSerializer(Function<Configuration,Serializer> eventSerializerBuilder)
Configurer
Serializer
instance.
This Serializer is specifically used to serialize EventMessage payload and metadata.configureEventSerializer
in interface Configurer
eventSerializerBuilder
- The builder function for the Serializer
.public Configurer configureMessageSerializer(Function<Configuration,Serializer> messageSerializerBuilder)
Configurer
Serializer
instance.
This Serializer is specifically used to serialize Message payload and Metadata.configureMessageSerializer
in interface Configurer
messageSerializerBuilder
- The builder function for the Serializer
.public <A> Configurer configureAggregate(AggregateConfiguration<A> aggregateConfiguration)
Configurer
aggregateConfiguration
. This method
allows for more fine-grained configuration compared to the Configurer.configureAggregate(Class)
method.configureAggregate
in interface Configurer
A
- The type of aggregate the configuration is foraggregateConfiguration
- The instance describing the configuration of an AggregateAggregateConfigurer
public Configurer registerHandlerDefinition(BiFunction<Configuration,Class,HandlerDefinition> handlerDefinitionClass)
Configurer
registerHandlerDefinition
in interface Configurer
handlerDefinitionClass
- A function providing the definition based on the current Configuration as well
as the class being inspected.public Configuration buildConfiguration()
Configurer
buildConfiguration
in interface Configurer
protected void prepareModules()
protected 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–2018. All rights reserved.