Class Extensions

java.lang.Object
org.jdbi.v3.core.extension.Extensions
All Implemented Interfaces:
JdbiConfig<Extensions>

public class Extensions extends Object implements JdbiConfig<Extensions>
Configuration class for defining Jdbi extensions via ExtensionFactory instances.
  • Constructor Details

    • Extensions

      public Extensions()
      Creates a new instance.
  • Method Details

    • setRegistry

      public void setRegistry(ConfigRegistry registry)
      Description copied from interface: JdbiConfig
      The registry will inject itself into the configuration object. This can be useful if you need to look up dependencies. You will get a new registry after being copied.
      Specified by:
      setRegistry in interface JdbiConfig<Extensions>
      Parameters:
      registry - the registry that owns this configuration object
    • register

      public Extensions register(ExtensionFactory factory)
      Register a ExtensionFactory instance with the extension framework.
      Parameters:
      factory - the factory to register
      Returns:
      This instance
    • registerHandlerFactory

      @Alpha public Extensions registerHandlerFactory(ExtensionHandlerFactory extensionHandlerFactory)
      Registers a global ExtensionHandlerFactory instance. This factory is registered globally and will be used with all registered ExtensionFactory instances.
      Parameters:
      extensionHandlerFactory - The ExtensionHandlerFactory to register
      Returns:
      This instance
      Since:
      3.38.0
    • registerHandlerCustomizer

      @Alpha public Extensions registerHandlerCustomizer(ExtensionHandlerCustomizer extensionHandlerCustomizer)
      Registers a global ExtensionHandlerCustomizer instance. This customizer is registered globally and will be used with all registered ExtensionFactory instances.
      Parameters:
      extensionHandlerCustomizer - The ExtensionHandlerCustomizer to register
      Returns:
      This instance
      Since:
      3.38.0
    • registerConfigCustomizerFactory

      @Alpha public Extensions registerConfigCustomizerFactory(ConfigCustomizerFactory configCustomizerFactory)
      Registers a global ConfigCustomizerFactory instance. This factory is registered globally and will be used with all registered ExtensionFactory instances.
      Parameters:
      configCustomizerFactory - The ConfigCustomizerFactory to register
      Returns:
      This instance
      Since:
      3.38.0
    • hasExtensionFor

      public boolean hasExtensionFor(Class<?> extensionType)
      Returns true if an extension is registered for the given extension type.
      Parameters:
      extensionType - the type to query. Must not be null
      Returns:
      true if a registered extension factory handles the type
    • findFor

      public <E> Optional<E> findFor(Class<E> extensionType, HandleSupplier handleSupplier)
      Create an extension instance if a factory accepts the extension type. This method requires access to a HandleSupplier, which is only useful either from within an extension implementation of inside the Jdbi code. It should rarely be called by user code.
      Type Parameters:
      E - the extension type to create
      Parameters:
      extensionType - the extension type to create
      handleSupplier - A handle supplier object
      Returns:
      an attached extension instance if a factory is found, Optional.empty() otherwise
    • findFactory

      public Optional<ExtensionFactory> findFactory(Class<? extends ExtensionFactory> factoryType)
      Find the registered factory of the given type. The factory returned from this call may not be the same instance that was registered with register(ExtensionFactory).
      Parameters:
      factoryType - the factory's type to find
      Returns:
      the found factory, if any or Optional.empty() otherwise
    • findMetadata

      @Alpha public ExtensionMetadata findMetadata(Class<?> extensionType, ExtensionFactory extensionFactory)
      Retrieves all extension metadata for a specific extension type.
      Parameters:
      extensionType - The extension type
      extensionFactory - The extension factory for this extension type
      Returns:
      A ExtensionMetadata object describing the extension handlers and customizers for this extension type
      Since:
      3.38.0
    • setAllowProxy

      @Beta public Extensions setAllowProxy(boolean allowProxy)
      Allow using Proxy to implement extensions.
      Parameters:
      allowProxy - whether to allow use of Proxy types
      Returns:
      this
    • isAllowProxy

      @Beta public boolean isAllowProxy()
      Returns whether Proxy classes are allowed to be used.
      Returns:
      whether Proxy classes are allowed to be used.
    • createCopy

      public Extensions createCopy()
      Description copied from interface: JdbiConfig
      Returns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.
      Specified by:
      createCopy in interface JdbiConfig<Extensions>
      Returns:
      a copy of this configuration object.
    • onCreateProxy

      @Beta public void onCreateProxy()
      Throw if proxy creation is disallowed.