Skip to content
This repository has been archived by the owner on Sep 13, 2021. It is now read-only.

Commit

Permalink
Migrate to dropwizard 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-shpak committed Dec 19, 2019
1 parent 93bc4c2 commit d52f285
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hk2bundleVersion=develop-SNAPSHOT
dropwizardVersion=1.3.5
hk2Version=2.5.0-b32
dropwizardVersion=2.0.0
hk2Version=2.6.1
junitVersion=4.12
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.codahale.metrics.health.HealthCheckRegistry;
import io.dropwizard.Application;
import io.dropwizard.Bundle;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.cli.Command;
import io.dropwizard.lifecycle.Managed;
Expand All @@ -25,7 +26,7 @@

import static org.glassfish.hk2.utilities.ServiceLocatorUtilities.*;

public class HK2Bundle implements Bundle {
public class HK2Bundle implements ConfiguredBundle<Configuration> {

/**
* Used to generate unique incremental IDs for ServiceLocator name
Expand Down Expand Up @@ -60,7 +61,7 @@ public void initialize(Bootstrap<?> bootstrap) {
}

@Override
public void run(Environment environment) {
public void run(Configuration configuration, Environment environment) throws Exception {
addOneConstant(serviceLocator, environment);
addOneConstant(serviceLocator, environment.jersey());
addOneConstant(serviceLocator, environment.admin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.dropwizard.Configuration;
import io.dropwizard.db.DatabaseConfiguration;
import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.api.TypeLiteral;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.jdbi.v3.core.Jdbi;

Expand All @@ -22,7 +23,7 @@ public class JDBIBinder<T extends Configuration> extends AbstractBinder {
private Class<? extends Factory<Jdbi>> dbiFactory = JDBIFactory.class;
private Class<? extends Factory<Object>> sqlObjectFactory = SqlObjectFactory.class;

private DatabaseConfiguration databaseConfiguration;
private DatabaseConfiguration<T> databaseConfiguration;
private HashSet<Class<?>> sqlInterfaces = new HashSet<>();

/**
Expand Down Expand Up @@ -69,7 +70,7 @@ public JDBIBinder<T> register(Class<?>... interfaces) {

@Override
protected void configure() {
bind(databaseConfiguration).to(DatabaseConfiguration.class);
bind(databaseConfiguration).to(new TypeLiteral<DatabaseConfiguration<Configuration>>() {});

addActiveFactoryDescriptor(dbiFactory);
addActiveFactoryDescriptor(HandleFactory.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public <T extends Bundle> ScopedBindingBuilder<T> bundle(T bundle) {
.to(Bundle.class);
}

public <T extends ConfiguredBundle> ScopedBindingBuilder<T> configuredBundle(Class<T> configuredBundle) {
public <T extends ConfiguredBundle<?>> ScopedBindingBuilder<T> configuredBundle(Class<T> configuredBundle) {
return bindAsContract(configuredBundle)
.to(ConfiguredBundle.class)
.in(Singleton.class);
}

public <T extends ConfiguredBundle> ScopedBindingBuilder<T> configuredBundle(T configuredBundle) {
public <T extends ConfiguredBundle<?>> ScopedBindingBuilder<T> configuredBundle(T configuredBundle) {
return bind(configuredBundle)
.to(ConfiguredBundle.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.winterly.dropwizard.hk2bundle.validation;

import io.dropwizard.Bundle;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.jersey.validation.Validators;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
Expand All @@ -12,7 +14,7 @@
import javax.validation.ValidatorFactory;
import javax.ws.rs.container.ResourceContext;

public class InjectValidatorBundle implements Bundle {
public class InjectValidatorBundle implements ConfiguredBundle<Configuration> {

private ConstraintValidatorFactory validatorFactory = new ConstraintValidatorFactoryImpl();

Expand All @@ -26,7 +28,7 @@ public void initialize(Bootstrap<?> bootstrap) {
}

@Override
public void run(Environment environment) {
public void run(Configuration configuration, Environment environment) {
GetLocatorFeature getLocatorFeature = new GetLocatorFeature(serviceLocator -> {
ResourceContext resourceContext = serviceLocator.getService(ResourceContext.class);
validatorFactory = resourceContext.getResource(InjectingConstraintValidatorFactory.class);
Expand Down

0 comments on commit d52f285

Please sign in to comment.