You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/10/07 00:31:19 UTC
[42/52] [abbrv] git commit: JCLOUDS-152 remove RestContext and its
dependencies.
JCLOUDS-152 remove RestContext and its dependencies.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/c3497536
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/c3497536
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/c3497536
Branch: refs/heads/use-agentproxy-008
Commit: c349753624e247e9875589e869c8a2e92152f5c7
Parents: 7bab2dd
Author: Adrian Cole <ad...@gmail.com>
Authored: Sun Oct 5 17:59:25 2014 -0700
Committer: Adrian Cole <ad...@gmail.com>
Committed: Sun Oct 5 22:32:55 2014 -0700
----------------------------------------------------------------------
.../main/java/org/jclouds/ContextBuilder.java | 45 +--
.../java/org/jclouds/apis/ApiPredicates.java | 30 --
...xtWithWildcardExtendsExplicitAndRawType.java | 69 ----
.../providers/AnonymousProviderMetadata.java | 5 -
.../jclouds/rest/AnonymousRestApiMetadata.java | 73 ----
.../org/jclouds/rest/ConfiguresRestClient.java | 32 --
.../java/org/jclouds/rest/HttpAsyncClient.java | 88 -----
.../java/org/jclouds/rest/RestApiMetadata.java | 55 ---
.../AnnotatedSyncToAsyncHttpApiProvider.java | 56 ---
.../org/jclouds/rest/config/BinderUtils.java | 94 -----
.../rest/config/CallGetOnFuturesProvider.java | 57 ---
.../jclouds/rest/config/RestClientModule.java | 119 ------
.../rest/config/SyncToAsyncHttpApiProvider.java | 57 ---
.../config/SyncToAsyncHttpInvocationModule.java | 145 -------
.../rest/internal/BaseRestApiMetadata.java | 120 ------
...otentiallySyncToAsyncInvocationFunction.java | 72 ----
.../internal/InvokeSyncToAsyncHttpMethod.java | 273 --------------
.../java/org/jclouds/ContextBuilderTest.java | 16 +-
.../apis/JcloudsTestBlobStoreApiMetadata.java | 9 +-
.../apis/JcloudsTestComputeApiMetadata.java | 9 +-
...JcloudsTestYetAnotherComputeApiMetadata.java | 9 +-
...thWildcardExtendsExplicitAndRawTypeTest.java | 117 ------
...thWildcardExtendsExplicitAndRawTypeTest.java | 123 ------
.../java/org/jclouds/http/BaseJettyTest.java | 6 +-
.../http/IntegrationTestAsyncClient.java | 209 -----------
.../BackoffLimitedRetryHandlerTest.java | 4 +-
.../handlers/RedirectionRetryHandlerTest.java | 9 +-
...oviderMetadataContextAndCredentialsTest.java | 15 +-
...pdateProviderMetadataFromPropertiesTest.java | 9 +-
.../jclouds/rest/InputParamValidatorTest.java | 9 +-
.../rest/annotationparsing/ClosableApiTest.java | 8 +-
.../DelegateAnnotationExpectTest.java | 47 +--
.../JAXBResponseParserAnnotationExpectTest.java | 24 +-
.../ProvidesAnnotationExpectTest.java | 31 +-
.../config/MappedHttpInvocationModuleTest.java | 114 ------
.../rest/internal/BaseAsyncClientTest.java | 25 --
.../rest/internal/BaseRestApiExpectTest.java | 2 -
.../rest/internal/BaseRestApiMetadataTest.java | 46 ---
.../internal/InvokeMappedHttpMethodTest.java | 171 ---------
.../internal/RestAnnotationProcessorTest.java | 373 +++++--------------
40 files changed, 178 insertions(+), 2597 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/ContextBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java
index 8e98b64..020d728 100644
--- a/core/src/main/java/org/jclouds/ContextBuilder.java
+++ b/core/src/main/java/org/jclouds/ContextBuilder.java
@@ -18,12 +18,10 @@ package org.jclouds;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.containsPattern;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Predicates.not;
import static com.google.common.base.Predicates.notNull;
-import static com.google.common.base.Predicates.or;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.addAll;
import static com.google.common.collect.Iterables.any;
@@ -43,6 +41,7 @@ import static org.jclouds.Constants.PROPERTY_IDENTITY;
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
import static org.jclouds.Constants.PROPERTY_PROVIDER;
import static org.jclouds.reflect.Reflection2.typeToken;
+import static org.jclouds.rest.config.BinderUtils.bindHttpApi;
import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException;
import java.io.Closeable;
@@ -60,7 +59,6 @@ import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.config.BindApiContextWithWildcardExtendsExplicitAndRawType;
import org.jclouds.config.BindNameToContext;
import org.jclouds.config.BindPropertiesToExpandedValues;
-import org.jclouds.config.BindRestContextWithWildcardExtendsExplicitAndRawType;
import org.jclouds.domain.Credentials;
import org.jclouds.events.config.ConfiguresEventBus;
import org.jclouds.events.config.EventBusModule;
@@ -74,16 +72,15 @@ import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.Providers;
import org.jclouds.providers.config.BindProviderMetadataContextAndCredentials;
import org.jclouds.providers.internal.UpdateProviderMetadataFromProperties;
+import org.jclouds.reflect.Invocation;
import org.jclouds.rest.ConfiguresCredentialStore;
import org.jclouds.rest.ConfiguresHttpApi;
-import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.HttpApiMetadata;
-import org.jclouds.rest.RestApiMetadata;
+import org.jclouds.rest.HttpClient;
import org.jclouds.rest.config.CredentialStoreModule;
import org.jclouds.rest.config.HttpApiModule;
-import org.jclouds.rest.config.SyncToAsyncHttpInvocationModule;
-import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.config.RestModule;
+import org.jclouds.rest.internal.InvokeHttpMethod;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -100,6 +97,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.reflect.TypeToken;
import com.google.common.util.concurrent.ExecutionList;
+import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
@@ -427,13 +425,6 @@ public class ContextBuilder {
} catch (IllegalArgumentException ignored) {
}
- } else if (apiMetadata instanceof RestApiMetadata) {
- try {
- modules.add(new BindRestContextWithWildcardExtendsExplicitAndRawType(RestApiMetadata.class
- .cast(apiMetadata)));
- } catch (IllegalArgumentException ignored) {
-
- }
}
}
@@ -455,7 +446,7 @@ public class ContextBuilder {
});
if (restModuleSpecifiedByUser)
- defaultModules = filter(defaultModules, and(not(configuresApi), not(configuresRest)));
+ defaultModules = filter(defaultModules, not(configuresApi));
return defaultModules;
}
@@ -493,7 +484,7 @@ public class ContextBuilder {
}
}
private static boolean apiModulePresent(List<Module> modules) {
- return any(modules, or(configuresApi, configuresRest));
+ return any(modules, configuresApi);
}
private static Predicate<Module> configuresApi = new Predicate<Module>() {
@@ -503,25 +494,22 @@ public class ContextBuilder {
};
- private static Predicate<Module> configuresRest = new Predicate<Module>() {
- public boolean apply(Module input) {
- return input.getClass().isAnnotationPresent(ConfiguresRestClient.class);
- }
-
- };
-
@SuppressWarnings({ "unchecked", "rawtypes" })
static void addClientModule(ApiMetadata apiMetadata, List<Module> modules) {
// TODO: move this up
if (apiMetadata instanceof HttpApiMetadata) {
HttpApiMetadata api = HttpApiMetadata.class.cast(apiMetadata);
modules.add(new HttpApiModule(api.getApi()));
- } else if (apiMetadata instanceof RestApiMetadata) {
- RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata);
- modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi())));
} else {
modules.add(new RestModule());
- modules.add(new SyncToAsyncHttpInvocationModule());
+ // Minimally bind HttpClient so that Utils works.
+ modules.add(new AbstractModule() {
+ @Override public void configure() {
+ bind(new TypeLiteral<Function<Invocation, Object>>() {
+ }).to(InvokeHttpMethod.class);
+ bindHttpApi(binder(), HttpClient.class);
+ }
+ });
}
}
@@ -570,12 +558,13 @@ public class ContextBuilder {
)) {
modules.add(new CredentialStoreModule());
}
+
}
/**
* Builds the base context for this api. Note that this may be of type {@link Closer}, if nothing
* else was configured via {@link ApiMetadata#getContext()}. Typically, the type returned is
- * {@link RestContext}
+ * {@link ApiContext}
*
* @see ApiMetadata#getContext()
* @see #build(TypeToken)
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/apis/ApiPredicates.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/apis/ApiPredicates.java b/core/src/main/java/org/jclouds/apis/ApiPredicates.java
index f87ce58..f75fe3a 100644
--- a/core/src/main/java/org/jclouds/apis/ApiPredicates.java
+++ b/core/src/main/java/org/jclouds/apis/ApiPredicates.java
@@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.emptyToNull;
import org.jclouds.View;
-import org.jclouds.rest.RestApiMetadata;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -70,35 +69,6 @@ public class ApiPredicates {
}
/**
- * Returns all apis with the given type.
- *
- * @param type
- * the type of the api to return
- *
- * @return the apis with the given type
- */
- public static Predicate<RestApiMetadata> apiAssignableFrom(final TypeToken<?> type) {
- checkNotNull(type, "type must be defined");
- return new Predicate<RestApiMetadata>() {
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean apply(RestApiMetadata apiMetadata) {
- return type.isAssignableFrom(apiMetadata.getApi());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "contextAssignableFrom(" + type + ")";
- }
- };
- }
-
- /**
* Returns all apis who's contexts are assignable from the parameter
*
* @param type
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java b/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java
deleted file mode 100644
index 0b8b7da..0000000
--- a/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.config;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-import org.jclouds.rest.RestApiMetadata;
-import org.jclouds.rest.RestContext;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
-import org.jclouds.rest.internal.RestContextImpl;
-
-import com.google.common.reflect.TypeToken;
-import com.google.inject.AbstractModule;
-import com.google.inject.TypeLiteral;
-import com.google.inject.util.Types;
-
-/**
- * Allows you to lookup the {@link RestApiMetadata#getContext()} as {@link RestContext}, {@code RestContext<Client, AsyncClient>}, and {@code
- *
- * @deprecated please use {@link BindApiContextWithWildcardExtendsExplicitAndRawType} as
- * async interface will be removed in jclouds 1.7.
- */
-@Deprecated
-public class BindRestContextWithWildcardExtendsExplicitAndRawType extends AbstractModule {
- private final RestApiMetadata restApiMetadata;
-
- public BindRestContextWithWildcardExtendsExplicitAndRawType(RestApiMetadata restApiMetadata)
- throws IllegalArgumentException {
- this.restApiMetadata = checkNotNull(restApiMetadata, "restApiMetadata");
- checkArgument(restApiMetadata.getContext().getRawType().equals(RestContext.class),
- "this does not work as %s raw type is not RestContext", restApiMetadata.getContext());
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void configure() {
- TypeToken<?> concreteType = BaseRestApiMetadata.contextToken(typeToken(restApiMetadata.getApi()),
- typeToken(restApiMetadata.getAsyncApi()));
- // bind explicit type
- bind(TypeLiteral.get(concreteType.getType())).to(
- TypeLiteral.class.cast(TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class,
- restApiMetadata.getApi(), restApiMetadata.getAsyncApi()))));
- // bind potentially wildcard type
- if (!concreteType.equals(restApiMetadata.getContext())) {
- bind(TypeLiteral.get(restApiMetadata.getContext().getType())).to(
- TypeLiteral.class.cast(TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class,
- restApiMetadata.getApi(), restApiMetadata.getAsyncApi()))));
- }
- // bind w/o types
- bind(TypeLiteral.get(RestContext.class)).to(
- TypeLiteral.class.cast(TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class,
- restApiMetadata.getApi(), restApiMetadata.getAsyncApi()))));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java
index d413158..2208376 100644
--- a/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java
+++ b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java
@@ -21,7 +21,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
import org.jclouds.rest.AnonymousHttpApiMetadata;
-import org.jclouds.rest.AnonymousRestApiMetadata;
/**
* Useful in creating arbitrary clients.
@@ -32,10 +31,6 @@ public class AnonymousProviderMetadata extends BaseProviderMetadata {
return forApiWithEndpoint(AnonymousHttpApiMetadata.forApi(api), endpoint);
}
- public static ProviderMetadata forClientMappedToAsyncClientOnEndpoint(Class<?> client, Class<?> asyncClient,
- String endpoint) {
- return forApiWithEndpoint(AnonymousRestApiMetadata.forClientMappedToAsyncClient(client, asyncClient), endpoint);
- }
public static ProviderMetadata forApiWithEndpoint(ApiMetadata md, String endpoint) {
checkNotNull(md, "api");
checkNotNull(endpoint, "endpoint (%s)", md.getEndpointName());
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java
deleted file mode 100644
index 64d89c1..0000000
--- a/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest;
-
-import java.net.URI;
-
-import org.jclouds.rest.internal.BaseRestApiMetadata;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Useful in creating arbitrary clients.
- *
- * @deprecated please use {@link AnonymousHttpApiMetadata} as
- * async interface will be removed in jclouds 1.7.
- */
-@Beta
-@Deprecated
-public class AnonymousRestApiMetadata extends BaseRestApiMetadata {
-
- public static AnonymousRestApiMetadata forClientMappedToAsyncClient(Class<?> client, Class<?> asyncClient) {
- return new AnonymousRestApiMetadata(client, asyncClient);
- }
-
- @Override
- public Builder toBuilder() {
- return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
- }
-
- public AnonymousRestApiMetadata(Class<?> client, Class<?> asyncClient) {
- super(new Builder(client, asyncClient));
- }
-
- protected AnonymousRestApiMetadata(Builder builder) {
- super(builder);
- }
-
- public static final class Builder extends BaseRestApiMetadata.Builder<Builder> {
-
- public Builder(Class<?> client, Class<?> asyncClient) {
- super(client, asyncClient);
- id(client.getSimpleName())
- .identityName("unused")
- .defaultIdentity("foo")
- .version("1")
- .documentation(URI.create("http://jclouds.org/documentation"));
- }
-
- @Override
- public AnonymousRestApiMetadata build() {
- return new AnonymousRestApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/ConfiguresRestClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/ConfiguresRestClient.java b/core/src/main/java/org/jclouds/rest/ConfiguresRestClient.java
deleted file mode 100644
index f60c8be..0000000
--- a/core/src/main/java/org/jclouds/rest/ConfiguresRestClient.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * designates the module configures a Client to a cloud.
- */
-@Retention(RUNTIME)
-@Target(TYPE)
-public @interface ConfiguresRestClient {
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/HttpAsyncClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/HttpAsyncClient.java b/core/src/main/java/org/jclouds/rest/HttpAsyncClient.java
deleted file mode 100644
index 8d519d7..0000000
--- a/core/src/main/java/org/jclouds/rest/HttpAsyncClient.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest;
-
-import java.io.InputStream;
-import java.net.URI;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-
-import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseETagHeader;
-import org.jclouds.io.Payload;
-import org.jclouds.rest.annotations.EndpointParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Simple rest client
- *
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no longer
- * supported.
- */
-@Deprecated
-public interface HttpAsyncClient {
- /**
- * @see HttpClient#put
- */
- @PUT
- @ResponseParser(ParseETagHeader.class)
- ListenableFuture<String> put(@EndpointParam URI location, Payload payload);
-
- /**
- * @see HttpClient#post
- */
- @POST
- @ResponseParser(ParseETagHeader.class)
- ListenableFuture<String> post(@EndpointParam URI location, Payload payload);
-
- /**
- * @see HttpClient#exists
- */
- @HEAD
- @Fallback(FalseOnNotFoundOr404.class)
- ListenableFuture<Boolean> exists(@EndpointParam URI location);
-
- /**
- * @see HttpClient#get
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<InputStream> get(@EndpointParam URI location);
-
- /**
- * @see HttpClient#invoke
- */
- ListenableFuture<HttpResponse> invoke(HttpRequest request);
-
- /**
- * @see HttpClient#delete
- */
- @DELETE
- @Fallback(FalseOnNotFoundOr404.class)
- ListenableFuture<Boolean> delete(@EndpointParam URI location);
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/RestApiMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/RestApiMetadata.java b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java
deleted file mode 100644
index 1c5dead..0000000
--- a/core/src/main/java/org/jclouds/rest/RestApiMetadata.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest;
-
-import org.jclouds.apis.ApiMetadata;
-
-import com.google.common.annotations.Beta;
-
-/**
- *
- * @since 1.5
- *
- * @deprecated please use {@link HttpApiMetadata} as
- * async interface will be removed in jclouds 1.7.
- */
-@Deprecated
-@Beta
-public interface RestApiMetadata extends ApiMetadata {
-
- public interface Builder<T extends Builder<T>> extends ApiMetadata.Builder<T> {
-
- /**
- * @see ApiMetadata#getApi()
- * @see ApiMetadata#getAsyncApi()
- */
- T javaApi(Class<?> api, Class<?> asyncApi);
- }
-
- /**
- *
- * @return the type of the api which blocks on all requests
- */
- Class<?> getApi();
-
- /**
- *
- * @return the type of the api, which is the same as {@link #getApi}, except
- * all methods return {@link ListenableFuture}
- */
- Class<?> getAsyncApi();
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/config/AnnotatedSyncToAsyncHttpApiProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/AnnotatedSyncToAsyncHttpApiProvider.java b/core/src/main/java/org/jclouds/rest/config/AnnotatedSyncToAsyncHttpApiProvider.java
deleted file mode 100644
index 6d5d7ac..0000000
--- a/core/src/main/java/org/jclouds/rest/config/AnnotatedSyncToAsyncHttpApiProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.config;
-
-import java.lang.reflect.Proxy;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
-
-import com.google.common.base.Function;
-import com.google.inject.Provider;
-import com.google.inject.TypeLiteral;
-
-/**
- *
- * @deprecated please use {@link DelegatesToInvocationFunction} as async
- * interface will be removed in jclouds 1.7.
- */
-@Deprecated
-@Singleton
-public class AnnotatedSyncToAsyncHttpApiProvider<A> implements Provider<A> {
- private final Class<? super A> annotatedApiType;
- private final DelegatesToPotentiallySyncToAsyncInvocationFunction<A, Function<Invocation, Object>> httpInvoker;
-
- @Inject
- private AnnotatedSyncToAsyncHttpApiProvider(
- DelegatesToPotentiallySyncToAsyncInvocationFunction<A, Function<Invocation, Object>> httpInvoker,
- TypeLiteral<A> annotatedApiType) {
- this.httpInvoker = httpInvoker;
- this.annotatedApiType = annotatedApiType.getRawType();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public A get() {
- return (A) Proxy.newProxyInstance(annotatedApiType.getClassLoader(), new Class<?>[] { annotatedApiType },
- httpInvoker);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
index 0d3c7d8..6e439a0 100644
--- a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
+++ b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
@@ -48,100 +48,6 @@ public class BinderUtils {
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
}
- /**
- * adds an explicit binding for {@code async} by parsing its annotations. Then, adds an explicit binding for an
- * interface which synchronously blocks on similar calls to an {@code async} type.
- *
- * @param <S>
- * sync interface that blocks
- * @param <A>
- * async type where all methods have same args as {@code sync}, but returns {@link ListenableFuture}
- * @param binder
- * guice binder
- * @param sync
- * type interface that blocks
- * @param async
- * type type that returns {@link ListenableFuture}
- *
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no
- * longer supported.
- */
- @Deprecated
- public static <S, A> void bindSyncToAsyncHttpApi(Binder binder, Class<S> sync, Class<A> async) {
- bindClass(binder, sync);
- bindClass(binder, async);
- bindAnnotatedSyncToAsyncHttpApiProvider(binder, async);
- bindHttpApiProvider(binder, sync, async);
- }
-
- /**
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no
- * longer supported.
- */
- @Deprecated
- @SuppressWarnings({ "unchecked", "serial" })
- private static <T> void bindAnnotatedSyncToAsyncHttpApiProvider(Binder binder, Class<T> annotated) {
- TypeToken<AnnotatedSyncToAsyncHttpApiProvider<T>> token = new TypeToken<AnnotatedSyncToAsyncHttpApiProvider<T>>() {
- }.where(new TypeParameter<T>() {
- }, annotated);
- binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
- }
-
- /**
- *
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no
- * longer supported.
- */
- @Deprecated
- @SuppressWarnings({ "unchecked", "serial" })
- private static <S, A> void bindHttpApiProvider(Binder binder, Class<S> sync, Class<A> async) {
- TypeToken<SyncToAsyncHttpApiProvider<S, A>> token = new TypeToken<SyncToAsyncHttpApiProvider<S, A>>() {
- }.where(new TypeParameter<S>() {
- }, sync).where(new TypeParameter<A>() {
- }, async);
- binder.bind(sync).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
- }
-
- /**
- * adds an explicit binding for an interface which synchronously blocks on
- * similar calls to an {@code async} type.
- *
- * @param <S>
- * sync interface that blocks
- * @param <A>
- * async type where all methods have same args as {@code sync}, but
- * returns {@link ListenableFuture}
- * @param binder
- * guice binder
- * @param sync
- * type interface that blocks
- * @param async
- * type type that returns {@link ListenableFuture}
- *
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no
- * longer supported.
- */
- @Deprecated
- public static <S, A> void bindSyncToAsyncApi(Binder binder, Class<S> sync, Class<A> async) {
- bindClass(binder, sync);
- bindClass(binder, async);
- bindCallGetOnFutures(binder, sync, async);
- }
-
- /**
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no
- * longer supported.
- */
- @Deprecated
- @SuppressWarnings({ "unchecked", "serial" })
- private static <S, A> void bindCallGetOnFutures(Binder binder, Class<S> sync, Class<A> async) {
- TypeToken<CallGetOnFuturesProvider<S, A>> token = new TypeToken<CallGetOnFuturesProvider<S, A>>() {
- }.where(new TypeParameter<S>() {
- }, sync).where(new TypeParameter<A>() {
- }, async);
- binder.bind(sync).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
- }
-
@SuppressWarnings({ "unchecked", "serial" })
private static <K> void bindClass(Binder binder, Class<K> sync) {
binder.bind(TypeLiteral.class.cast(TypeLiteral.get(new TypeToken<Class<K>>() {
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java b/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java
deleted file mode 100644
index ee82528..0000000
--- a/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.config;
-
-
-import java.lang.reflect.Proxy;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
-import org.jclouds.rest.internal.InvokeAndCallGetOnFutures;
-
-import com.google.common.cache.Cache;
-import com.google.common.reflect.Invokable;
-import com.google.inject.Provider;
-
-/**
- * @deprecated will be removed in jclouds 1.7, as async interfaces are no longer supported.
- */
-@Deprecated
-@Singleton
-public class CallGetOnFuturesProvider<S, A> implements Provider<S> {
-
- private final Class<? super S> apiType;
- private final DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker;
-
- @Inject
- private CallGetOnFuturesProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
- DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker, Class<S> apiType,
- Class<A> asyncApiType) {
- this.syncInvoker = syncInvoker;
- this.apiType = apiType;
- SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- @Singleton
- public S get() {
- return (S) Proxy.newProxyInstance(apiType.getClassLoader(), new Class<?>[] { apiType }, syncInvoker);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/config/RestClientModule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java
deleted file mode 100644
index 9dfddc1..0000000
--- a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.config;
-
-import static org.jclouds.reflect.Types2.checkBound;
-import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
-
-import java.util.Map;
-
-import org.jclouds.rest.ConfiguresRestClient;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-
-/**
- *
- *
- * @deprecated will be removed in jclouds 1.7; use {@link HttpApiModule}
- */
-@Deprecated
-@ConfiguresRestClient
-public class RestClientModule<S, A> extends RestModule {
- protected final TypeToken<S> syncClientType;
- protected final TypeToken<A> asyncClientType;
-
- private final SyncToAsyncHttpInvocationModule invocationModule;
-
- /**
- * Note that this ctor requires that you instantiate w/resolved generic params. For example, via
- * a subclass of a bound type, or natural instantiation w/resolved type params.
- */
- protected RestClientModule(Map<Class<?>, Class<?>> sync2Async) {
- this.invocationModule = new SyncToAsyncHttpInvocationModule(sync2Async);
- this.syncClientType = checkBound(new TypeToken<S>(getClass()) {
- private static final long serialVersionUID = 1L;
- });
- this.asyncClientType = checkBound(new TypeToken<A>(getClass()) {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * @see #RestClientModule(Map)
- */
- protected RestClientModule() {
- this(ImmutableMap.<Class<?>, Class<?>> of());
- }
-
- /**
- * @see #RestClientModule(TypeToken, TypeToken, Map)
- */
- public RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
- this(syncClientType, asyncClientType, ImmutableMap.<Class<?>, Class<?>> of());
- }
-
- /**
- * only necessary when type params are not resolvable at runtime.
- */
- public RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) {
- this.invocationModule = new SyncToAsyncHttpInvocationModule(sync2Async);
- this.syncClientType = checkBound(syncClientType);
- this.asyncClientType = checkBound(asyncClientType);
- }
-
- @Override
- protected void configure() {
- super.configure();
- install(invocationModule);
- bindSyncToAsyncHttpApi(binder(), syncClientType.getRawType(), asyncClientType.getRawType());
- bindErrorHandlers();
- bindRetryHandlers();
- }
-
- /**
- * overrides this to change the default retry handlers for the http engine
- *
- * ex.
- *
- * <pre>
- * bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(AWSRedirectionRetryHandler.class);
- * bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AWSClientErrorRetryHandler.class);
- * </pre>
- *
- */
- protected void bindRetryHandlers() {
- }
-
- /**
- * overrides this to change the default error handlers for the http engine
- *
- * ex.
- *
- * <pre>
- * bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAWSErrorFromXmlContent.class);
- * bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAWSErrorFromXmlContent.class);
- * bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAWSErrorFromXmlContent.class);
- * </pre>
- *
- *
- */
- protected void bindErrorHandlers() {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpApiProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpApiProvider.java b/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpApiProvider.java
deleted file mode 100644
index 4f492e7..0000000
--- a/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpApiProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.config;
-
-
-import java.lang.reflect.Proxy;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
-
-import com.google.common.base.Function;
-import com.google.common.cache.Cache;
-import com.google.common.reflect.Invokable;
-import com.google.inject.Provider;
-
-/**
- *
- * @deprecated will be removed in jclouds 1.7; use {@link AnnotatedHttpApiProvider}
- */
-@Deprecated
-@Singleton
-public class SyncToAsyncHttpApiProvider<S, A> implements Provider<S> {
- private final Class<? super S> apiType;
- private final DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker;
-
- @Inject
- private SyncToAsyncHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
- DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
- this.httpInvoker = httpInvoker;
- this.apiType = apiType;
- SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- @Singleton
- public S get() {
- return (S) Proxy.newProxyInstance(apiType.getClassLoader(), new Class<?>[] { apiType }, httpInvoker);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpInvocationModule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpInvocationModule.java b/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpInvocationModule.java
deleted file mode 100644
index 3ccb15b..0000000
--- a/core/src/main/java/org/jclouds/rest/config/SyncToAsyncHttpInvocationModule.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.config;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.toArray;
-import static com.google.common.collect.Iterables.transform;
-import static org.jclouds.reflect.Reflection2.method;
-import static org.jclouds.reflect.Reflection2.methods;
-
-import java.io.Closeable;
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.HttpAsyncClient;
-import org.jclouds.rest.HttpClient;
-import org.jclouds.rest.internal.InvokeSyncToAsyncHttpMethod;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.Invokable;
-import com.google.common.reflect.Parameter;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-
-/**
- * supports sync-async mapping
- *
- * @deprecated will be removed in jclouds 1.7; use {@link HttpApiModule}
- */
-@Deprecated
-public class SyncToAsyncHttpInvocationModule extends AbstractModule {
- protected final Map<Class<?>, Class<?>> sync2Async;
-
- public SyncToAsyncHttpInvocationModule() {
- this(ImmutableMap.<Class<?>, Class<?>> of());
- }
-
- public SyncToAsyncHttpInvocationModule(Map<Class<?>, Class<?>> sync2Async) {
- this.sync2Async = sync2Async;
- }
-
- @Override
- protected void configure() {
- bind(new TypeLiteral<Map<Class<?>, Class<?>>>() {
- }).toInstance(sync2Async);
- bind(new TypeLiteral<Function<Invocation, Object>>() {
- }).to(InvokeSyncToAsyncHttpMethod.class);
- BinderUtils.bindSyncToAsyncHttpApi(binder(), HttpClient.class, HttpAsyncClient.class);
- }
-
- /**
- * seeds well-known invokables.
- */
- @Provides
- @Singleton
- protected Cache<Invokable<?, ?>, Invokable<?, ?>> seedKnownSync2AsyncInvokables() {
- return seedKnownSync2AsyncInvokables(sync2Async);
- }
-
- /**
- * function view of above
- *
- * @see InvokeAndCallGetOnFutures
- * @see InvokeSyncToAsyncHttpMethod
- */
- @Provides
- @Singleton
- protected Function<Invocation, Invocation> sync2async(final Cache<Invokable<?, ?>, Invokable<?, ?>> cache) {
- return new Function<Invocation, Invocation>() {
- public Invocation apply(Invocation in) {
- return Invocation.create(
- checkNotNull(cache.getIfPresent(in.getInvokable()), "invokable %s not in %s", in.getInvokable(),
- cache), in.getArgs());
- }
- };
- }
-
- @VisibleForTesting
- static Cache<Invokable<?, ?>, Invokable<?, ?>> seedKnownSync2AsyncInvokables(Map<Class<?>, Class<?>> sync2Async) {
- Cache<Invokable<?, ?>, Invokable<?, ?>> sync2AsyncBuilder = CacheBuilder.newBuilder().build();
- putInvokables(HttpClient.class, HttpAsyncClient.class, sync2AsyncBuilder);
- for (Map.Entry<Class<?>, Class<?>> entry : sync2Async.entrySet()) {
- putInvokables(entry.getKey(), entry.getValue(), sync2AsyncBuilder);
- }
- return sync2AsyncBuilder;
- }
-
- // accessible for ClientProvider
- public static void putInvokables(Class<?> sync, Class<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) {
- for (Invokable<?, ?> invoked : methods(sync)) {
- Invokable<?, ?> delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked));
- checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes())
- || isCloseable(delegatedMethod), "invoked %s has different typed exceptions than target %s", invoked,
- delegatedMethod);
- cache.put(invoked, delegatedMethod);
- }
- }
-
- /**
- * In JDK7 Closeable.close is declared in AutoCloseable, which throws
- * Exception vs IOException, so we have to be more lenient about exception
- * type declarations.
- *
- * <h4>note</h4>
- *
- * This will be refactored out when we delete Async code in jclouds 1.7.
- */
- private static boolean isCloseable(Invokable<?, ?> delegatedMethod) {
- return "close".equals(delegatedMethod.getName())
- && Closeable.class.isAssignableFrom(delegatedMethod.getDeclaringClass());
- }
-
- /**
- * for portability with {@link Class#getMethod(String, Class...)}
- */
- private static Class<?>[] getParameterTypes(Invokable<?, ?> in) {
- return toArray(transform(checkNotNull(in, "invokable").getParameters(), new Function<Parameter, Class<?>>() {
- public Class<?> apply(Parameter input) {
- return input.getType().getRawType();
- }
- }), Class.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java
deleted file mode 100644
index f2a6c48..0000000
--- a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-import java.util.Properties;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.internal.BaseApiMetadata;
-import org.jclouds.rest.RestApiMetadata;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.reflect.TypeParameter;
-import com.google.common.reflect.TypeToken;
-
-/**
- * Useful in creating rest apis.
- *
- * @deprecated please use {@link BaseHttpApiMetadata} as
- * async interface will be removed in jclouds 1.7.
- */
-@Beta
-@Deprecated
-public abstract class BaseRestApiMetadata extends BaseApiMetadata implements RestApiMetadata {
-
- protected final Class<?> api;
- protected final Class<?> asyncApi;
-
- protected BaseRestApiMetadata(Builder<?> builder) {
- super(builder);
- this.api = checkNotNull(builder.api, "api");
- this.asyncApi = checkNotNull(builder.asyncApi, "asyncApi");
- }
-
- public static Properties defaultProperties() {
- Properties props = BaseApiMetadata.defaultProperties();
- return props;
- }
-
- public static <S, A> TypeToken<org.jclouds.rest.RestContext<S, A>> contextToken(TypeToken<S> apiToken, TypeToken<A> asyncApiToken) {
- return new TypeToken<org.jclouds.rest.RestContext<S, A>>() {
- private static final long serialVersionUID = 1L;
- }.where(new TypeParameter<S>() {
- }, apiToken).where(new TypeParameter<A>() {
- }, asyncApiToken);
- }
-
- public abstract static class Builder<T extends Builder<T>> extends BaseApiMetadata.Builder<T> implements RestApiMetadata.Builder<T> {
- protected Class<?> api;
- protected Class<?> asyncApi;
-
- protected Builder(Class<?> api, Class<?> asyncApi) {
- checkNotNull(api, "api");
- checkNotNull(asyncApi, "asyncApi");
- javaApi(api, asyncApi)
- .name(String.format("%s->%s", api.getSimpleName(), asyncApi.getSimpleName()))
- .context(contextToken(typeToken(api), typeToken(asyncApi)))
- .defaultProperties(BaseRestApiMetadata.defaultProperties());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public T javaApi(Class<?> api, Class<?> asyncApi) {
- this.api = checkNotNull(api, "api");
- this.asyncApi = checkNotNull(asyncApi, "asyncApi");
- return self();
- }
-
- @Override
- public T fromApiMetadata(ApiMetadata in) {
- if (in instanceof RestApiMetadata) {
- RestApiMetadata rest = RestApiMetadata.class.cast(in);
- javaApi(rest.getApi(), rest.getAsyncApi());
- }
- super.fromApiMetadata(in);
- return self();
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Class<?> getApi() {
- return api;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Class<?> getAsyncApi() {
- return asyncApi;
- }
-
- @Override
- protected ToStringHelper string() {
- return super.string().add("api", getApi()).add("asyncApi", getAsyncApi());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/internal/DelegatesToPotentiallySyncToAsyncInvocationFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/internal/DelegatesToPotentiallySyncToAsyncInvocationFunction.java b/core/src/main/java/org/jclouds/rest/internal/DelegatesToPotentiallySyncToAsyncInvocationFunction.java
deleted file mode 100644
index cccdc61..0000000
--- a/core/src/main/java/org/jclouds/rest/internal/DelegatesToPotentiallySyncToAsyncInvocationFunction.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.reflect.Invocation;
-import org.jclouds.reflect.InvocationSuccess;
-import org.jclouds.rest.config.SetCaller;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.util.Types;
-
-/**
- * @param <S>
- * The enclosing type of the interface that a dynamic proxy like this
- * implements
- * @param <F>
- * The function that implements this dynamic proxy
- *
- * @deprecated please use {@link DelegatesToInvocationFunction} as
- * async interface will be removed in jclouds 1.7.
- */
-@Deprecated
-@Beta
-public final class DelegatesToPotentiallySyncToAsyncInvocationFunction<S, F extends Function<Invocation, Object>> extends
- DelegatesToInvocationFunction<S, F> {
- private final Map<Class<?>, Class<?>> syncToAsync;
-
- @Inject
- DelegatesToPotentiallySyncToAsyncInvocationFunction(Injector injector, SetCaller setCaller, Class<S> ownerType,
- Function<InvocationSuccess, Optional<Object>> optionalConverter, F methodInvoker,
- Map<Class<?>, Class<?>> syncToAsync) {
- super(injector, setCaller, ownerType, optionalConverter, methodInvoker);
- this.syncToAsync = checkNotNull(syncToAsync, "syncToAsync");
- }
-
- protected Key<?> methodInvokerFor(Class<?> returnType) {
- if (methodInvoker.getClass().getTypeParameters().length == 2) {
- if (syncToAsync.containsValue(returnType))
- return Key.get(Types.newParameterizedType(methodInvoker.getClass(), returnType, returnType));
- return Key.get(Types.newParameterizedType(
- methodInvoker.getClass(),
- returnType,
- checkNotNull(syncToAsync.get(returnType), "need async type of %s for %s", returnType,
- methodInvoker.getClass())));
- }
- return super.methodInvokerFor(returnType);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/main/java/org/jclouds/rest/internal/InvokeSyncToAsyncHttpMethod.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/internal/InvokeSyncToAsyncHttpMethod.java b/core/src/main/java/org/jclouds/rest/internal/InvokeSyncToAsyncHttpMethod.java
deleted file mode 100644
index 1aa5b68..0000000
--- a/core/src/main/java/org/jclouds/rest/internal/InvokeSyncToAsyncHttpMethod.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.rest.internal;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Throwables.propagate;
-import static com.google.common.util.concurrent.Futures.transform;
-import static com.google.common.util.concurrent.Futures.withFallback;
-import static java.util.concurrent.TimeUnit.NANOSECONDS;
-import static org.jclouds.Constants.PROPERTY_USER_THREADS;
-
-import java.util.concurrent.Callable;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpCommandExecutorService;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.logging.Logger;
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.InvocationContext;
-import org.jclouds.rest.config.InvocationConfig;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.reflect.Invokable;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.TimeLimiter;
-
-/**
- * @deprecated will be replaced in jclouds 1.7 with {@link InvokeHttpMethod}, as async interfaces are no longer supported.
- */
-@Deprecated
-public class InvokeSyncToAsyncHttpMethod implements Function<Invocation, Object> {
-
- @Resource
- private Logger logger = Logger.NULL;
-
- private final Function<Invocation, Invocation> sync2async;
- private final Function<Invocation, HttpRequest> annotationProcessor;
- private final HttpCommandExecutorService http;
- private final ListeningExecutorService userExecutor;
- private final TimeLimiter timeLimiter;
- private final Function<HttpRequest, Function<HttpResponse, ?>> transformerForRequest;
- private final InvocationConfig config;
-
- @Inject
- @VisibleForTesting
- InvokeSyncToAsyncHttpMethod(Function<Invocation, Invocation> sync2async, Function<Invocation, HttpRequest> annotationProcessor,
- HttpCommandExecutorService http, Function<HttpRequest, Function<HttpResponse, ?>> transformerForRequest,
- TimeLimiter timeLimiter, InvocationConfig config,
- @Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
- this.sync2async = sync2async;
- this.annotationProcessor = annotationProcessor;
- this.http = http;
- this.userExecutor = userExecutor;
- this.timeLimiter = timeLimiter;
- this.transformerForRequest = transformerForRequest;
- this.config = config;
- }
-
- @Override
- public Object apply(Invocation in) {
- if (isFuture(in.getInvokable())) {
- return submit(in);
- }
- Invocation async = toAsync(in);
- Optional<Long> timeoutNanos = config.getTimeoutNanos(async);
- if (timeoutNanos.isPresent()) {
- return invokeWithTimeout(async, timeoutNanos.get());
- }
- return invoke(async);
- }
-
- /**
- * submits the {@linkplain HttpCommand} associated with {@code invocation},
- * {@link #getTransformer(String, HttpCommand) parses its response}, and
- * applies a {@link #getFallback(String, Invocation, HttpCommand) fallback}
- * if a {@code Throwable} is encountered. Parsing and Fallback occur on the
- * {@code userExecutor} thread.
- */
- public ListenableFuture<?> submit(Invocation invocation) {
- String commandName = config.getCommandName(invocation);
- HttpCommand command = toCommand(commandName, invocation);
- Function<HttpResponse, ?> transformer = getTransformer(commandName, command);
- org.jclouds.Fallback<?> fallback = getFallback(commandName, invocation, command);
-
- logger.debug(">> submitting %s", commandName);
- return withFallback(transform(http.submit(command), transformer, userExecutor), fallback);
- }
-
- /**
- * invokes the {@linkplain HttpCommand} associated with {@code invocation},
- * {@link #getTransformer(String, HttpCommand) parses its response}, and
- * applies a {@link #getFallback(String, Invocation, HttpCommand) fallback}
- * if a {@code Throwable} is encountered.
- */
- public Object invoke(Invocation invocation) {
- String commandName = config.getCommandName(invocation);
- HttpCommand command = toCommand(commandName, invocation);
- Function<HttpResponse, ?> transformer = getTransformer(commandName, command);
- org.jclouds.Fallback<?> fallback = getFallback(commandName, invocation, command);
-
- logger.debug(">> invoking %s", commandName);
- try {
- return transformer.apply(http.invoke(command));
- } catch (Throwable t) {
- try {
- return fallback.createOrPropagate(t);
- } catch (Exception e) {
- throw propagate(e);
- }
- }
- }
-
- /**
- * calls {@link #invoke(Invocation)}, timing out after the specified time
- * limit. If the target method call finished before the limit is reached, the
- * return value or exception is propagated to the caller exactly as-is. If,
- * on the other hand, the time limit is reached, we attempt to abort the call
- * to the target, and throw an {@link UncheckedTimeoutException} to the
- * caller.
- *
- * @param invocation
- * the Invocation to invoke via {@link #invoke(Invocation)}
- * @param limitNanos
- * with timeoutUnit, the maximum length of time to wait in
- * nanoseconds
- * @throws InterruptedException
- * if our thread is interrupted during execution
- * @throws UncheckedTimeoutException
- * if the time limit is reached
- * @see TimeLimiter#callWithTimeout(Callable, long, TimeUnit, boolean)
- */
- public Object invokeWithTimeout(final Invocation invocation, final long limitNanos) {
- String commandName = config.getCommandName(invocation);
- HttpCommand command = toCommand(commandName, invocation);
- org.jclouds.Fallback<?> fallback = getFallback(commandName, invocation, command);
-
- logger.debug(">> blocking on %s for %s", invocation, limitNanos);
- try {
- return timeLimiter
- .callWithTimeout(new InvokeAndTransform(commandName, command), limitNanos, NANOSECONDS, true);
- } catch (Throwable t) {
- try {
- return fallback.createOrPropagate(t);
- } catch (Exception e) {
- throw propagate(e);
- }
- }
- }
-
- private org.jclouds.Fallback<?> getFallback(String commandName, Invocation invocation, HttpCommand command) {
- HttpRequest request = command.getCurrentRequest();
- org.jclouds.Fallback<?> fallback = config.getFallback(invocation);
- if (fallback instanceof InvocationContext)
- InvocationContext.class.cast(fallback).setContext(request);
- logger.trace("<< exceptions from %s are parsed by %s", commandName, fallback.getClass().getSimpleName());
- return fallback;
- }
-
- @VisibleForTesting
- final class InvokeAndTransform implements Callable<Object> {
- private final String commandName;
- private final HttpCommand command;
- private final Function<HttpResponse, ?> transformer;
-
- InvokeAndTransform(String commandName, HttpCommand command) {
- this.commandName = commandName;
- this.command = command;
- this.transformer = getTransformer(commandName, command);
- }
-
- @Override
- public Object call() throws Exception {
- return transformer.apply(http.invoke(command));
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(commandName, command, transformer);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- InvokeAndTransform that = InvokeAndTransform.class.cast(obj);
- return equal(this.commandName, that.commandName) && equal(this.command, that.command)
- && equal(this.transformer, that.transformer);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("commandName", commandName).add("command", command)
- .add("transformer", transformer).toString();
- }
- }
-
- /**
- * looks up the corresponding {@code Invocation} that returns a
- * {@code Future}. Only Invokables that return {@code Futures} are annotated
- * in a way that can be parsed into an {@linkplain HttpRequest}.
- */
- private Invocation toAsync(Invocation in) {
- Invocation async = sync2async.apply(in);
- checkState(isFuture(async.getInvokable()), "not a future: %s", async);
- return async;
- }
-
- private HttpCommand toCommand(String commandName, Invocation invocation) {
- logger.trace(">> converting %s", commandName);
- HttpRequest request = annotationProcessor.apply(invocation);
- logger.trace("<< converted %s to %s", commandName, request.getRequestLine());
- return new HttpCommand(request);
- }
-
- private Function<HttpResponse, ?> getTransformer(String commandName, HttpCommand command) {
- HttpRequest request = command.getCurrentRequest();
- Function<HttpResponse, ?> transformer = transformerForRequest.apply(request);
- logger.trace("<< response from %s is parsed by %s", commandName, transformer.getClass().getSimpleName());
- return transformer;
- }
-
- private boolean isFuture(Invokable<?, ?> in) {
- return in.getReturnType().getRawType().equals(ListenableFuture.class);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
- InvokeSyncToAsyncHttpMethod that = InvokeSyncToAsyncHttpMethod.class.cast(o);
- return equal(this.annotationProcessor, that.annotationProcessor);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(annotationProcessor);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper("").omitNullValues().add("annotationParser", annotationProcessor).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/test/java/org/jclouds/ContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/ContextBuilderTest.java b/core/src/test/java/org/jclouds/ContextBuilderTest.java
index 9faa6a1..ac59433 100644
--- a/core/src/test/java/org/jclouds/ContextBuilderTest.java
+++ b/core/src/test/java/org/jclouds/ContextBuilderTest.java
@@ -17,6 +17,7 @@
package org.jclouds;
import static com.google.common.base.Suppliers.ofInstance;
+import static org.jclouds.providers.AnonymousProviderMetadata.forApiOnEndpoint;
import static org.testng.Assert.assertEquals;
import java.net.URI;
@@ -28,7 +29,6 @@ import java.util.Set;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.domain.Credentials;
import org.jclouds.events.config.EventBusModule;
-import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@@ -36,9 +36,7 @@ import org.jclouds.location.Provider;
import org.jclouds.logging.config.LoggingModule;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
-import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.annotations.ApiVersion;
import org.jclouds.rest.config.CredentialStoreModule;
import org.testng.annotations.Test;
@@ -47,7 +45,6 @@ import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
@@ -65,8 +62,7 @@ public class ContextBuilderTest {
}
private ContextBuilder testContextBuilder() {
- return ContextBuilder.newBuilder(AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
- IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"));
+ return ContextBuilder.newBuilder(forApiOnEndpoint(IntegrationTestClient.class, "http://localhost"));
}
@Test
@@ -198,14 +194,6 @@ public class ContextBuilderTest {
assertEquals(modules.remove(0), httpModule);
}
- @ConfiguresRestClient
- static class ConfiguresClientModule implements Module {
-
- public void configure(Binder arg0) {
- }
-
- }
-
@Test
public void testAddBothWhenDefault() {
List<Module> modules = Lists.newArrayList();
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java
index 39e3a9d..6cb7127 100644
--- a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java
+++ b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java
@@ -18,14 +18,13 @@ package org.jclouds.apis;
import java.net.URI;
-import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
/**
* Implementation of @ link org.jclouds.types.ApiMetadata} for testing.
*/
-public class JcloudsTestBlobStoreApiMetadata extends BaseRestApiMetadata {
+public class JcloudsTestBlobStoreApiMetadata extends BaseHttpApiMetadata {
public static Builder builder() {
return new Builder();
@@ -44,10 +43,10 @@ public class JcloudsTestBlobStoreApiMetadata extends BaseRestApiMetadata {
super(builder);
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<IntegrationTestClient, Builder> {
protected Builder() {
- super(IntegrationTestClient.class, IntegrationTestAsyncClient.class);
+ super(IntegrationTestClient.class);
id("test-blobstore-api")
.view(Storage.class)
.name("Test Blobstore Api")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java
index 084f1a5..66f080c 100644
--- a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java
+++ b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java
@@ -18,14 +18,13 @@ package org.jclouds.apis;
import java.net.URI;
-import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
/**
* Implementation of @ link org.jclouds.types.ApiMetadata} for testing.
*/
-public class JcloudsTestComputeApiMetadata extends BaseRestApiMetadata {
+public class JcloudsTestComputeApiMetadata extends BaseHttpApiMetadata {
public static Builder builder() {
return new Builder();
@@ -44,10 +43,10 @@ public class JcloudsTestComputeApiMetadata extends BaseRestApiMetadata {
super(builder);
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<IntegrationTestClient, Builder> {
protected Builder() {
- super(IntegrationTestClient.class, IntegrationTestAsyncClient.class);
+ super(IntegrationTestClient.class);
id("test-compute-api")
.view(Compute.class)
.name("Test Compute Api")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java
index 60cc431..12988d2 100644
--- a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java
+++ b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java
@@ -18,14 +18,13 @@ package org.jclouds.apis;
import java.net.URI;
-import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
/**
* Implementation of @ link org.jclouds.types.ApiMetadata} for testing.
*/
-public class JcloudsTestYetAnotherComputeApiMetadata extends BaseRestApiMetadata {
+public class JcloudsTestYetAnotherComputeApiMetadata extends BaseHttpApiMetadata {
public static Builder builder() {
return new Builder();
@@ -44,10 +43,10 @@ public class JcloudsTestYetAnotherComputeApiMetadata extends BaseRestApiMetadata
super(builder);
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<IntegrationTestClient, Builder> {
protected Builder() {
- super(IntegrationTestClient.class, IntegrationTestAsyncClient.class);
+ super(IntegrationTestClient.class);
id("test-yet-another-compute-api")
.view(Compute.class)
.name("Test Yet Another Compute Api")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/c3497536/core/src/test/java/org/jclouds/config/BindApiContextWithWildcardExtendsExplicitAndRawTypeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/config/BindApiContextWithWildcardExtendsExplicitAndRawTypeTest.java b/core/src/test/java/org/jclouds/config/BindApiContextWithWildcardExtendsExplicitAndRawTypeTest.java
deleted file mode 100644
index 8997081..0000000
--- a/core/src/test/java/org/jclouds/config/BindApiContextWithWildcardExtendsExplicitAndRawTypeTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.config;
-
-import static com.google.common.base.Suppliers.ofInstance;
-import static org.easymock.EasyMock.createMock;
-import static org.testng.Assert.assertEquals;
-
-import javax.inject.Inject;
-
-import org.jclouds.Context;
-import org.jclouds.domain.Credentials;
-import org.jclouds.http.IntegrationTestAsyncClient;
-import org.jclouds.http.IntegrationTestClient;
-import org.jclouds.providers.AnonymousProviderMetadata;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.providers.config.BindProviderMetadataContextAndCredentials;
-import org.jclouds.rest.ApiContext;
-import org.jclouds.rest.HttpApiMetadata;
-import org.jclouds.rest.Utils;
-import org.jclouds.rest.internal.BaseRestApiTest.MockModule;
-import org.testng.annotations.Test;
-
-import com.google.common.reflect.TypeToken;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-@Test(groups = "unit", testName = "BindApiContextWithWildcardExtendsExplicitAndRawTypeTest")
-public class BindApiContextWithWildcardExtendsExplicitAndRawTypeTest {
-
- @SuppressWarnings("rawtypes")
- private static class ExpectedBindings {
-
- private final ApiContext raw;
- private final ApiContext<IntegrationTestClient> explicit;
-
- @Inject
- public ExpectedBindings(ApiContext raw, ApiContext<IntegrationTestClient> explicit) {
- this.raw = raw;
- this.explicit = explicit;
- }
-
- }
-
- @Test
- public void testRawAndExplicit() {
- ProviderMetadata md = AnonymousProviderMetadata.forApiOnEndpoint(IntegrationTestClient.class, "http://localhost");
-
- ExpectedBindings bindings = injectorFor(md).getInstance(ExpectedBindings.class);
- assertEquals(bindings.raw, bindings.explicit);
- }
-
- private Injector injectorFor(ProviderMetadata md) {
- return Guice.createInjector(new BindNameToContext("test"), new BindProviderMetadataContextAndCredentials(md,
- ofInstance(new Credentials("user", "pass"))), new BindApiContextWithWildcardExtendsExplicitAndRawType(
- HttpApiMetadata.class.cast(md.getApiMetadata())),
-
- // stuff needed for ApiContextImpl
- new MockModule(), new AbstractModule() {
-
- @Override
- protected void configure() {
- bind(Utils.class).toInstance(createMock(Utils.class));
- bind(IntegrationTestClient.class).toInstance(createMock(IntegrationTestClient.class));
- bind(IntegrationTestAsyncClient.class).toInstance(createMock(IntegrationTestAsyncClient.class));
- }
- });
- }
-
- @SuppressWarnings("rawtypes")
- private static class ExpectedBindingsWithWildCardExtends {
-
- private final ApiContext raw;
- private final ApiContext<IntegrationTestClient> explicit;
- private final ApiContext<? extends IntegrationTestClient> wildcardExtends;
-
- @Inject
- public ExpectedBindingsWithWildCardExtends(ApiContext raw, ApiContext<IntegrationTestClient> explicit,
- ApiContext<? extends IntegrationTestClient> wildcardExtends) {
- this.raw = raw;
- this.explicit = explicit;
- this.wildcardExtends = wildcardExtends;
- }
-
- }
-
- @Test
- public void testRawExplicitAndWildCardExtends() {
- ProviderMetadata md = AnonymousProviderMetadata.forApiOnEndpoint(IntegrationTestClient.class, "http://localhost");
-
- TypeToken<? extends Context> wildCardExtendsType = new TypeToken<ApiContext<? extends IntegrationTestClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
- md = md.toBuilder().apiMetadata(md.getApiMetadata().toBuilder().context(wildCardExtendsType).build()).build();
-
- ExpectedBindingsWithWildCardExtends bindings = injectorFor(md).getInstance(
- ExpectedBindingsWithWildCardExtends.class);
- assertEquals(bindings.raw, bindings.explicit);
- assertEquals(bindings.explicit, bindings.wildcardExtends);
- }
-}