From 1a54f0fb098526fc9a4f6fa99f6b818444cc985a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 5 Oct 2014 13:57:10 -0700 Subject: [PATCH] JCLOUDS-153 Remove deprecated ExecutorService and HttpAsyncClient accessors. --- .../jclouds/compute/internal/UtilsImpl.java | 14 ++------- .../internal/BaseComputeServiceLiveTest.java | 8 ++++- .../src/main/java/org/jclouds/rest/Utils.java | 24 -------------- .../jclouds/rest/config/HttpApiModule.java | 3 -- .../org/jclouds/rest/internal/UtilsImpl.java | 31 ++----------------- 5 files changed, 12 insertions(+), 68 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java b/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java index 36ac90ba90..980b99932c 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java @@ -18,10 +18,8 @@ package org.jclouds.compute.internal; import java.util.Map; -import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.Constants; import org.jclouds.compute.Utils; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.crypto.Crypto; @@ -36,7 +34,6 @@ import org.jclouds.xml.XMLParser; import com.google.common.base.Function; import com.google.common.eventbus.EventBus; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; import com.google.inject.Injector; @@ -46,15 +43,10 @@ public class UtilsImpl extends org.jclouds.rest.internal.UtilsImpl implements Ut private Factory sshFactory; private final Function sshForNode; - @Inject - UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, - org.jclouds.rest.HttpAsyncClient simpleAsyncClient, Crypto encryption, DateService date, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, - @Named(Constants.PROPERTY_IO_WORKER_THREADS) ListeningExecutorService ioExecutor, EventBus eventBus, - Map credentialStore, LoggerFactory loggerFactory, + @Inject UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, Crypto encryption, + DateService date, EventBus eventBus, Map credentialStore, LoggerFactory loggerFactory, Function sshForNode) { - super(injector, json, xml, simpleClient, simpleAsyncClient, encryption, date, userExecutor, ioExecutor, eventBus, - credentialStore, loggerFactory); + super(injector, json, xml, simpleClient, encryption, date, eventBus, credentialStore, loggerFactory); this.sshForNode = sshForNode; } diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index a98d4814d7..3509196203 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -33,6 +33,7 @@ import static java.lang.String.format; import static java.lang.System.currentTimeMillis; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.logging.Logger.getAnonymousLogger; +import static org.jclouds.Constants.PROPERTY_USER_THREADS; import static org.jclouds.compute.options.RunScriptOptions.Builder.nameTask; import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript; import static org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials; @@ -63,6 +64,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import javax.inject.Named; + import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeTestUtils; @@ -111,7 +114,9 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.name.Names; @Test(groups = { "integration", "live" }, singleThreaded = true) public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceContextLiveTest { @@ -448,7 +453,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte final long timeoutMs = 20 * 60 * 1000; List groups = Lists.newArrayList(); List> futures = Lists.newArrayList(); - ListeningExecutorService userExecutor = MoreExecutors.listeningDecorator(context.utils().userExecutor()); + ListeningExecutorService userExecutor = context.utils().injector() + .getInstance(Key.get(ListeningExecutorService.class, Names.named(PROPERTY_USER_THREADS))); try { for (int i = 0; i < 2; i++) { diff --git a/core/src/main/java/org/jclouds/rest/Utils.java b/core/src/main/java/org/jclouds/rest/Utils.java index dc7ac50366..f197702082 100644 --- a/core/src/main/java/org/jclouds/rest/Utils.java +++ b/core/src/main/java/org/jclouds/rest/Utils.java @@ -28,7 +28,6 @@ import org.jclouds.xml.XMLParser; import com.google.common.annotations.Beta; import com.google.common.eventbus.EventBus; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.ImplementedBy; import com.google.inject.Injector; @@ -56,34 +55,12 @@ public interface Utils { Json json(); - /** - * - * @deprecated will be removed in jclouds 1.7, as async interfaces are no - * longer supported. - */ - @Deprecated - HttpAsyncClient asyncHttp(); - HttpClient http(); Crypto crypto(); DateService date(); - /** - * @deprecated will be removed in jclouds 1.7, as async interfaces are no - * longer supported. - */ - @Deprecated - ListeningExecutorService userExecutor(); - - /** - * @deprecated will be removed in jclouds 1.7, as async interfaces are no - * longer supported. - */ - @Deprecated - ListeningExecutorService ioExecutor(); - EventBus eventBus(); LoggerFactory loggerFactory(); @@ -92,5 +69,4 @@ public interface Utils { Injector injector(); XMLParser xml(); - } diff --git a/core/src/main/java/org/jclouds/rest/config/HttpApiModule.java b/core/src/main/java/org/jclouds/rest/config/HttpApiModule.java index dbfdb0fc12..820ee685f0 100644 --- a/core/src/main/java/org/jclouds/rest/config/HttpApiModule.java +++ b/core/src/main/java/org/jclouds/rest/config/HttpApiModule.java @@ -21,7 +21,6 @@ import static org.jclouds.rest.config.BinderUtils.bindHttpApi; import org.jclouds.reflect.Invocation; import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.rest.internal.InvokeHttpMethod; @@ -56,8 +55,6 @@ public class HttpApiModule extends RestModule { }).to(InvokeHttpMethod.class); bindHttpApi(binder(), api); bindHttpApi(binder(), HttpClient.class); - // TODO: remove when references are gone - bindHttpApi(binder(), HttpAsyncClient.class); bindErrorHandlers(); bindRetryHandlers(); } diff --git a/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java b/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java index c7562701bc..6b32d79af9 100644 --- a/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java +++ b/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java @@ -19,9 +19,7 @@ package org.jclouds.rest.internal; import java.util.Map; import javax.inject.Inject; -import javax.inject.Named; -import org.jclouds.Constants; import org.jclouds.crypto.Crypto; import org.jclouds.date.DateService; import org.jclouds.domain.Credentials; @@ -33,7 +31,6 @@ import org.jclouds.xml.XMLParser; import com.google.common.annotations.Beta; import com.google.common.eventbus.EventBus; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Injector; import com.google.inject.Singleton; @@ -42,11 +39,8 @@ public class UtilsImpl implements Utils { private final Json json; private final HttpClient simpleClient; - private final org.jclouds.rest.HttpAsyncClient simpleAsyncClient; private final Crypto encryption; private final DateService date; - private final ListeningExecutorService userExecutor; - private final ListeningExecutorService ioExecutor; private final EventBus eventBus; private final Map credentialStore; private final LoggerFactory loggerFactory; @@ -54,30 +48,19 @@ public class UtilsImpl implements Utils { private XMLParser xml; @Inject - protected UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, org.jclouds.rest.HttpAsyncClient simpleAsyncClient, - Crypto encryption, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, - @Named(Constants.PROPERTY_IO_WORKER_THREADS) ListeningExecutorService ioExecutor, EventBus eventBus, - Map credentialStore, LoggerFactory loggerFactory) { + protected UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, Crypto encryption, + DateService date, EventBus eventBus, Map credentialStore, LoggerFactory loggerFactory) { this.injector = injector; this.json = json; this.simpleClient = simpleClient; - this.simpleAsyncClient = simpleAsyncClient; this.encryption = encryption; this.date = date; - this.userExecutor = userExecutor; - this.ioExecutor = ioExecutor; this.eventBus = eventBus; this.credentialStore = credentialStore; this.loggerFactory = loggerFactory; this.xml = xml; } - @Override - @Deprecated - public org.jclouds.rest.HttpAsyncClient asyncHttp() { - return simpleAsyncClient; - } - @Override public DateService date() { return date; @@ -93,16 +76,6 @@ public class UtilsImpl implements Utils { return simpleClient; } - @Override - public ListeningExecutorService ioExecutor() { - return ioExecutor; - } - - @Override - public ListeningExecutorService userExecutor() { - return userExecutor; - } - @Override public EventBus eventBus() { return eventBus;