Interface ExtensionFactory
- All Known Implementing Classes:
SqlObjectFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Factory interface used to produce Jdbi extension objects. A factory can provide additional
pieces of information by overriding the various default methods.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Flags that the factory can return to control aspects of the extension framework. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the factory can process the given extension type.default <E> E
attach
(Class<E> extensionType, HandleSupplier handleSupplier) Attaches an extension type.default void
Receives theExtensionMetadata.Builder
when theExtensionMetadata
object for this extension is created.default Collection
<ConfigCustomizerFactory> Returns a collection ofConfigCustomizerFactory
objects.default Collection
<ExtensionHandlerCustomizer> Returns a collection ofExtensionHandlerCustomizer
objects.default Collection
<ExtensionHandlerFactory> Returns a collection ofExtensionHandlerFactory
objects.default Set
<ExtensionFactory.FactoryFlag> Returns a set ofExtensionFactory.FactoryFlag
s that describe the extension factory.
-
Method Details
-
accepts
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
Attaches an extension type. This method is not called ifgetFactoryFlags()
containsExtensionFactory.FactoryFlag.NON_VIRTUAL_FACTORY
.- Type Parameters:
E
- the extension type- Parameters:
extensionType
- The extension typehandleSupplier
- 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:
IllegalArgumentException
- if the extension type is not supported by this factory- See Also:
-
getExtensionHandlerFactories
@Alpha default Collection<ExtensionHandlerFactory> getExtensionHandlerFactories(ConfigRegistry config) Returns a collection ofExtensionHandlerFactory
objects. These factories are used in addition to the factories that have been registered withExtensions.registerHandlerFactory(org.jdbi.v3.core.extension.ExtensionHandlerFactory)
.
Handler factories returned here can customize the behavior of the Extension factory itself.- Parameters:
config
- A Configuration registry object that can be used to look up additional information- Returns:
- A collection of
ExtensionHandlerFactory
objects. Can be empty, must not be null - Since:
- 3.38.0
-
getExtensionHandlerCustomizers
@Alpha default Collection<ExtensionHandlerCustomizer> getExtensionHandlerCustomizers(ConfigRegistry config) Returns a collection ofExtensionHandlerCustomizer
objects. These customizers are used in addition to the customizers that have been registered withExtensions.registerHandlerCustomizer(org.jdbi.v3.core.extension.ExtensionHandlerCustomizer)
.
Handler customizers returned here can customize the behavior of the Handlers returned by the handler factories.- Parameters:
config
- A Configuration registry object that can be used to look up additional information- Returns:
- A collection of
ExtensionHandlerCustomizer
objects. Can be empty, must not be null - Since:
- 3.38.0
-
getConfigCustomizerFactories
@Alpha default Collection<ConfigCustomizerFactory> getConfigCustomizerFactories(ConfigRegistry config) Returns a collection ofConfigCustomizerFactory
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 returnConfigCustomizer
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
Receives theExtensionMetadata.Builder
when theExtensionMetadata
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 theExtensionMetadata
object- Since:
- 3.38.0
-
getFactoryFlags
Returns a set ofExtensionFactory.FactoryFlag
s that describe the extension factory.- Returns:
- A set of
ExtensionFactory.FactoryFlag
elements. Default is the empty set - Since:
- 3.38.0
-