Class ValueGenerationManagerImpl

  • All Implemented Interfaces:
    ValueGenerationManager

    public class ValueGenerationManagerImpl
    extends java.lang.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.
    Any unique generators are loaded at initialisation. Any datastore generators are loaded when required. All generators are cached once created, and can be looked up by the member "key" that they are for.

    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 Detail

      • generatorsByMemberKey

        protected java.util.Map<java.lang.String,​ValueGenerator> generatorsByMemberKey
        Map of ValueGenerators, keyed by the member key ("{class}.{field}", or "{class} + (datastore-id)").
      • uniqueGeneratorsByName

        protected java.util.Map<java.lang.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

      • getMemberKey

        public java.lang.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 interface ValueGenerationManager
        Parameters:
        cmd - Metadata for the class using datastore-identity
        Returns:
        The member "key" to use
      • getTypeForValueGeneratorForMember

        public java.lang.Class getTypeForValueGeneratorForMember​(java.lang.String strategyName,
                                                                 java.lang.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 interface ValueGenerationManager
        Parameters:
        strategyName - The value generation strategy
        memberKey - The member "key"
        Returns:
        The type of value generated
      • createAndRegisterValueGenerator

        public ValueGenerator createAndRegisterValueGenerator​(java.lang.String memberKey,
                                                              java.lang.String strategyName,
                                                              java.util.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 interface ValueGenerationManager
        Parameters:
        memberKey - The member key
        strategyName - Strategy for the generator
        props - The properties to use
        Returns:
        The ValueGenerator
      • supportsStrategy

        public boolean supportsStrategy​(java.lang.String strategy)
        Description copied from interface: ValueGenerationManager
        Convenience accessor for whether the specified strategy is supported for this datastore.
        Specified by:
        supportsStrategy in interface ValueGenerationManager
        Parameters:
        strategy - The strategy name
        Returns:
        Whether it is supported
      • createValueGenerator

        public ValueGenerator createValueGenerator​(java.lang.String strategyName,
                                                   java.lang.String seqName,
                                                   java.util.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 interface ValueGenerationManager
        Parameters:
        strategyName - Strategy name
        seqName - Symbolic name of the generator
        props - Properties to control the generator
        connectionProvider - Provider for connections
        Returns:
        The ValueGenerator