Class AbstractJdbiDefinitionModule
- java.lang.Object
-
- com.google.inject.PrivateModule
-
- org.jdbi.v3.guice.AbstractJdbiDefinitionModule
-
- All Implemented Interfaces:
com.google.inject.Module,JdbiBinder
public abstract class AbstractJdbiDefinitionModule extends com.google.inject.PrivateModule implements JdbiBinder
Base module class to defineJdbiinstances. This is aPrivateModulewhich will by default only expose the constructedJdbiobject as a binding. Everything configured within this module is private to the module and not exposed. This allows installation of multiple instances of modules that extend theAbstractJdbiDefinitionModulebase class.Each module requires a
DataSourcebound using the same annotation or annotation class as used on the module constructor. If this data source is not present, the injection process will fail.Successful binding will expose a
Jdbibinding annotated with the same annotation or annotation class as used on the module constructor. Additional elements defined in this module can be exposed using theexposeBinding(Class)is called within theconfigureJdbi()method.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.annotation.Annotationannotationprivate java.lang.Class<? extends java.lang.annotation.Annotation>annotationClassprivate java.lang.Class<? extends java.lang.annotation.Annotation>globalAnnotationClassprivate InternalJdbiBinderjdbiBinder
-
Constructor Summary
Constructors Modifier Constructor Description AbstractJdbiDefinitionModule(java.lang.annotation.Annotation annotation)Create a Jdbi definition module.AbstractJdbiDefinitionModule(java.lang.annotation.Annotation annotation, java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass)Create a Jdbi definition module with a custom annotation for element configuration.privateAbstractJdbiDefinitionModule(java.lang.annotation.Annotation annotation, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass)AbstractJdbiDefinitionModule(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)Create a Jdbi definition module.AbstractJdbiDefinitionModule(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass)Create a Jdbi definition module with a custom annotation for element configuration.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidconfigure()abstract voidconfigureJdbi()Override this method to configure all aspects of a Jdbi instance.<T> com.google.inject.Key<T>createKey(com.google.inject.TypeLiteral<T> type)Creates aKeyobject for aTypeLiteralthat uses the annotation or annotation class used to construct this module.<T> com.google.inject.Key<T>createKey(java.lang.Class<T> clazz)Creates aKeyobject for a class that uses the annotation or annotation class used to construct this module.<T> voidexposeBinding(com.google.inject.TypeLiteral<T> type)Exposes a binding that is in module scope (without annotations) and binds it using either the annotation or annotation class and then exposes it outside the module.<T> voidexposeBinding(java.lang.Class<T> clazz)Exposes a binding that is in module scope (without annotations) and binds it using either the annotation or annotation class and then exposes it outside the module.<T> InternalImportBindingBuilder<T>importBinding(com.google.inject.binder.LinkedBindingBuilder<T> binder, com.google.inject.TypeLiteral<T> type)Pulls an existing outside binding into the module scope using the specified binder.<T> InternalImportBindingBuilder<T>importBinding(com.google.inject.binder.LinkedBindingBuilder<T> binder, java.lang.Class<T> clazz)Pulls an existing outside binding into the module scope using the specified binder.<T> InternalImportBindingBuilder<T>importBinding(com.google.inject.TypeLiteral<T> type)Pulls an existing outside binding into the module scope.<T> InternalImportBindingBuilder<T>importBinding(java.lang.Class<T> clazz)Pulls an existing outside binding into the module scope.<T> InternalLooseImportBindingBuilder<T>importBindingLoosely(com.google.inject.binder.LinkedBindingBuilder<T> binder, com.google.inject.TypeLiteral<T> type)Pulls an outside binding into the module scope if it exists using the binder given.<T> InternalLooseImportBindingBuilder<T>importBindingLoosely(com.google.inject.binder.LinkedBindingBuilder<T> binder, java.lang.Class<T> clazz)Pulls an outside binding into the module scope if it exists using the binder given.<T> InternalLooseImportBindingBuilder<T>importBindingLoosely(com.google.inject.TypeLiteral<T> type)Pulls an outside binding into the module scope if it exists.<T> InternalLooseImportBindingBuilder<T>importBindingLoosely(java.lang.Class<T> clazz)Pulls an outside binding into the module scope if it exists.JdbiBinderjdbiBinder()Provides access to theJdbiBinderinstance.-
Methods inherited from class com.google.inject.PrivateModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, convertToTypes, currentStage, expose, expose, expose, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jdbi.v3.guice.JdbiBinder
bindArrayType, bindCodec, bindCodec, bindCodec, bindColumnMapper, bindColumnMapper, bindColumnMapper, bindColumnMapper, bindCustomizer, bindPlugin, bindRowMapper, bindRowMapper, bindRowMapper
-
-
-
-
Field Detail
-
annotation
private final java.lang.annotation.Annotation annotation
-
annotationClass
private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass
-
globalAnnotationClass
private final java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass
-
jdbiBinder
private InternalJdbiBinder jdbiBinder
-
-
Constructor Detail
-
AbstractJdbiDefinitionModule
public AbstractJdbiDefinitionModule(java.lang.annotation.Annotation annotation)
Create a Jdbi definition module.A Jdbi definition module that uses this constructor will use the default element configuration from
AbstractJdbiConfigurationModules that do not use any custom annotation.- Parameters:
annotation- The resultingJdbiinstance will be exposed using this annotation.
-
AbstractJdbiDefinitionModule
public AbstractJdbiDefinitionModule(java.lang.annotation.Annotation annotation, java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass)Create a Jdbi definition module with a custom annotation for element configuration.A Jdbi definition module that uses this constructor will use the element configuration from
AbstractJdbiConfigurationModules that use the same annotation as this constructor.
-
AbstractJdbiDefinitionModule
public AbstractJdbiDefinitionModule(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Create a Jdbi definition module.A Jdbi definition module that uses this constructor will use the default element configuration from
AbstractJdbiConfigurationModules that do not use any custom annotation.- Parameters:
annotationClass- The resultingJdbiinstance will be exposed using this annotation class.
-
AbstractJdbiDefinitionModule
public AbstractJdbiDefinitionModule(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass)Create a Jdbi definition module with a custom annotation for element configuration.A Jdbi definition module that uses this constructor will use the element configuration from
AbstractJdbiConfigurationModules that use the same annotation as this constructor.
-
AbstractJdbiDefinitionModule
private AbstractJdbiDefinitionModule(@Nullable java.lang.annotation.Annotation annotation, @Nullable java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, @Nullable java.lang.Class<? extends java.lang.annotation.Annotation> globalAnnotationClass)
-
-
Method Detail
-
configure
protected final void configure()
- Specified by:
configurein classcom.google.inject.PrivateModule
-
configureJdbi
public abstract void configureJdbi()
Override this method to configure all aspects of a Jdbi instance.@Override protected void configureJdbi() { bindPlugin().toInstance(...); bindTransformer().to(...); bindRowMapper().to(...); }
-
jdbiBinder
public final JdbiBinder jdbiBinder()
Provides access to theJdbiBinderinstance.Only valid when called from
configureJdbi().- Specified by:
jdbiBinderin interfaceJdbiBinder
-
importBindingLoosely
public final <T> InternalLooseImportBindingBuilder<T> importBindingLoosely(com.google.inject.TypeLiteral<T> type)
Pulls an outside binding into the module scope if it exists. If it does not exist, bind a null value or a default. An outside binding uses the same annotation or annotation class as the module.
-
importBindingLoosely
public final <T> InternalLooseImportBindingBuilder<T> importBindingLoosely(java.lang.Class<T> clazz)
Pulls an outside binding into the module scope if it exists. If it does not exist, bind a null value or a default. An outside binding uses the same annotation or annotation class as the module.
-
importBindingLoosely
public final <T> InternalLooseImportBindingBuilder<T> importBindingLoosely(com.google.inject.binder.LinkedBindingBuilder<T> binder, com.google.inject.TypeLiteral<T> type)
Pulls an outside binding into the module scope if it exists using the binder given. If it does not exist, bind a null value or a default. An outside binding uses the same annotation or annotation class as the module.
-
importBindingLoosely
public final <T> InternalLooseImportBindingBuilder<T> importBindingLoosely(com.google.inject.binder.LinkedBindingBuilder<T> binder, java.lang.Class<T> clazz)
Pulls an outside binding into the module scope if it exists using the binder given. If it does not exist, bind a null value or a default. An outside binding uses the same annotation or annotation class as the module.
-
importBinding
public final <T> InternalImportBindingBuilder<T> importBinding(java.lang.Class<T> clazz)
Pulls an existing outside binding into the module scope. An outside binding uses the same annotation or annotation class as the module.
-
importBinding
public final <T> InternalImportBindingBuilder<T> importBinding(com.google.inject.TypeLiteral<T> type)
Pulls an existing outside binding into the module scope. An outside binding uses the same annotation or annotation class as the module.
-
importBinding
public final <T> InternalImportBindingBuilder<T> importBinding(com.google.inject.binder.LinkedBindingBuilder<T> binder, com.google.inject.TypeLiteral<T> type)
Pulls an existing outside binding into the module scope using the specified binder. An outside binding uses the same annotation or annotation class as the module.
-
importBinding
public final <T> InternalImportBindingBuilder<T> importBinding(com.google.inject.binder.LinkedBindingBuilder<T> binder, java.lang.Class<T> clazz)
Pulls an existing outside binding into the module scope using the specified binder. An outside binding uses the same annotation or annotation class as the module.
-
createKey
public final <T> com.google.inject.Key<T> createKey(java.lang.Class<T> clazz)
Creates aKeyobject for a class that uses the annotation or annotation class used to construct this module.
-
createKey
public final <T> com.google.inject.Key<T> createKey(com.google.inject.TypeLiteral<T> type)
Creates aKeyobject for aTypeLiteralthat uses the annotation or annotation class used to construct this module.
-
exposeBinding
public final <T> void exposeBinding(java.lang.Class<T> clazz)
Exposes a binding that is in module scope (without annotations) and binds it using either the annotation or annotation class and then exposes it outside the module.
-
exposeBinding
public final <T> void exposeBinding(com.google.inject.TypeLiteral<T> type)
Exposes a binding that is in module scope (without annotations) and binds it using either the annotation or annotation class and then exposes it outside the module.
-
-