org.axonframework.domain
Class IdentifierFactory

java.lang.Object
  extended by 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.UUIDs.

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

Constructor Summary
IdentifierFactory()
           
 
Method Summary
abstract  String generateIdentifier()
          Generates a unique identifier for use by Entities (generally the Aggregate Root) and Events.
static IdentifierFactory getInstance()
          Returns an instance of the IdentifierFactory discovered on the classpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdentifierFactory

public IdentifierFactory()
Method Detail

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.UUIDs.

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.