org.axonframework.domain
Class IdentifierFactory
java.lang.Object
org.axonframework.domain.IdentifierFactory
- Direct Known Subclasses:
- DefaultIdentifierFactory
public abstract class IdentifierFactory
- extends Object
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.UUID
s.
To provide your own implementation, create a file called org.axonframework.domain.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:
ServiceLoader
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IdentifierFactory
public IdentifierFactory()
getInstance
public static IdentifierFactory getInstance()
- Returns an instance of the IdentifierFactory discovered on the classpath. This class uses the
ServiceLoader
mechanism to find implementations. If none are found, it defaults to an implementation that
provides randomly chosen java.util.UUID
s.
- Returns:
- the IdentifierFactory implementation found on the classpath.
- See Also:
ServiceLoader
generateIdentifier
public abstract String 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
Copyright © 2010-2016. All Rights Reserved.