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>
generatorsByMemberKey
Map of ValueGenerators, keyed by the member key ("{class}.{field}", or "{class} + (datastore-id)").protected StoreManager
storeMgr
protected Map<String,ValueGenerator>
uniqueGeneratorsByName
Map 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 void
clear()
Method to clear out the generators managed by this manager.ValueGenerator
createAndRegisterValueGenerator(String memberKey, String strategyName, Properties props)
Method to create and register a generator of the specified strategy, for the specified memberKey.ValueGenerator
createValueGenerator(String strategyName, String seqName, Properties props, ValueGenerationConnectionProvider connectionProvider)
Method to create a ValueGenerator when the generator is datastore based.String
getMemberKey(AbstractClassMetaData cmd)
Simple way of generating a member "key" for use in lookups for datastore-identity.String
getMemberKey(AbstractMemberMetaData mmd)
Simple way of generating a member "key" for use in lookups.Class
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".ValueGenerator
getUniqueValueGeneratorByName(String name)
Accessor for the "unique" ValueGenerator for the specified name (if any).ValueGenerator
getValueGeneratorForMemberKey(String memberKey)
Method to access the currently defined ValueGenerator for the specified member "key" (if any).void
registerValueGeneratorForMemberKey(String memberKey, ValueGenerator generator)
Method to store a ValueGenerator for the specified member "key".boolean
supportsStrategy(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:ValueGenerationManager
Method to clear out the generators managed by this manager.- Specified by:
clear
in interfaceValueGenerationManager
-
getValueGeneratorForMemberKey
public ValueGenerator getValueGeneratorForMemberKey(String memberKey)
Description copied from interface:ValueGenerationManager
Method to access the currently defined ValueGenerator for the specified member "key" (if any).- Specified by:
getValueGeneratorForMemberKey
in interfaceValueGenerationManager
- Parameters:
memberKey
- The member "key"- Returns:
- Its ValueGenerator
-
registerValueGeneratorForMemberKey
public void registerValueGeneratorForMemberKey(String memberKey, ValueGenerator generator)
Description copied from interface:ValueGenerationManager
Method to store a ValueGenerator for the specified member "key".- Specified by:
registerValueGeneratorForMemberKey
in 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:ValueGenerationManager
Accessor for the "unique" ValueGenerator for the specified name (if any).- Specified by:
getUniqueValueGeneratorByName
in interfaceValueGenerationManager
- Parameters:
name
- The (strategy) name.- Returns:
- The ValueGenerator for that name
-
getMemberKey
public String getMemberKey(AbstractClassMetaData cmd)
Description copied from interface:ValueGenerationManager
Simple way of generating a member "key" for use in lookups for datastore-identity.- Specified by:
getMemberKey
in 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:ValueGenerationManager
Simple way of generating a member "key" for use in lookups.- Specified by:
getMemberKey
in 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:ValueGenerationManager
Accessor for the type of value that is generated by the ValueGenerator for the specified strategy, for the member "key".- Specified by:
getTypeForValueGeneratorForMember
in 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:ValueGenerationManager
Method to create and register a generator of the specified strategy, for the specified memberKey.- Specified by:
createAndRegisterValueGenerator
in 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:ValueGenerationManager
Convenience accessor for whether the specified strategy is supported for this datastore.- Specified by:
supportsStrategy
in 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:ValueGenerationManager
Method 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:
createValueGenerator
in interfaceValueGenerationManager
- Parameters:
strategyName
- Strategy nameseqName
- Symbolic name of the generatorprops
- Properties to control the generatorconnectionProvider
- Provider for connections- Returns:
- The ValueGenerator
-
-