Package org.jdbi.v3.core.extension
Class InstanceExtensionHandlerFactory
- java.lang.Object
-
- org.jdbi.v3.core.extension.InstanceExtensionHandlerFactory
-
- All Implemented Interfaces:
ExtensionHandlerFactory
final class InstanceExtensionHandlerFactory extends java.lang.Object implements ExtensionHandlerFactory
ProvidesExtensionHandlerinstances for all methods that have not been covered in any other way. It forwards a call to the handler to a method invocation on the target object. For any extension factory that simply provides an implementation of the extension interface, this forwards the call to the method on the implementation. The extension framework wraps these calls into invocations that manage the extension context for the handle correctly so that logging will work for all extension.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static ExtensionHandlerFactoryINSTANCE
-
Constructor Summary
Constructors Constructor Description InstanceExtensionHandlerFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepts(java.lang.Class<?> extensionType, java.lang.reflect.Method method)Determines whether the factory can create anExtensionHandlerfor combination of extension type and method.java.util.Optional<ExtensionHandler>createExtensionHandler(java.lang.Class<?> extensionType, java.lang.reflect.Method method)Returns anExtensionHandlerinstance for a extension type and method combination.
-
-
-
Field Detail
-
INSTANCE
static final ExtensionHandlerFactory INSTANCE
-
-
Method Detail
-
accepts
public boolean accepts(java.lang.Class<?> extensionType, java.lang.reflect.Method method)Description copied from interface:ExtensionHandlerFactoryDetermines whether the factory can create anExtensionHandlerfor combination of extension type and method.- Specified by:
acceptsin interfaceExtensionHandlerFactory- Parameters:
extensionType- The extension type classmethod- A method- Returns:
- True if the factory can create an extension handler for extension type and method, false otherwise
-
createExtensionHandler
public java.util.Optional<ExtensionHandler> createExtensionHandler(java.lang.Class<?> extensionType, java.lang.reflect.Method method)
Description copied from interface:ExtensionHandlerFactoryReturns anExtensionHandlerinstance for a extension type and method combination.- Specified by:
createExtensionHandlerin interfaceExtensionHandlerFactory- Parameters:
extensionType- The extension type classmethod- A method- Returns:
- An
ExtensionHandlerinstance wrapped into anOptional. The optional can be empty. This is necessary to retrofit old code that does not have an accept/build code pair but unconditionally tries to build a handler and returns empty if it can not. New code should always returnOptional.of(extensionHandler}and never returnOptional.empty()
-
-