Interface ComponentFactory<C>
- Type Parameters:
C- The component this factory builds on request.
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
AxonServerEventStorageEngineFactory
C.
It is strongly recommended to invoke start operations during
construction of the components, since the Configuration is always
started before a factory is consulted. Hence, failing to invoke start operations
results in components in a faulty state.
When registered with a ComponentRegistry, the
registry will consult the factory only when there is no registered component for a given type and name.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionconstruct(String name, Configuration config) Constructs aComponentcontaining an implementation of the generic typeC.forType()Returns theClassthis factory constructs.voidregisterShutdownHandlers(LifecycleRegistry registry) Registers this factory's shutdown process with the givenregistry.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
forType
Returns theClassthis factory constructs.Useful when the generic type is lost due to grouping multiple factories in a collection.
- Returns:
- The
Classthis factory constructs.
-
construct
Constructs aComponentcontaining an implementation of the generic typeC.Implementations of this method may choose to reject the construction by returning an
empty Optionalif thenameis not of an expected format, or when the givenconfigdoes not contain the required components to construct a new instance with.Be certain to invoke any start operation on the new instance of type
Cbefore returning. This is mandatory since factories are only consulted once an application isstarted.- Parameters:
name- The name that's used to request a new instance from this factory. This parameter can be a basis to reject construction.config- The configuration to retrieve components from to use during the construction by this factory. A factory may return anempty Optionalif the configuration does not contain the necessary components.- Returns:
- An optional of a
Componentcontaining an implementation of the generic typeC.
-
registerShutdownHandlers
Registers this factory's shutdown process with the givenregistry.This typically means the factory registers the shutdown operations of all
constructedcomponents of typeC. This operation might do nothing with theregistrywhen the component of typeCdoes not have any shutdown operations, for example.Since a component factory is consulted after
start-upof aConfiguration, onlyregistered shutdown handlerswill take effect.- Parameters:
registry- The life cycle registry toregister shutdown handlerswith.
-