Class ValueGenerationManagerImpl
java.lang.Object
org.datanucleus.store.valuegenerator.ValueGenerationManagerImpl
- All Implemented Interfaces:
ValueGenerationManager
Manager for the creation of ValueGenerators.
ValueGenerators are of two primary types.
- unique : apply to any datastore, and generate unique values. For example, UUID, which generates the values in Java space.
- datastore : apply to a particular datastore, and member. For example, an RDBMS SEQUENCE.
Member Key
The member "key" is either the fully-qualified member name (e.g "mydomain.MyClass.myField") that is having its values generated, or is for a (surrogate) datastore id member (e.g "mydomain.MyClass (datastore-id)"). All unique generators can also be looked up by the strategy name (since there is one instance of that generator per strategy.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String, ValueGenerator> Map of ValueGenerators, keyed by the member key ("{class}.{field}", or "{class} + (datastore-id)").protected final StoreManagerprotected Map<String, ValueGenerator> Map of "unique" ValueGenerators, keyed by their strategy name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Method to clear out the generators managed by this manager.createAndRegisterValueGenerator(String memberKey, String strategyName, Properties props) Method to create and register a generator of the specified strategy, for the specified memberKey.createValueGenerator(String strategyName, String seqName, Properties props, ValueGenerationConnectionProvider connectionProvider) Method to create a ValueGenerator when the generator is datastore based.Simple way of generating a member "key" for use in lookups for datastore-identity.Simple way of generating a member "key" for use in lookups.getTypeForValueGeneratorForMember(String strategyName, String memberKey) Accessor for the type of value that is generated by the ValueGenerator for the specified strategy, for the member "key".Accessor for the "unique" ValueGenerator for the specified name (if any).getValueGeneratorForMemberKey(String memberKey) Method to access the currently defined ValueGenerator for the specified member "key" (if any).voidregisterValueGeneratorForMemberKey(String memberKey, ValueGenerator generator) Method to store a ValueGenerator for the specified member "key".booleansupportsStrategy(String strategy) Convenience accessor for whether the specified strategy is supported for this datastore.
-
Field Details
-
storeMgr
-
generatorsByMemberKey
Map of ValueGenerators, keyed by the member key ("{class}.{field}", or "{class} + (datastore-id)"). -
uniqueGeneratorsByName
Map of "unique" ValueGenerators, keyed by their strategy name.
-
-
Constructor Details
-
ValueGenerationManagerImpl
Constructor.- Parameters:
storeMgr- Store Manager
-
-
Method Details
-
clear
public void clear()Description copied from interface:ValueGenerationManagerMethod to clear out the generators managed by this manager.- Specified by:
clearin interfaceValueGenerationManager
-
getValueGeneratorForMemberKey
Description copied from interface:ValueGenerationManagerMethod to access the currently defined ValueGenerator for the specified member "key" (if any).- Specified by:
getValueGeneratorForMemberKeyin interfaceValueGenerationManager- Parameters:
memberKey- The member "key"- Returns:
- Its ValueGenerator
-
registerValueGeneratorForMemberKey
Description copied from interface:ValueGenerationManagerMethod to store a ValueGenerator for the specified member "key".- Specified by:
registerValueGeneratorForMemberKeyin interfaceValueGenerationManager- Parameters:
memberKey- The member "key"generator- The ValueGenerator to use for that member key
-
getUniqueValueGeneratorByName
Description copied from interface:ValueGenerationManagerAccessor for the "unique" ValueGenerator for the specified name (if any).- Specified by:
getUniqueValueGeneratorByNamein interfaceValueGenerationManager- Parameters:
name- The (strategy) name.- Returns:
- The ValueGenerator for that name
-
getMemberKey
Description copied from interface:ValueGenerationManagerSimple way of generating a member "key" for use in lookups for datastore-identity.- Specified by:
getMemberKeyin interfaceValueGenerationManager- Parameters:
cmd- Metadata for the class using datastore-identity- Returns:
- The member "key" to use
-
getMemberKey
Description copied from interface:ValueGenerationManagerSimple way of generating a member "key" for use in lookups.- Specified by:
getMemberKeyin interfaceValueGenerationManager- Parameters:
mmd- Metadata for the member- Returns:
- The member "key" to use
-
getTypeForValueGeneratorForMember
Description copied from interface:ValueGenerationManagerAccessor for the type of value that is generated by the ValueGenerator for the specified strategy, for the member "key".- Specified by:
getTypeForValueGeneratorForMemberin interfaceValueGenerationManager- Parameters:
strategyName- The value generation strategymemberKey- The member "key"- Returns:
- The type of value generated
-
createAndRegisterValueGenerator
public ValueGenerator createAndRegisterValueGenerator(String memberKey, String strategyName, Properties props) Description copied from interface:ValueGenerationManagerMethod to create and register a generator of the specified strategy, for the specified memberKey.- Specified by:
createAndRegisterValueGeneratorin interfaceValueGenerationManager- Parameters:
memberKey- The member keystrategyName- Strategy for the generatorprops- The properties to use- Returns:
- The ValueGenerator
-
supportsStrategy
Description copied from interface:ValueGenerationManagerConvenience accessor for whether the specified strategy is supported for this datastore.- Specified by:
supportsStrategyin interfaceValueGenerationManager- Parameters:
strategy- The strategy name- Returns:
- Whether it is supported
-
createValueGenerator
public ValueGenerator createValueGenerator(String strategyName, String seqName, Properties props, ValueGenerationConnectionProvider connectionProvider) Description copied from interface:ValueGenerationManagerMethod to create a ValueGenerator when the generator is datastore based. This is used solely by the NucleusSequence API to create a generator, but not to register it here for further use.- Specified by:
createValueGeneratorin interfaceValueGenerationManager- Parameters:
strategyName- Strategy nameseqName- Symbolic name of the generatorprops- Properties to control the generatorconnectionProvider- Provider for connections- Returns:
- The ValueGenerator
-