Package org.jdbi.v3.core.extension
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
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumFlags that the factory can return to control aspects of the extension framework. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the factory can process the given extension type.default <E> Eattach(Class<E> extensionType, HandleSupplier handleSupplier) Attaches an extension type.default voidReceives theExtensionMetadata.Builderwhen theExtensionMetadataobject for this extension is created.default Collection<ConfigCustomizerFactory> Returns a collection ofConfigCustomizerFactoryobjects.default Collection<ExtensionHandlerCustomizer> Returns a collection ofExtensionHandlerCustomizerobjects.default Collection<ExtensionHandlerFactory> Returns a collection ofExtensionHandlerFactoryobjects.default Set<ExtensionFactory.FactoryFlag> Returns a set ofExtensionFactory.FactoryFlags 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 ofExtensionHandlerFactoryobjects. 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
ExtensionHandlerFactoryobjects. Can be empty, must not be null - Since:
- 3.38.0
-
getExtensionHandlerCustomizers
@Alpha default Collection<ExtensionHandlerCustomizer> getExtensionHandlerCustomizers(ConfigRegistry config) Returns a collection ofExtensionHandlerCustomizerobjects. 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
ExtensionHandlerCustomizerobjects. Can be empty, must not be null - Since:
- 3.38.0
-
getConfigCustomizerFactories
@Alpha default Collection<ConfigCustomizerFactory> getConfigCustomizerFactories(ConfigRegistry config) Returns a collection ofConfigCustomizerFactoryobjects.
Each factory is called once for every type that is attached by the factory and once for each method in the type. They can returnConfigCustomizerinstances 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
ConfigCustomizerFactoryobjects. Can be empty, must not be null - Since:
- 3.38.0
-
buildExtensionMetadata
Receives theExtensionMetadata.Builderwhen theExtensionMetadataobject 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 theExtensionMetadataobject- Since:
- 3.38.0
-
getFactoryFlags
Returns a set ofExtensionFactory.FactoryFlags that describe the extension factory.- Returns:
- A set of
ExtensionFactory.FactoryFlagelements. Default is the empty set - Since:
- 3.38.0
-