Interface Configuration
- All Superinterfaces:
DescribableComponent
- All Known Subinterfaces:
AxonConfiguration
components in an Axon Framework application.- Since:
- 3.0.0
- Author:
- Allard Buijze, Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptiondefault <C> CgetComponent(Class<C> type) Returns the component declared under the giventypeor throws aComponentNotFoundExceptionif it does not exist.default <C> CgetComponent(Class<C> type, String name) Returns the component declared under the giventypeandnameor throws aComponentNotFoundExceptionif it does not exist.<C> CgetComponent(Class<C> type, String name, Supplier<C> defaultImpl) Returns the component declared under the giventypeandname, reverting to the givendefaultImplif no such component is defined.default <C> CgetComponent(Class<C> type, Supplier<C> defaultImpl) Returns the component declared under the giventype, reverting to the givendefaultImplif no such component is defined.getComponents(Class<C> type) Returns all components declared under the giventypeas a map of component names to component instances.getModuleConfiguration(String name) default <C> Optional<C> getOptionalComponent(Class<C> type) Returns the component declared under the giventypewithin anOptional.<C> Optional<C> getOptionalComponent(Class<C> type, String name) Returns the component declared under the giventypeandnamewithin anOptional.Returns the parent configuration of this configuration, if the parent configuration exists.default booleanhasComponent(Class<?> type) default booleanhasComponent(Class<?> type, String name) Check whether there is aComponentpresent in thisConfigurationfor the giventypeandnamecombination.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
getComponent
Returns the component declared under the giventypeor throws aComponentNotFoundExceptionif it does not exist.- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.- Returns:
- The component registered for the given type.
- Throws:
ComponentNotFoundException- Whenever there is no component present for the giventype.
-
getComponent
Returns the component declared under the giventypeandnameor throws aComponentNotFoundExceptionif it does not exist.- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.name- The name of the component to retrieve. Usenullwhen there is no name or usegetComponent(Class)instead.- Returns:
- The component registered for the given
typeandname. - Throws:
ComponentNotFoundException- Whenever there is no component present for the giventypeandname.
-
getOptionalComponent
Returns the component declared under the giventypewithin anOptional.- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.- Returns:
- An
Optionalwrapping the component registered for the giventype. Might be empty when there is no component present for the giventype.
-
getOptionalComponent
Returns the component declared under the giventypeandnamewithin anOptional.- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.name- The name of the component to retrieve. Usenullwhen there is no name or usegetOptionalComponent(Class)instead.- Returns:
- An
Optionalwrapping the component registered for the giventypeandname. Might be empty when there is no component present for the giventypeandname.
-
hasComponent
-
hasComponent
Check whether there is aComponentpresent in thisConfigurationfor the giventypeandnamecombination.- Parameters:
type- The type of theComponentto check if it exists, typically an interface.name- The name of theComponentto check if it exists. Usenullwhen there is no name or usehasComponent(Class)instead.- Returns:
truewhen there is aComponentregistered under the giventypeandname combination,falseotherwise.
-
getComponent
Returns the component declared under the giventype, reverting to the givendefaultImplif no such component is defined.When no component was previously registered, the default is then configured as the component for the given type.
- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.defaultImpl- The supplier of the default component to return if it was not registered.- Returns:
- The component declared under the given
type, reverting to the givendefaultImplif no such component is defined.
-
getComponent
@Nonnull <C> C getComponent(@Nonnull Class<C> type, @Nullable String name, @Nonnull Supplier<C> defaultImpl) Returns the component declared under the giventypeandname, reverting to the givendefaultImplif no such component is defined.When no component was previously registered, the default is then configured as the component for the given type.
- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.name- The name of the component to retrieve. Usenullwhen there is no name or usegetComponent(Class, Supplier)instead.defaultImpl- The supplier of the default component to return if it was not registered.- Returns:
- The component declared under the given
typeandname, reverting to the givendefaultImplif no such component is defined.
-
getModuleConfigurations
List<Configuration> getModuleConfigurations()- Returns:
- The resulting
Configurationfrom eachregistered modulewith thisConfiguration.
-
getModuleConfiguration
Returns theConfigurationfrom theModulewith the givenname.The module must have been
registeredwith thisConfigurationdirectly. -
getParent
Returns the parent configuration of this configuration, if the parent configuration exists. Components can use this to build hierarchical components, which prefer components from a child configuration over components from a parent configuration.- Returns:
- The parent configuration of this configuration, or
nullif no parent configuration exists.
-
getComponents
Returns all components declared under the giventypeas a map of component names to component instances.This method retrieves all registered components matching the specified type. The returned map contains:
- An entry with
nullkey for the component registered without a name (if one exists) - Entries with
Stringkeys for components registered with specific names
EventProcessors.The method searches in the current configuration and all
module configurations. It does NOT search theparent configuration. To get the full hierarchy of components, call this method on the top-level (root) configuration.Important: This method only returns components that are already registered or have been instantiated. Components that could be created on-demand by a
ComponentFactorybut have not yet been accessed will not be included in the results. If you need to access a specific component that might be factory-created, usegetComponent(Class, String)orgetOptionalComponent(Class, String)instead.Example usage:
Map<String, EventProcessor> processors = configuration.getComponents(EventProcessor.class); EventProcessor defaultProcessor = processors.get(null); // unnamed processor EventProcessor orderProcessor = processors.get("orderProcessor"); // named processor- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.- Returns:
- A map of component names to component instances for the given
type. Returns an empty map if no components are registered for the given type. The map may contain anullkey for the unnamed component.
- An entry with
-