Dropwizard JDBI with Java 8 support

Addon bundle for Dropwizard to support Java 8 features

Лицензия

Лицензия

Категории

Категории

Java 8 Языки программирования DropWizard Контейнер Микросервисы JDBI Данные Базы данных
Группа

Группа

io.dropwizard.modules
Идентификатор

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

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

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

0.9.0-1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Dropwizard JDBI with Java 8 support
Addon bundle for Dropwizard to support Java 8 features

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

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

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.dropwizard : dropwizard-jdbi jar

test (4)

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

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

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

Dropwizard Java 8 Bundle

Build Status Coverage Status Maven Central

An addon bundle and a set of classes for using Java 8 features like Optional<T> and the new Date/Time API (JSR-310) in a Dropwizard application.

Currently it supports Java 8 versions of dropwizard-auth and dropwizard-jdbi.

INFO: The Dropwizard Java 8 Bundle has been integrated into Dropwizard 1.0.0 and higher and not required any more. Please only use this bundle if you're using an older version of Dropwizard.

Usage

Just add Java8Bundle to your Application class as described in the manual in the Bundles paragraph.

Serialization and deserialization

This will add support for Optional<T> to Jersey and support for JSR-310 and Optional<T> to Jackson.

public class DemoApplication extends Application<DemoConfiguration> {
    // [...]
    @Override
    public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
        bootstrap.addBundle(new Java8Bundle());
        // [...]
    }
}

When using ResourceTestRule in unit tests, Java8 providers need to registered to ensure correct behaviour:

public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(new HelloWorldResource())
    .addProvider(OptionalMessageBodyWriter.class)
    .addProvider(OptionalParamFeature.class)
    .build();

JDBI

To get support for Java 8 objects use io.dropwizard.java8.jdbi.DBIFactory

import io.dropwizard.java8.jdbi.DBIFactory;

@Override
public void run(ExampleConfiguration config, Environment environment) {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, config.getDataSourceFactory(), "postgresql");
    final UserDAO dao = jdbi.onDemand(UserDAO.class);
    environment.jersey().register(new UserResource(dao));
}

When getting a single result use the annotation @SingleValueResult

public interface MyDAO {
    @SingleValueResult
    @SqlQuery("select name from something where id = :id")
    Optional<String> findNameById(@Bind("id") int id);
}

Maven Artifacts

This project is available on Maven Central. To add it to your project simply add the following dependencies to your pom.xml:

<dependency>
  <groupId>io.dropwizard.modules</groupId>
  <artifactId>dropwizard-java8</artifactId>
  <version>0.9.0-1</version>
</dependency>

<dependency>
  <groupId>io.dropwizard.modules</groupId>
  <artifactId>dropwizard-java8-auth</artifactId>
  <version>0.9.0-1</version>
</dependency>

<dependency>
  <groupId>io.dropwizard.modules</groupId>
  <artifactId>dropwizard-java8-jdbi</artifactId>
  <version>0.9.0-1</version>
</dependency>

When using JSR-310 Dates with Hibernate, Jadira UserType Extend needs to be added:

<dependency>
    <groupId>org.jadira.usertype</groupId>
    <artifactId>usertype.extended</artifactId>
    <version>4.0.0.GA</version>
</dependency>

Dropwizard will auto register this in SessionFactoryFactory.

Support

Please file bug reports and feature requests in GitHub issues.

License

Copyright (c) 2014-2015 Jochen Schalanda

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.

io.dropwizard.modules

Dropwizard

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

Версия
0.9.0-1
0.9.0-rc5-1
0.8.0-2
0.8.0-1
0.7.1-1
0.7.0-1