From c1d3b8a30c9cd4fc8dc8f2d391214b8ac19a1da9 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Mon, 17 Oct 2016 09:37:47 -0500 Subject: [PATCH] Remove dropwizard-jdbc dependency from lookups-cached-single. (#3573) Fixes #3548. --- extensions-core/lookups-cached-single/pom.xml | 5 --- .../druid/server/lookup/jdbc/QueryKeys.java | 38 +++++++++++++++++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/extensions-core/lookups-cached-single/pom.xml b/extensions-core/lookups-cached-single/pom.xml index 6c7d42afcf9..3c28f3b777e 100644 --- a/extensions-core/lookups-cached-single/pom.xml +++ b/extensions-core/lookups-cached-single/pom.xml @@ -56,11 +56,6 @@ org.mapdb mapdb - - io.dropwizard - dropwizard-jdbi - 0.9.2 - org.antlr stringtemplate diff --git a/extensions-core/lookups-cached-single/src/main/java/io/druid/server/lookup/jdbc/QueryKeys.java b/extensions-core/lookups-cached-single/src/main/java/io/druid/server/lookup/jdbc/QueryKeys.java index dce03904dd3..47bd4b19f7e 100644 --- a/extensions-core/lookups-cached-single/src/main/java/io/druid/server/lookup/jdbc/QueryKeys.java +++ b/extensions-core/lookups-cached-single/src/main/java/io/druid/server/lookup/jdbc/QueryKeys.java @@ -21,19 +21,19 @@ package io.druid.server.lookup.jdbc; import com.google.common.collect.ImmutableSet; -import io.dropwizard.jdbi.ImmutableSetContainerFactory; +import org.skife.jdbi.v2.ContainerBuilder; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.customizers.Define; import org.skife.jdbi.v2.sqlobject.customizers.RegisterContainerMapper; import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator; +import org.skife.jdbi.v2.tweak.ContainerFactory; import org.skife.jdbi.v2.unstable.BindIn; import java.util.List; import java.util.Map; - @UseStringTemplate3StatementLocator() -@RegisterContainerMapper(ImmutableSetContainerFactory.class) +@RegisterContainerMapper(QueryKeys.QueryKeysContainerFactory.class) public interface QueryKeys { @SqlQuery("SELECT , FROM WHERE IN ()") @@ -43,5 +43,35 @@ public interface QueryKeys @Define("keyColumn") String keyColumn, @Define("valueColumn") String valueColumn ); -} + static class QueryKeysContainerFactory implements ContainerFactory> + { + @Override + public boolean accepts(Class type) + { + return ImmutableSet.class.isAssignableFrom(type); + } + + @Override + public ContainerBuilder> newContainerBuilderFor(Class type) + { + return new ContainerBuilder>() + { + final ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); + + @Override + public ContainerBuilder> add(final Object obj) + { + builder.add(obj); + return this; + } + + @Override + public ImmutableSet build() + { + return builder.build(); + } + }; + } + } +}