Interface ExtensionFactory

  • All Known Implementing Classes:
    AbstractSqlObjectFactory, ExtensionFactoryDelegate, GeneratorSqlObjectFactory, SqlObjectFactory
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ExtensionFactory
    Factory interface used to produce Jdbi extension objects. A factory can provide additional pieces of information by overriding the various default methods.
    • Method Detail

      • accepts

        boolean accepts​(java.lang.Class<?> extensionType)
        Returns true if the factory can process the given extension type.
        Parameters:
        extensionType - the extension type
        Returns:
        whether the factory can produce an extension of the given type
      • attach

        default <E> E attach​(java.lang.Class<E> extensionType,
                             HandleSupplier handleSupplier)
        Attaches an extension type. This method is not called if getFactoryFlags() contains ExtensionFactory.FactoryFlag.NON_VIRTUAL_FACTORY.
        Type Parameters:
        E - the extension type
        Parameters:
        extensionType - The extension type
        handleSupplier - Supplies the database handle. This supplier may lazily open a Handle on the first invocation. Extension implementors should take care not to fetch the handle before it is needed, to avoid opening handles unnecessarily
        Returns:
        An extension of the given type, attached to the given handle
        Throws:
        java.lang.IllegalArgumentException - if the extension type is not supported by this factory
        See Also:
        Jdbi.onDemand(Class)
      • getConfigCustomizerFactories

        @Alpha
        default java.util.Collection<ConfigCustomizerFactory> getConfigCustomizerFactories​(ConfigRegistry config)
        Returns a collection of ConfigCustomizerFactory objects.
        Each factory is called once for every type that is attached by the factory and once for each method in the type. They can return ConfigCustomizer instances that will affect the specific configuration for each method and extension type.
        Parameters:
        config - A Configuration registry object that can be used to look up additional information
        Returns:
        A collection of ConfigCustomizerFactory objects. Can be empty, must not be null
        Since:
        3.38.0
      • buildExtensionMetadata

        @Alpha
        default void buildExtensionMetadata​(ExtensionMetadata.Builder builder)
        Receives the ExtensionMetadata.Builder when the ExtensionMetadata object for this extension is created. The factory can add additional method handlers or specific instance and method customizers as needed.
        Code here can call methods on the builder to configure the metadata object.
        Parameters:
        builder - The builder object that is used to create the ExtensionMetadata object
        Since:
        3.38.0