Interface ValueGenerationManager

  • All Known Implementing Classes:

    public interface 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.
    • Method Detail

      • clear

        void clear()
        Method to clear out the generators managed by this manager.
      • getValueGeneratorForMemberKey

        ValueGenerator getValueGeneratorForMemberKey​(String memberKey)
        Method to access the currently defined ValueGenerator for the specified member "key" (if any).
        memberKey - The member "key"
        Its ValueGenerator
      • registerValueGeneratorForMemberKey

        void registerValueGeneratorForMemberKey​(String memberKey,
                                                ValueGenerator generator)
        Method to store a ValueGenerator for the specified member "key".
        memberKey - The member "key"
        generator - The ValueGenerator to use for that member key
      • getUniqueValueGeneratorByName

        ValueGenerator getUniqueValueGeneratorByName​(String name)
        Accessor for the "unique" ValueGenerator for the specified name (if any).
        name - The (strategy) name.
        The ValueGenerator for that name
      • getMemberKey

        String getMemberKey​(AbstractClassMetaData cmd)
        Simple way of generating a member "key" for use in lookups for datastore-identity.
        cmd - Metadata for the class using datastore-identity
        The member "key" to use
      • getMemberKey

        String getMemberKey​(AbstractMemberMetaData mmd)
        Simple way of generating a member "key" for use in lookups.
        mmd - Metadata for the member
        The member "key" to use
      • createAndRegisterValueGenerator

        ValueGenerator createAndRegisterValueGenerator​(String memberKey,
                                                       String strategyName,
                                                       Properties props)
        Method to create and register a generator of the specified strategy, for the specified memberKey.
        memberKey - The member key
        strategyName - Strategy for the generator
        props - The properties to use
        The ValueGenerator
      • getTypeForValueGeneratorForMember

        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".
        strategyName - The value generation strategy
        memberKey - The member "key"
        The type of value generated
      • supportsStrategy

        boolean supportsStrategy​(String strategy)
        Convenience accessor for whether the specified strategy is supported for this datastore.
        strategy - The strategy name
        Whether it is supported
      • createValueGenerator

        ValueGenerator createValueGenerator​(String strategyName,
                                            String seqName,
                                            Properties props,
                                            ValueGenerationConnectionProvider connectionProvider)
        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.
        strategyName - Strategy name
        seqName - Symbolic name of the generator
        props - Properties to control the generator
        connectionProvider - Provider for connections
        The ValueGenerator