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
-
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.boolean
hasExtensionFor
(Class<?> extensionType) Returns true if an extension is registered for the given extension type.boolean
Returns whether Proxy classes are allowed to be used.boolean
Returns true if misconfigured extension objects fail fast.void
Throw if proxy creation is disallowed.register
(ExtensionFactory factory) Register aExtensionFactory
instance with the extension framework.registerConfigCustomizerFactory
(ConfigCustomizerFactory configCustomizerFactory) Registers a globalConfigCustomizerFactory
instance.registerHandlerCustomizer
(ExtensionHandlerCustomizer extensionHandlerCustomizer) Registers a globalExtensionHandlerCustomizer
instance.registerHandlerFactory
(ExtensionHandlerFactory extensionHandlerFactory) Registers a globalExtensionHandlerFactory
instance.setAllowProxy
(boolean allowProxy) Allow usingProxy
to implement extensions.void
setRegistry
(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
UseExtensionHandler
annotation. - registers extension handler customizers for the
UseExtensionHandlerCustomizer
annotation. - registers extension configurer factories for
UseExtensionConfigurer
annotation.
- registers extension handlers factories for bridge and interface default methods and for the
-
-
Method Details
-
setRegistry
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 interfaceJdbiConfig<Extensions>
- Parameters:
registry
- the registry that owns this configuration object
-
register
Register aExtensionFactory
instance with the extension framework.- Parameters:
factory
- the factory to register- Returns:
- This instance
-
registerHandlerFactory
Registers a globalExtensionHandlerFactory
instance. This factory is registered globally and will be used with all registeredExtensionFactory
instances.- Parameters:
extensionHandlerFactory
- TheExtensionHandlerFactory
to register- Returns:
- This instance
- Since:
- 3.38.0
-
registerHandlerCustomizer
@Alpha public Extensions registerHandlerCustomizer(ExtensionHandlerCustomizer extensionHandlerCustomizer) Registers a globalExtensionHandlerCustomizer
instance. This customizer is registered globally and will be used with all registeredExtensionFactory
instances.- Parameters:
extensionHandlerCustomizer
- TheExtensionHandlerCustomizer
to register- Returns:
- This instance
- Since:
- 3.38.0
-
registerConfigCustomizerFactory
@Alpha public Extensions registerConfigCustomizerFactory(ConfigCustomizerFactory configCustomizerFactory) Registers a globalConfigCustomizerFactory
instance. This factory is registered globally and will be used with all registeredExtensionFactory
instances.- Parameters:
configCustomizerFactory
- TheConfigCustomizerFactory
to 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
ExtensionMetadata
object describing the extension handlers and customizers for this extension type - Since:
- 3.38.0
-
setAllowProxy
Allow usingProxy
to 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:JdbiConfig
Returns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.- Specified by:
createCopy
in interfaceJdbiConfig<Extensions>
- Returns:
- a copy of this configuration object.
-
onCreateProxy
Throw if proxy creation is disallowed.
-