From f66837de7cf64a603b6df8d0a984d61f74506f48 Mon Sep 17 00:00:00 2001 From: Jared Stehler Date: Fri, 12 Apr 2024 10:18:48 -0400 Subject: [PATCH 1/2] move deprecated guice module to slack-java-client-guice --- .../slack/client/guice/SlackClientModule.java | 35 ++++++++++++------- .../slack/client/SlackClientModule.java | 31 ---------------- .../http/SlackClientModuleTest.java | 21 ++++++----- 3 files changed, 32 insertions(+), 55 deletions(-) delete mode 100644 slack-java-client/src/main/java/com/hubspot/slack/client/SlackClientModule.java diff --git a/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java b/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java index bcbbaa93..bd16326c 100644 --- a/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java +++ b/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java @@ -1,23 +1,32 @@ package com.hubspot.slack.client.guice; import com.google.inject.AbstractModule; +import com.hubspot.slack.client.SlackClientFactory; +import com.hubspot.slack.client.SlackWebClient; +import com.hubspot.slack.client.http.NioHttpClient; +import com.hubspot.slack.client.http.NioHttpClientFactory; import com.hubspot.slack.client.request.verifier.SlackRequestVerifierModule; public class SlackClientModule extends AbstractModule { - @Override - protected void configure() { - install(new com.hubspot.slack.client.SlackClientModule()); - install(new SlackRequestVerifierModule()); - } + @Override + protected void configure() { + bind(NioHttpClientFactory.class).toInstance(NioHttpClientFactory.defaultFactory()); + bind(NioHttpClient.Factory.class).toInstance(NioHttpClientFactory.defaultFactory()); - @Override - public boolean equals(Object o) { - return o != null && getClass().equals(o.getClass()); - } + bind(SlackClientFactory.class).toInstance(SlackClientFactory.defaultFactory()); + bind(SlackWebClient.Factory.class).toInstance(SlackClientFactory.defaultFactory()); - @Override - public int hashCode() { - return getClass().hashCode(); - } + install(new SlackRequestVerifierModule()); + } + + @Override + public boolean equals(Object o) { + return o != null && getClass().equals(o.getClass()); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } } diff --git a/slack-java-client/src/main/java/com/hubspot/slack/client/SlackClientModule.java b/slack-java-client/src/main/java/com/hubspot/slack/client/SlackClientModule.java deleted file mode 100644 index a509cf2e..00000000 --- a/slack-java-client/src/main/java/com/hubspot/slack/client/SlackClientModule.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hubspot.slack.client; - -import com.google.inject.AbstractModule; -import com.hubspot.slack.client.http.NioHttpClient; -import com.hubspot.slack.client.http.NioHttpClientFactory; - -/** - * Use slack-java-client-guice module instead - */ -@Deprecated -public class SlackClientModule extends AbstractModule { - - @Override - protected void configure() { - bind(NioHttpClientFactory.class).toInstance(NioHttpClientFactory.defaultFactory()); - bind(NioHttpClient.Factory.class).toInstance(NioHttpClientFactory.defaultFactory()); - - bind(SlackClientFactory.class).toInstance(SlackClientFactory.defaultFactory()); - bind(SlackWebClient.Factory.class).toInstance(SlackClientFactory.defaultFactory()); - } - - @Override - public boolean equals(Object o) { - return o != null && getClass().equals(o.getClass()); - } - - @Override - public int hashCode() { - return getClass().hashCode(); - } -} diff --git a/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java b/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java index c7721577..f3e1af05 100644 --- a/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java +++ b/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java @@ -3,23 +3,22 @@ import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Stage; -import com.hubspot.slack.client.SlackClientModule; import org.junit.Test; public class SlackClientModuleTest { - @Test - public void itGuices() { - Guice.createInjector(Stage.TOOL, new StrictGuiceModule()); - } + @Test + public void itGuices() { + Guice.createInjector(Stage.TOOL, new StrictGuiceModule()); + } - private static class StrictGuiceModule extends AbstractModule { + private static class StrictGuiceModule extends AbstractModule { - @Override - protected void configure() { - binder().requireAtInjectOnConstructors(); + @Override + protected void configure() { + binder().requireAtInjectOnConstructors(); - install(new SlackClientModule()); + install(new SlackClientModule()); + } } - } } From 594d35a2e668a5d1477dbf4afd879330e2261c17 Mon Sep 17 00:00:00 2001 From: Jared Stehler Date: Fri, 12 Apr 2024 11:13:59 -0400 Subject: [PATCH 2/2] fully move guice dependencies into slack-java-client-guice module --- .../slack/client/guice/SlackClientModule.java | 32 +++++++++---------- .../client/guice/SlackClientModuleTest.java | 1 - slack-java-client/pom.xml | 9 ------ .../hubspot/slack/client/SlackWebClient.java | 7 ++-- .../slack/client/http/NioHttpClient.java | 7 ++-- .../http/SlackClientModuleTest.java | 24 -------------- 6 files changed, 20 insertions(+), 60 deletions(-) delete mode 100644 slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java diff --git a/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java b/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java index bd16326c..efccab07 100644 --- a/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java +++ b/slack-java-client-guice/src/main/java/com/hubspot/slack/client/guice/SlackClientModule.java @@ -9,24 +9,24 @@ public class SlackClientModule extends AbstractModule { - @Override - protected void configure() { - bind(NioHttpClientFactory.class).toInstance(NioHttpClientFactory.defaultFactory()); - bind(NioHttpClient.Factory.class).toInstance(NioHttpClientFactory.defaultFactory()); + @Override + protected void configure() { + bind(NioHttpClientFactory.class).toInstance(NioHttpClientFactory.defaultFactory()); + bind(NioHttpClient.Factory.class).toInstance(NioHttpClientFactory.defaultFactory()); - bind(SlackClientFactory.class).toInstance(SlackClientFactory.defaultFactory()); - bind(SlackWebClient.Factory.class).toInstance(SlackClientFactory.defaultFactory()); + bind(SlackClientFactory.class).toInstance(SlackClientFactory.defaultFactory()); + bind(SlackWebClient.Factory.class).toInstance(SlackClientFactory.defaultFactory()); - install(new SlackRequestVerifierModule()); - } + install(new SlackRequestVerifierModule()); + } - @Override - public boolean equals(Object o) { - return o != null && getClass().equals(o.getClass()); - } + @Override + public boolean equals(Object o) { + return o != null && getClass().equals(o.getClass()); + } - @Override - public int hashCode() { - return getClass().hashCode(); - } + @Override + public int hashCode() { + return getClass().hashCode(); + } } diff --git a/slack-java-client-guice/src/test/java/com/hubspot/slack/client/guice/SlackClientModuleTest.java b/slack-java-client-guice/src/test/java/com/hubspot/slack/client/guice/SlackClientModuleTest.java index e3ec1181..c265e90d 100644 --- a/slack-java-client-guice/src/test/java/com/hubspot/slack/client/guice/SlackClientModuleTest.java +++ b/slack-java-client-guice/src/test/java/com/hubspot/slack/client/guice/SlackClientModuleTest.java @@ -33,7 +33,6 @@ protected void configure() { binder().requireAtInjectOnConstructors(); install(new SlackClientModule()); - install(new com.hubspot.slack.client.SlackClientModule()); } } ); diff --git a/slack-java-client/pom.xml b/slack-java-client/pom.xml index fa8af36d..c95c933f 100644 --- a/slack-java-client/pom.xml +++ b/slack-java-client/pom.xml @@ -32,15 +32,6 @@ guava - - - com.google.inject - guice - - - com.google.inject.extensions - guice-assistedinject - com.hubspot algebra diff --git a/slack-java-client/src/main/java/com/hubspot/slack/client/SlackWebClient.java b/slack-java-client/src/main/java/com/hubspot/slack/client/SlackWebClient.java index 69b85839..442aaeef 100644 --- a/slack-java-client/src/main/java/com/hubspot/slack/client/SlackWebClient.java +++ b/slack-java-client/src/main/java/com/hubspot/slack/client/SlackWebClient.java @@ -7,8 +7,6 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Multimap; -import com.google.inject.assistedinject.Assisted; -import com.google.inject.assistedinject.AssistedInject; import com.hubspot.algebra.Result; import com.hubspot.horizon.HttpConfig; import com.hubspot.horizon.HttpRequest; @@ -218,16 +216,15 @@ public class SlackWebClient implements SlackClient { private final ResponseDebugger responseDebugger; public interface Factory { - SlackWebClient build(@Assisted SlackClientRuntimeConfig config); + SlackWebClient build(SlackClientRuntimeConfig config); } - @AssistedInject public SlackWebClient( DefaultHttpRequestDebugger defaultHttpRequestDebugger, DefaultHttpResponseDebugger defaultHttpResponseDebugger, NioHttpClient.Factory nioHttpClientFactory, ByMethodRateLimiter defaultRateLimiter, - @Assisted SlackClientRuntimeConfig config + SlackClientRuntimeConfig config ) { this.nioHttpClient = config diff --git a/slack-java-client/src/main/java/com/hubspot/slack/client/http/NioHttpClient.java b/slack-java-client/src/main/java/com/hubspot/slack/client/http/NioHttpClient.java index 677cbddb..0d0cef1f 100644 --- a/slack-java-client/src/main/java/com/hubspot/slack/client/http/NioHttpClient.java +++ b/slack-java-client/src/main/java/com/hubspot/slack/client/http/NioHttpClient.java @@ -1,8 +1,6 @@ package com.hubspot.slack.client.http; import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.Inject; -import com.google.inject.assistedinject.Assisted; import com.hubspot.horizon.AsyncHttpClient; import com.hubspot.horizon.AsyncHttpClient.Callback; import com.hubspot.horizon.HttpRequest; @@ -27,11 +25,10 @@ public class NioHttpClient implements Closeable { private final AsyncHttpClient delegate; public interface Factory { - NioHttpClient wrap(@Assisted AsyncHttpClient delegate); + NioHttpClient wrap(AsyncHttpClient delegate); } - @Inject - public NioHttpClient(@Assisted AsyncHttpClient delegate) { + public NioHttpClient(AsyncHttpClient delegate) { this.delegate = delegate; } diff --git a/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java b/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java deleted file mode 100644 index f3e1af05..00000000 --- a/slack-java-client/src/test/java/com/hubspot/slack/client/interceptors/http/SlackClientModuleTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.hubspot.slack.client.interceptors.http; - -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Stage; -import org.junit.Test; - -public class SlackClientModuleTest { - - @Test - public void itGuices() { - Guice.createInjector(Stage.TOOL, new StrictGuiceModule()); - } - - private static class StrictGuiceModule extends AbstractModule { - - @Override - protected void configure() { - binder().requireAtInjectOnConstructors(); - - install(new SlackClientModule()); - } - } -}