Package org.axonframework.common
Class IdentifierFactory
java.lang.Object
org.axonframework.common.IdentifierFactory
- Direct Known Subclasses:
DefaultIdentifierFactory
Abstract Factory class that provides access to an IdentifierFactory implementation. The IdentifierFactory
is responsible for generated unique identifiers for domain objects, such as Aggregates (AggregateRoot) and Events.
This class uses the
ServiceLoader mechanism to find implementations. If none are found, it defaults to an
implementation that provides randomly chosen java.util.UUIDs.
To provide your own implementation, create a file called org.axonframework.common.IdentifierFactory in
the META-INF/services package. The file must contain the fully qualified class name of the
implementation to use. This implementation must have a public no-arg constructor and extend IdentifierFactory.
This class is thread safe to use.- Since:
- 1.2
- Author:
- Allard Buijze
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringGenerates a unique identifier for use by Entities (generally the Aggregate Root) and Events.static IdentifierFactoryReturns an instance of the IdentifierFactory discovered on the classpath.
-
Constructor Details
-
IdentifierFactory
public IdentifierFactory()
-
-
Method Details
-
getInstance
Returns an instance of the IdentifierFactory discovered on the classpath. This class uses theServiceLoadermechanism to find implementations. If none are found, it defaults to an implementation that provides randomly chosenjava.util.UUIDs.- Returns:
- the IdentifierFactory implementation found on the classpath.
- See Also:
-
generateIdentifier
Generates a unique identifier for use by Entities (generally the Aggregate Root) and Events. The implementation may choose whatever strategy it sees fit, as long as the chance of a duplicate identifier is acceptable to the application.- Returns:
- a String representation of a unique identifier
-