public final class JdbiBundle
extends java.lang.Object
implements ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
JdbiBundle.forDatabase((env, conf) -> conf.getDatabase()).
Bundle introduce unit of work concept for JDBI. All actions must perform inside unit of work. You may use
InTransaction annotation to annotate classes or methods in order to wrap logic with unit of work
(and actual transaction). Annotations could be nested: in this case upper most annotation declares transaction and
nested are ignored (logic executed inside upper transaction). To declare unit of work without transaction
use UnitManager.
To manually declare transaction use TransactionTemplate bean.
Custom installations:
JdbiRepository are installed
as guice beans, but provides usual functionality as JDBI sql proxies (just no need to always combine them).ResultSetMapper are registered
automatically.for manual unit of work definition,
for manual work with transactions,
for sql object
customization details| Modifier and Type | Method and Description |
|---|---|
static <C extends io.dropwizard.Configuration> |
forDatabase(ConfigAwareProvider<io.dropwizard.db.PooledDataSourceFactory,C> db)
Builds bundle, by using only database factory from configuration.
|
static <C extends io.dropwizard.Configuration> |
forDbi(ConfigAwareProvider<org.skife.jdbi.v2.DBI,C> dbi)
Builds bundle for custom JDBI instance.
|
void |
initialize(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap) |
JdbiBundle |
withTxAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation>... txAnnotations)
By default,
InTransaction annotation registered. |
@SafeVarargs public final JdbiBundle withTxAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation>... txAnnotations)
InTransaction annotation registered. If you need to use different or more annotations
provide all of them. Note, that you will need to provide InTransaction too if you want to use it too,
otherwise it would not be supported.txAnnotations - annotations to use as transaction annotationspublic void initialize(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap)
initialize in interface ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundlepublic static <C extends io.dropwizard.Configuration> JdbiBundle forDbi(ConfigAwareProvider<org.skife.jdbi.v2.DBI,C> dbi)
C - configuration typedbi - JDBI instance providerpublic static <C extends io.dropwizard.Configuration> JdbiBundle forDatabase(ConfigAwareProvider<io.dropwizard.db.PooledDataSourceFactory,C> db)
C - configuration typedb - database configuration provider