Dropwizard Jdbi Unit Of Work

Provides support for Unit Of Work annotations with a Jdbi Backend

Лицензия

Лицензия

Категории

Категории

IDE Инструменты разработки DropWizard Контейнер Микросервисы JDBI Данные Базы данных
Группа

Группа

com.github.isopropylcyanide
Идентификатор

Идентификатор

dropwizard-jdbi-unitofwork
Последняя версия

Последняя версия

1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Dropwizard Jdbi Unit Of Work
Provides support for Unit Of Work annotations with a Jdbi Backend
Ссылка на сайт

Ссылка на сайт

https://github.com/isopropylcyanide/dropwizard-jdbi-unitofwork
Система контроля версий

Система контроля версий

https://github.com/isopropylcyanide/dropwizard-jdbi-unitofwork/tree/master

Скачать dropwizard-jdbi-unitofwork

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.isopropylcyanide/dropwizard-jdbi-unitofwork/ -->
<dependency>
    <groupId>com.github.isopropylcyanide</groupId>
    <artifactId>dropwizard-jdbi-unitofwork</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.isopropylcyanide/dropwizard-jdbi-unitofwork/
implementation 'com.github.isopropylcyanide:dropwizard-jdbi-unitofwork:1.1'
// https://jarcasting.com/artifacts/com.github.isopropylcyanide/dropwizard-jdbi-unitofwork/
implementation ("com.github.isopropylcyanide:dropwizard-jdbi-unitofwork:1.1")
'com.github.isopropylcyanide:dropwizard-jdbi-unitofwork:jar:1.1'
<dependency org="com.github.isopropylcyanide" name="dropwizard-jdbi-unitofwork" rev="1.1">
  <artifact name="dropwizard-jdbi-unitofwork" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.isopropylcyanide', module='dropwizard-jdbi-unitofwork', version='1.1')
)
libraryDependencies += "com.github.isopropylcyanide" % "dropwizard-jdbi-unitofwork" % "1.1"
[com.github.isopropylcyanide/dropwizard-jdbi-unitofwork "1.1"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
io.dropwizard : dropwizard-jdbi jar 1.3.29
org.reflections : reflections jar 0.9.12
org.slf4j : slf4j-api jar 1.7.30

test (2)

Идентификатор библиотеки Тип Версия
org.mockito : mockito-core jar 3.8.0
junit : junit jar 4.13.1

Модули Проекта

Данный проект не имеет модулей.

Dropwizard Jdbi - Unit of Work Support

Travis (.org) Codecov GitHub Maven Central

Provides @JdbiUnitOfWork annotation for a Jdbi backed Dropwizard backend for wrapping resource methods in a transaction context

  • Dropwizard provides a very slick @UnitOfWork annotation that wraps a transaction context around resource methods annotated with this annotation. This is very useful for wrapping multiple calls in a single database transaction all of which will succeed or roll back atomically.

  • However this support is only available for Hibernate. For all the goodness Jdbi brings, we had to bring the transactionality on our own. This module provides support for JdbiUnitOfWork with a Jdbi backend

Maven Artifacts

This project is available on Maven Central. To add it to your project you can add the following dependency to your pom.xml:

<dependency>
    <groupId>com.github.isopropylcyanide</groupId>
    <artifactId>dropwizard-jdbi-unitofwork</artifactId>
    <version>1.0</version>
 </dependency>

Features

  • transactionality across multiple datasources when called from a request thread
  • transactionality across multiple datasources across multiple threads
  • excluding, selectively, certain set of URI's from transaction contexts, such as ELB, Health Checks etc
  • Http GET methods are excluded from transaction by default.
  • Http POST methods are wrapped around in a transaction only when annotated with @JdbiUnitOfWork

Usage

  • Add the dependency to your pom.xml

  • Decide which implementation of JdbiHandleManager is suitable for your use case.

    //bind(JdbiHandleManager.class).toInstance(new RequestScopedJdbiHandleManager(dbi)); 
    bind(JdbiHandleManager.class).toInstance(new LinkedRequestScopedJdbiHandleManager(dbi)); 
  • Provide the list of package where the SQL Objects (to be attached) are located. Classes with Jdbi annotations @SqlQuery or @SqlUpdate will be picked automatically

    Set<String> daoPackages = Sets.newHashSet("<fq-package-name>", "fq-package-name", ...);
  • Install the module in your main application module.

    install(new JdbiUnitOfWorkModule(handleManager, daoPackages));
  • Start annotating resource methods with @JdbiUnitOfWork and you're good to go.

    @POST
    @Path("/")
    @JdbiUnitOfWork
    public RequestResponse createRequest() {
          ..do stateful work (across multiple Dao's)
          return response 
    }

Design

  • This library relies on Jersey Monitoring Events to bind request lifecycle with a transaction aspect
  • At the backend, all Jdbi objects such as Dao or SqlObjects are proxied behind a JdbiHandleManager
  • JdbiHandleManager contract specifies the get and clear of the actual handles to the calling thread.

image

Support

Please file bug reports and feature requests in GitHub issues.

License

Copyright (c) 2012-2020 Aman Garg

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.

Версии библиотеки

Версия
1.1
1.0