Package org.jdbi.v3.core.extension
Class Extensions
java.lang.Object
org.jdbi.v3.core.extension.Extensions
- All Implemented Interfaces:
JdbiConfig<Extensions>
Configuration class for defining
Jdbi extensions via ExtensionFactory
instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this configuration object.failFast()Fail fast if any method in an Extension object is misconfigured and can not be warmed.findFactory(Class<? extends ExtensionFactory> factoryType) Find the registered factory of the given type.<E> Optional<E>findFor(Class<E> extensionType, HandleSupplier handleSupplier) Create an extension instance if a factory accepts the extension type.findMetadata(Class<?> extensionType, ExtensionFactory extensionFactory) Retrieves all extension metadata for a specific extension type.booleanhasExtensionFor(Class<?> extensionType) Returns true if an extension is registered for the given extension type.booleanReturns whether Proxy classes are allowed to be used.booleanReturns true if misconfigured extension objects fail fast.voidThrow if proxy creation is disallowed.register(ExtensionFactory factory) Register aExtensionFactoryinstance with the extension framework.registerConfigCustomizerFactory(ConfigCustomizerFactory configCustomizerFactory) Registers a globalConfigCustomizerFactoryinstance.registerHandlerCustomizer(ExtensionHandlerCustomizer extensionHandlerCustomizer) Registers a globalExtensionHandlerCustomizerinstance.registerHandlerFactory(ExtensionHandlerFactory extensionHandlerFactory) Registers a globalExtensionHandlerFactoryinstance.setAllowProxy(boolean allowProxy) Allow usingProxyto implement extensions.voidsetRegistry(ConfigRegistry registry) The registry will inject itself into the configuration object.
-
Constructor Details
-
Extensions
public Extensions()Creates a new instance.- registers extension handlers factories for bridge and interface default methods and for the
UseExtensionHandlerannotation. - registers extension handler customizers for the
UseExtensionHandlerCustomizerannotation. - registers extension configurer factories for
UseExtensionConfigurerannotation.
- registers extension handlers factories for bridge and interface default methods and for the
-
-
Method Details
-
setRegistry
Description copied from interface:JdbiConfigThe 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:
setRegistryin interfaceJdbiConfig<Extensions>- Parameters:
registry- the registry that owns this configuration object
-
register
Register aExtensionFactoryinstance with the extension framework.- Parameters:
factory- the factory to register- Returns:
- This instance
-
registerHandlerFactory
Registers a globalExtensionHandlerFactoryinstance. This factory is registered globally and will be used with all registeredExtensionFactoryinstances.- Parameters:
extensionHandlerFactory- TheExtensionHandlerFactoryto register- Returns:
- This instance
- Since:
- 3.38.0
-
registerHandlerCustomizer
@Alpha public Extensions registerHandlerCustomizer(ExtensionHandlerCustomizer extensionHandlerCustomizer) Registers a globalExtensionHandlerCustomizerinstance. This customizer is registered globally and will be used with all registeredExtensionFactoryinstances.- Parameters:
extensionHandlerCustomizer- TheExtensionHandlerCustomizerto register- Returns:
- This instance
- Since:
- 3.38.0
-
registerConfigCustomizerFactory
@Alpha public Extensions registerConfigCustomizerFactory(ConfigCustomizerFactory configCustomizerFactory) Registers a globalConfigCustomizerFactoryinstance. This factory is registered globally and will be used with all registeredExtensionFactoryinstances.- Parameters:
configCustomizerFactory- TheConfigCustomizerFactoryto register- Returns:
- This instance
- Since:
- 3.38.0
-
hasExtensionFor
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
Create an extension instance if a factory accepts the extension type.
This method requires access to aHandleSupplier, 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 createhandleSupplier- A handle supplier object- Returns:
- an attached extension instance if a factory is found,
Optional.empty()otherwise
-
findFactory
Find the registered factory of the given type. The factory returned from this call may not be the same instance that was registered withregister(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 typeextensionFactory- The extension factory for this extension type- Returns:
- A
ExtensionMetadataobject describing the extension handlers and customizers for this extension type - Since:
- 3.38.0
-
setAllowProxy
Allow usingProxyto implement extensions.- Parameters:
allowProxy- whether to allow use of Proxy types- Returns:
- this
-
isAllowProxy
Returns whether Proxy classes are allowed to be used.- Returns:
- whether Proxy classes are allowed to be used.
-
failFast
Fail fast if any method in an Extension object is misconfigured and can not be warmed. Default is to fail when a method is used for the first time.- Returns:
- this
- Since:
- 3.39.0
-
isFailFast
Returns true if misconfigured extension objects fail fast.- Returns:
- True if misconfigured extension objects fail fast.
- Since:
- 3.39.0
-
createCopy
Description copied from interface:JdbiConfigReturns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.- Specified by:
createCopyin interfaceJdbiConfig<Extensions>- Returns:
- a copy of this configuration object.
-
onCreateProxy
Throw if proxy creation is disallowed.
-