Class ValueGenerationManagerImpl
- java.lang.Object
-
- org.datanucleus.store.valuegenerator.ValueGenerationManagerImpl
-
- All Implemented Interfaces:
ValueGenerationManager
public class ValueGenerationManagerImpl extends Object implements 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
Fields Modifier and Type Field Description protected Map<String,ValueGenerator>generatorsByMemberKeyMap of ValueGenerators, keyed by the member key ("{class}.{field}", or "{class} + (datastore-id)").protected StoreManagerstoreMgrprotected Map<String,ValueGenerator>uniqueGeneratorsByNameMap of "unique" ValueGenerators, keyed by their strategy name.
-
Constructor Summary
Constructors Constructor Description ValueGenerationManagerImpl(StoreManager storeMgr)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Method to clear out the generators managed by this manager.ValueGeneratorcreateAndRegisterValueGenerator(String memberKey, String strategyName, Properties props)Method to create and register a generator of the specified strategy, for the specified memberKey.ValueGeneratorcreateValueGenerator(String strategyName, String seqName, Properties props, ValueGenerationConnectionProvider connectionProvider)Method to create a ValueGenerator when the generator is datastore based.StringgetMemberKey(AbstractClassMetaData cmd)Simple way of generating a member "key" for use in lookups for datastore-identity.StringgetMemberKey(AbstractMemberMetaData mmd)Simple way of generating a member "key" for use in lookups.ClassgetTypeForValueGeneratorForMember(String strategyName, String memberKey)Accessor for the type of value that is generated by the ValueGenerator for the specified strategy, for the member "key".ValueGeneratorgetUniqueValueGeneratorByName(String name)Accessor for the "unique" ValueGenerator for the specified name (if any).ValueGeneratorgetValueGeneratorForMemberKey(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 Detail
-
storeMgr
protected final StoreManager storeMgr
-
generatorsByMemberKey
protected Map<String,ValueGenerator> generatorsByMemberKey
Map of ValueGenerators, keyed by the member key ("{class}.{field}", or "{class} + (datastore-id)").
-
uniqueGeneratorsByName
protected Map<String,ValueGenerator> uniqueGeneratorsByName
Map of "unique" ValueGenerators, keyed by their strategy name.
-
-
Constructor Detail
-
ValueGenerationManagerImpl
public ValueGenerationManagerImpl(StoreManager storeMgr)
Constructor.- Parameters:
storeMgr- Store Manager
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:ValueGenerationManagerMethod to clear out the generators managed by this manager.- Specified by:
clearin interfaceValueGenerationManager
-
getValueGeneratorForMemberKey
public ValueGenerator getValueGeneratorForMemberKey(String memberKey)
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
public void registerValueGeneratorForMemberKey(String memberKey, ValueGenerator generator)
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
public ValueGenerator getUniqueValueGeneratorByName(String name)
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
public String getMemberKey(AbstractClassMetaData cmd)
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
public String getMemberKey(AbstractMemberMetaData mmd)
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
public Class getTypeForValueGeneratorForMember(String strategyName, String memberKey)
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
public boolean supportsStrategy(String strategy)
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
-
-