removed ContextBuilder subclasses; added unwrap; undid generic params

This commit is contained in:
Adrian Cole 2012-04-16 00:44:20 -07:00
parent 874884c61b
commit 0b59dea073
659 changed files with 3814 additions and 8641 deletions

View File

@ -25,19 +25,31 @@ import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class AtmosApiMetadata public class AtmosApiMetadata extends BaseRestApiMetadata {
extends
BaseBlobStoreApiMetadata<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> { /** The serialVersionUID */
private static final long serialVersionUID = 8067252472547486854L;
public static final TypeToken<RestContext<AtmosClient, AtmosAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<AtmosClient, AtmosAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
private static Builder builder() { private static Builder builder() {
return new Builder(); return new Builder();
} }
@ -55,17 +67,16 @@ public class AtmosApiMetadata
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
return properties; return properties;
} }
public static class Builder public static class Builder extends BaseRestApiMetadata.Builder {
extends
BaseBlobStoreApiMetadata.Builder<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
protected Builder() { protected Builder() {
super(AtmosClient.class, AtmosAsyncClient.class);
id("atmos") id("atmos")
.name("EMC's Atmos API") .name("EMC's Atmos API")
.identityName("Subtenant ID (UID)") .identityName("Subtenant ID (UID)")
@ -73,9 +84,9 @@ public class AtmosApiMetadata
.documentation(URI.create("https://community.emc.com/docs/DOC-10508")) .documentation(URI.create("https://community.emc.com/docs/DOC-10508"))
.version("1.4.0") .version("1.4.0")
.defaultEndpoint("https://accesspoint.atmosonline.com") .defaultEndpoint("https://accesspoint.atmosonline.com")
.contextBuilder(TypeToken.of(AtmosContextBuilder.class))
.defaultProperties(AtmosApiMetadata.defaultProperties()) .defaultProperties(AtmosApiMetadata.defaultProperties())
.javaApi(AtmosClient.class, AtmosAsyncClient.class); .wrapper(TypeToken.of(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class));
} }
@Override @Override
@ -84,7 +95,7 @@ public class AtmosApiMetadata
} }
@Override @Override
public Builder fromApiMetadata(AtmosApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,72 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.atmos;
import java.util.List;
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Creates {@link AtmosStoreContext} or {@link Injector} instances based on
* the most commonly requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or
* Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default
* {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
* installed.
*
* @author Adrian Cole, Andrew Newdigate
* @see AtmosStoreContext
*/
public class AtmosContextBuilder
extends
BlobStoreContextBuilder<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
public AtmosContextBuilder(
ProviderMetadata<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> providerMetadata) {
super(providerMetadata);
}
public AtmosContextBuilder(AtmosApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new AtmosBlobStoreContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new AtmosRestClientModule());
}
}

View File

@ -33,8 +33,8 @@ import org.jclouds.rest.Binder;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
/** /**
* @author Adrian Cole * @author Adrian Cole

View File

@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
private final LoadingCache<String, Boolean> isPublic; private final LoadingCache<String, Boolean> isPublic;
@Inject @Inject
AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
@Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async, AtmosClient sync, @Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async, AtmosClient sync,
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,

View File

@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore {
private final LoadingCache<String, Boolean> isPublic; private final LoadingCache<String, Boolean> isPublic;
@Inject @Inject
AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
@Memoized Supplier<Set<? extends Location>> locations, AtmosClient sync, ObjectToBlob object2Blob, @Memoized Supplier<Set<? extends Location>> locations, AtmosClient sync, ObjectToBlob object2Blob,
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
BlobStoreListOptionsToListOptions container2ContainerListOptions, BlobStoreListOptionsToListOptions container2ContainerListOptions,

View File

@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.atmos.AtmosAsyncClient;
import org.jclouds.atmos.AtmosClient; import org.jclouds.atmos.AtmosClient;
import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore; import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore;
import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner; import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner;
@ -31,10 +30,8 @@ import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.AsyncBlobStore;
import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.attr.ConsistencyModel;
import org.jclouds.blobstore.config.BlobStoreMapModule; import org.jclouds.blobstore.config.BlobStoreMapModule;
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
@ -43,7 +40,6 @@ import com.google.common.cache.LoadingCache;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Scopes; import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/** /**
* Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound. * Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound.
@ -58,8 +54,6 @@ public class AtmosBlobStoreContextModule extends AbstractModule {
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON); bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON);
bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON);
bind(BlobStoreContext.class).to(new TypeLiteral<BlobStoreContextImpl<AtmosClient, AtmosAsyncClient>>() {
}).in(Scopes.SINGLETON);
bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class); bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class);
bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class); bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class);
} }

View File

@ -19,8 +19,8 @@
package org.jclouds.atmos.blobstore.functions; package org.jclouds.atmos.blobstore.functions;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;

View File

@ -32,7 +32,6 @@ import org.jclouds.date.DateService;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -50,7 +49,6 @@ import com.google.inject.Provides;
* @author Adrian Cole * @author Adrian Cole
*/ */
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> { public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> {
public AtmosRestClientModule() { public AtmosRestClientModule() {
super(AtmosClient.class, AtmosAsyncClient.class); super(AtmosClient.class, AtmosAsyncClient.class);

View File

@ -51,8 +51,8 @@ import org.jclouds.util.Strings2;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
/** /**
* Signs the EMC Atmos Online Storage request. * Signs the EMC Atmos Online Storage request.

View File

@ -33,9 +33,9 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap.Builder;
/** /**
* @author Adrian Cole * @author Adrian Cole

View File

@ -42,7 +42,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.options.GetOptions; import org.jclouds.http.options.GetOptions;
@ -320,8 +319,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
return new TestAtmosRestClientModule(); return new TestAtmosRestClientModule();
} }
@RequiresHttp @ConfiguresRestClient
@ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule { private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override @Override
protected void configure() { protected void configure() {
@ -337,7 +335,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
protected String provider = "atmos"; protected String provider = "atmos";
@Override @Override
public ApiMetadata<?, ?, ?, ?> createApiMetadata() { public ApiMetadata createApiMetadata() {
return new AtmosApiMetadata(); return new AtmosApiMetadata();
} }

View File

@ -57,7 +57,7 @@ import com.google.common.collect.Sets;
public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
public AtmosClient getApi() { public AtmosClient getApi() {
return (AtmosClient) context.getProviderSpecificContext().getApi(); return context.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi();
} }
private static final class HeadMatches implements Runnable { private static final class HeadMatches implements Runnable {

View File

@ -32,7 +32,6 @@ import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.blobstore.domain.Blob.Factory;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
@ -128,8 +127,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
return new TestAtmosRestClientModule(); return new TestAtmosRestClientModule();
} }
@RequiresHttp @ConfiguresRestClient
@ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule { private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override @Override
protected void configure() { protected void configure() {
@ -143,7 +141,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
} }
@Override @Override
public ApiMetadata<?, ?, ?, ?> createApiMetadata() { public ApiMetadata createApiMetadata() {
return new AtmosApiMetadata(); return new AtmosApiMetadata();
} }

View File

@ -20,10 +20,10 @@ package org.jclouds.atmos.blobstore.config;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.ContextBuilder;
import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.atmos.AtmosApiMetadata;
import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata; import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
@ -41,7 +41,7 @@ import com.google.inject.Module;
public class AtmosBlobStoreModuleTest { public class AtmosBlobStoreModuleTest {
Injector createInjector() { Injector createInjector() {
return BlobStoreContextBuilder return ContextBuilder
.newBuilder(new AtmosApiMetadata()) .newBuilder(new AtmosApiMetadata())
.credentials("uid", "key") .credentials("uid", "key")
.modules( .modules(
@ -53,7 +53,7 @@ public class AtmosBlobStoreModuleTest {
void testContextImpl() { void testContextImpl() {
Injector injector = createInjector(); Injector injector = createInjector();
BlobStoreContext<?, ?> handler = injector.getInstance(BlobStoreContext.class); BlobStoreContext handler = injector.getInstance(BlobStoreContext.class);
assertEquals(handler.getClass(), BlobStoreContextImpl.class); assertEquals(handler.getClass(), BlobStoreContextImpl.class);
ContainsValueInListStrategy valueList = injector ContainsValueInListStrategy valueList = injector
.getInstance(ContainsValueInListStrategy.class); .getInstance(ContainsValueInListStrategy.class);

View File

@ -28,12 +28,11 @@ import java.security.NoSuchAlgorithmException;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.ContextBuilder;
import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.atmos.reference.AtmosHeaders; import org.jclouds.atmos.reference.AtmosHeaders;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
@ -43,9 +42,9 @@ import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
@ -97,7 +96,7 @@ public class SignRequestTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
Injector injector = BlobStoreContextBuilder Injector injector = ContextBuilder
.newBuilder("atmos") .newBuilder("atmos")
.credentials(UID, KEY) .credentials(UID, KEY)
.modules( .modules(
@ -108,8 +107,7 @@ public class SignRequestTest {
} }
@RequiresHttp @ConfiguresRestClient
@ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule { private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override @Override

View File

@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals;
import java.io.File; import java.io.File;
import org.jclouds.atmos.domain.AtmosObject; import org.jclouds.atmos.domain.AtmosObject;
import org.jclouds.atmos.domain.AtmosObject.Factory;
import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.SystemMetadata;
import org.jclouds.atmos.domain.UserMetadata; import org.jclouds.atmos.domain.UserMetadata;
import org.jclouds.atmos.domain.AtmosObject.Factory;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.Guice; import com.google.inject.Guice;

View File

@ -19,15 +19,16 @@
package org.jclouds.byon; package org.jclouds.byon;
import java.net.URI; import java.net.URI;
import java.util.Properties;
import org.jclouds.JcloudsVersion; import org.jclouds.JcloudsVersion;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.internal.BaseApiMetadata;
import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.YamlNodeStoreModule;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for jclouds BYON API * Implementation of {@link ApiMetadata} for jclouds BYON API
@ -39,8 +40,10 @@ import com.google.common.reflect.TypeToken;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@SuppressWarnings("rawtypes") public class BYONApiMetadata extends BaseApiMetadata {
public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
/** The serialVersionUID */
private static final long serialVersionUID = -4059125995177393819L;
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
@ -55,11 +58,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Sup
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static class Builder extends BaseApiMetadata.Builder {
return BaseComputeServiceApiMetadata.Builder.defaultProperties();
}
public static class Builder extends BaseComputeServiceApiMetadata.Builder<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
protected Builder() { protected Builder() {
id("byon") id("byon")
@ -71,9 +70,8 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Sup
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")) .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
.version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion)) .version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion))
.buildVersion(JcloudsVersion.get().toString()) .buildVersion(JcloudsVersion.get().toString())
.defaultProperties(BYONApiMetadata.defaultProperties()) .wrapper(ComputeServiceContext.class)
.javaApi(Supplier.class, Supplier.class) .defaultModules(ImmutableSet.<Class<? extends Module>>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class));
.contextBuilder(TypeToken.of(BYONComputeServiceContextBuilder.class));
} }
@Override @Override
@ -82,7 +80,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Sup
} }
@Override @Override
public Builder fromApiMetadata(BYONApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,71 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.byon;
import java.util.List;
import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.ConfiguresNodeStore;
import org.jclouds.byon.config.YamlNodeStoreModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
import org.jclouds.providers.ProviderMetadata;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
@SuppressWarnings("rawtypes")
public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder<Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
public BYONComputeServiceContextBuilder(
ProviderMetadata<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> providerMetadata) {
super(providerMetadata);
}
public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new BYONComputeServiceContextModule());
addNodeStoreModuleIfNotPresent(modules);
}
protected void addNodeStoreModuleIfNotPresent(List<Module> modules) {
if (!Iterables.any(modules, new Predicate<Module>() {
public boolean apply(Module input) {
return input.getClass().isAnnotationPresent(ConfiguresNodeStore.class);
}
})) {
addNodeStoreModule(modules);
}
}
protected void addNodeStoreModule(List<Module> modules) {
modules.add(new YamlNodeStoreModule());
}
}

View File

@ -21,9 +21,6 @@ package org.jclouds.byon.config;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import javax.inject.Singleton;
import org.jclouds.byon.Node;
import org.jclouds.byon.internal.BYONComputeServiceAdapter; import org.jclouds.byon.internal.BYONComputeServiceAdapter;
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule; import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
@ -36,27 +33,17 @@ import org.jclouds.location.Provider;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@SuppressWarnings("unchecked")
@SingleThreaded @SingleThreaded
public class BYONComputeServiceContextModule extends public class BYONComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule {
JCloudsNativeComputeServiceAdapterContextModule<Supplier, Supplier> {
public BYONComputeServiceContextModule() { public BYONComputeServiceContextModule() {
super(Supplier.class, Supplier.class, BYONComputeServiceAdapter.class); super(BYONComputeServiceAdapter.class);
}
@Provides
@Singleton
Supplier provideApi(Supplier<LoadingCache<String, Node>> in) {
return in;
} }
@Override @Override
@ -68,6 +55,7 @@ public class BYONComputeServiceContextModule extends
}).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class); }).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class);
bind(new TypeLiteral<Function<URI, InputStream>>() { bind(new TypeLiteral<Function<URI, InputStream>>() {
}).to(SupplyFromProviderURIOrNodesProperty.class); }).to(SupplyFromProviderURIOrNodesProperty.class);
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>(){}); install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
});
} }
} }

View File

@ -33,9 +33,9 @@ import org.yaml.snakeyaml.constructor.Constructor;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
/** /**

View File

@ -42,8 +42,8 @@ import com.google.common.base.Predicates;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.common.util.concurrent.UncheckedExecutionException;
/** /**

View File

@ -24,14 +24,14 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Map.Entry;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.internal.ContextBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
@ -49,7 +49,7 @@ import com.google.inject.Module;
@Test(groups = "live") @Test(groups = "live")
public class BYONComputeServiceLiveTest { public class BYONComputeServiceLiveTest {
private ComputeServiceContext<?, ?> context; private ComputeServiceContext context;
@BeforeClass(groups = "live") @BeforeClass(groups = "live")
public void setup() throws FileNotFoundException, IOException { public void setup() throws FileNotFoundException, IOException {
@ -72,8 +72,9 @@ public class BYONComputeServiceLiveTest {
.append("\n"); .append("\n");
contextProperties.setProperty("byon.nodes", nodes.toString()); contextProperties.setProperty("byon.nodes", nodes.toString());
context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties) context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties).modules(
.modules(ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build(); ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build(
ComputeServiceContext.class);
} }
public void testCanRunCommandAsCurrentUser() throws Exception { public void testCanRunCommandAsCurrentUser() throws Exception {

View File

@ -23,16 +23,14 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.expectedProvider
import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled; import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.net.URI; import org.jclouds.ContextBuilder;
import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.CacheNodeStoreModule; import org.jclouds.byon.config.CacheNodeStoreModule;
import org.jclouds.byon.functions.NodesFromYamlTest; import org.jclouds.byon.functions.NodesFromYamlTest;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.rest.internal.ContextBuilder;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -40,7 +38,9 @@ import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/** /**
* *
@ -51,36 +51,31 @@ public class BYONComputeServiceTest {
@Test @Test
public void testNodesParseNodeMap() throws Exception { public void testNodesParseNodeMap() throws Exception {
assertNodesParse( assertNodesParse("foo", ContextBuilder.newBuilder(
"foo", new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build())
ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of( .endpoint("foo").modules(
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))); ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of(
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build(
ComputeServiceContext.class));
} }
@Test @Test
public void testNodesParseWithFileUrl() throws Exception { public void testNodesParseWithFileUrl() throws Exception {
assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ImmutableSet.<Module> of()); assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
"file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class));
} }
@Test @Test
public void testNodesParseWithClasspathUrl() throws Exception { public void testNodesParseWithClasspathUrl() throws Exception {
assertNodesParse("classpath:///test1.yaml", ImmutableSet.<Module> of()); assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
"classpath:///test1.yaml").build(ComputeServiceContext.class));
} }
private void assertNodesParse(String endpoint, Iterable<Module> modules) { private void assertNodesParse(String endpoint, ComputeServiceContext context) {
ComputeServiceContext<?, ?> context = null;
try { try {
Location providerLocation = expectedProviderLocationFromResource(endpoint); Location providerLocation = expectedProviderLocationFromResource(endpoint);
context = ContextBuilder.newBuilder( Supplier<LoadingCache<String, Node>> supplier = supplier(context);
AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint))
.modules(modules).build();
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
@SuppressWarnings("unchecked")
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
.getApi();
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
assertEquals(supplier.get().asMap(), assertEquals(supplier.get().asMap(),
@ -96,17 +91,12 @@ public class BYONComputeServiceTest {
} }
public void testNodesWithLocations() { public void testNodesWithLocations() {
ComputeServiceContext<?, ?> context = null; ComputeServiceContext context = null;
try { try {
String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath(); String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath();
context = ContextBuilder.newBuilder( context = ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(endpoint).build(ComputeServiceContext.class);
AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build();
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); Supplier<LoadingCache<String, Node>> supplier = supplier(context);
@SuppressWarnings("unchecked")
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
.getApi();
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
assertEquals(supplier.get().asMap(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST2.getId(), assertEquals(supplier.get().asMap(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST2.getId(),
@ -143,4 +133,11 @@ public class BYONComputeServiceTest {
context.close(); context.close();
} }
} }
private Supplier<LoadingCache<String, Node>> supplier(ComputeServiceContext context) {
Supplier<LoadingCache<String, Node>> supplier = context.utils().injector().getInstance(
Key.get(new TypeLiteral<Supplier<LoadingCache<String, Node>>>() {
}));
return supplier;
}
} }

View File

@ -26,19 +26,29 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudFilesApiMetadata public class CloudFilesApiMetadata extends BaseRestApiMetadata {
extends /** The serialVersionUID */
BaseBlobStoreApiMetadata<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> { private static final long serialVersionUID = 820062881469203616L;
public static final TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
private static Builder builder() { private static Builder builder() {
return new Builder(); return new Builder();
} }
@ -56,26 +66,25 @@ public class CloudFilesApiMetadata
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
return properties; return properties;
} }
public static class Builder public static class Builder extends BaseRestApiMetadata.Builder {
extends
BaseBlobStoreApiMetadata.Builder<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
protected Builder() { protected Builder() {
super(CloudFilesClient.class, CloudFilesAsyncClient.class);
id("cloudfiles") id("cloudfiles")
.name("Rackspace Cloud Files API") .name("Rackspace Cloud Files API")
.identityName("Username") .identityName("Username")
.credentialName("API Key") .credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION) .version(OpenStackAuthAsyncClient.VERSION)
.contextBuilder(TypeToken.of(CloudFilesContextBuilder.class))
.defaultProperties(CloudFilesApiMetadata.defaultProperties()) .defaultProperties(CloudFilesApiMetadata.defaultProperties())
.javaApi(CloudFilesClient.class, CloudFilesAsyncClient.class); .wrapper(TypeToken.of(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));
} }
@Override @Override
@ -84,7 +93,7 @@ public class CloudFilesApiMetadata
} }
@Override @Override
public Builder fromApiMetadata(CloudFilesApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,72 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudfiles;
import java.util.List;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on
* the most commonly requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or
* Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default
* {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
* installed.
*
* @author Adrian Cole, Andrew Newdigate
* @see CloudFilesStoreContext
*/
public class CloudFilesContextBuilder
extends
BlobStoreContextBuilder<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
public CloudFilesContextBuilder(
ProviderMetadata<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> providerMetadata) {
super(providerMetadata);
}
public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudFilesBlobStoreContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new CloudFilesRestClientModule());
}
}

View File

@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore {
private final EnableCDNAndCache enableCDNAndCache; private final EnableCDNAndCache enableCDNAndCache;
@Inject @Inject
protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
@Memoized Supplier<Set<? extends Location>> locations, CloudFilesClient sync, CloudFilesAsyncClient async, @Memoized Supplier<Set<? extends Location>> locations, CloudFilesClient sync, CloudFilesAsyncClient async,
ContainerToResourceMetadata container2ResourceMd, ContainerToResourceMetadata container2ResourceMd,

View File

@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore {
private EnableCDNAndCache enableCDNAndCache; private EnableCDNAndCache enableCDNAndCache;
@Inject @Inject
protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
@Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync, @Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
ContainerToResourceMetadata container2ResourceMd, ContainerToResourceMetadata container2ResourceMd,
BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,

View File

@ -28,7 +28,6 @@ import org.jclouds.cloudfiles.CDNManagement;
import org.jclouds.cloudfiles.CloudFilesAsyncClient; import org.jclouds.cloudfiles.CloudFilesAsyncClient;
import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.cloudfiles.CloudFilesClient;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -53,7 +52,6 @@ import com.google.inject.Provides;
* @author Adrian Cole * @author Adrian Cole
*/ */
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> { public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> {
public CloudFilesRestClientModule() { public CloudFilesRestClientModule() {

View File

@ -47,7 +47,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest<CloudFil
@Override @Override
public CloudFilesClient getApi() { public CloudFilesClient getApi() {
return (CloudFilesClient) context.getProviderSpecificContext().getApi(); return context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
} }
@Override @Override

View File

@ -22,21 +22,31 @@ import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType; import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.loadbalancer.LoadBalancerServiceContext;
import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata;
import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for CloudLoadBalancers 1.0 API * Implementation of {@link ApiMetadata} for CloudLoadBalancers 1.0 API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudLoadBalancersApiMetadata public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
extends
BaseLoadBalancerServiceApiMetadata<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> { /** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
@ -51,16 +61,15 @@ public class CloudLoadBalancersApiMetadata
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
return properties; return properties;
} }
public static class Builder public static class Builder extends BaseRestApiMetadata.Builder {
extends
BaseLoadBalancerServiceApiMetadata.Builder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
protected Builder() { protected Builder() {
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class);
id("cloudloadbalancers") id("cloudloadbalancers")
.name("Rackspace Cloud Load Balancers API") .name("Rackspace Cloud Load Balancers API")
.identityName("Username") .identityName("Username")
@ -68,9 +77,9 @@ public class CloudLoadBalancersApiMetadata
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")) .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION) .version(OpenStackAuthAsyncClient.VERSION)
.defaultEndpoint("https://auth.api.rackspacecloud.com") .defaultEndpoint("https://auth.api.rackspacecloud.com")
.javaApi(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class)
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties()) .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
.contextBuilder(TypeToken.of(CloudLoadBalancersContextBuilder.class)); .wrapper(TypeToken.of(LoadBalancerServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
} }
@Override @Override
@ -79,7 +88,7 @@ public class CloudLoadBalancersApiMetadata
} }
@Override @Override
public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,57 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudloadbalancers;
import java.util.List;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudLoadBalancersContextBuilder
extends
LoadBalancerServiceContextBuilder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
public CloudLoadBalancersContextBuilder(
ProviderMetadata<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> providerMetadata) {
super(providerMetadata);
}
public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudLoadBalancersLoadBalancerContextModule());
}
protected void addClientModule(List<Module> modules) {
modules.add(new CloudLoadBalancersRestClientModule());
}
}

View File

@ -37,7 +37,6 @@ import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromH
import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix; import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix;
import org.jclouds.cloudloadbalancers.reference.RackspaceConstants; import org.jclouds.cloudloadbalancers.reference.RackspaceConstants;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -64,7 +63,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudLoadBalancersRestClientModule extends public class CloudLoadBalancersRestClientModule extends
RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> { RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {

View File

@ -22,9 +22,9 @@ import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer; import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

View File

@ -22,8 +22,8 @@ import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes; import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;

View File

@ -53,12 +53,12 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
} }
@Override @Override
protected void tearDown() { protected void tearDownContext() {
for (LoadBalancer lb : lbs) { for (LoadBalancer lb : lbs) {
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId()); client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
assert loadBalancerDeleted.apply(lb) : lb; assert loadBalancerDeleted.apply(lb) : lb;
} }
super.tearDown(); super.tearDownContext();
} }
public void testCreateLoadBalancer() throws Exception { public void testCreateLoadBalancer() throws Exception {

View File

@ -24,8 +24,8 @@ import java.util.Collections;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.NodeRequest; import org.jclouds.cloudloadbalancers.domain.NodeRequest;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition; import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition;
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;

View File

@ -26,16 +26,16 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
import org.jclouds.cloudloadbalancers.domain.NodeRequest; import org.jclouds.cloudloadbalancers.domain.NodeRequest;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -137,7 +137,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
@Override @Override
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { protected void tearDownContext() {
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) { for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
LoadBalancer lb = entry.getKey(); LoadBalancer lb = entry.getKey();
LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion()); LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion());
@ -147,6 +147,6 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
} }
assert loadBalancerDeleted.apply(lb) : lb; assert loadBalancerDeleted.apply(lb) : lb;
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -19,9 +19,9 @@
package org.jclouds.cloudloadbalancers.functions; package org.jclouds.cloudloadbalancers.functions;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion; import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;

View File

@ -21,8 +21,8 @@ package org.jclouds.cloudloadbalancers.functions;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.BaseSetParserTest;

View File

@ -38,7 +38,6 @@ import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.reference.Region; import org.jclouds.cloudloadbalancers.reference.Region;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.internal.ClassMethodArgs; import org.jclouds.internal.ClassMethodArgs;
import org.jclouds.location.config.LocationModule; import org.jclouds.location.config.LocationModule;
import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.filters.AuthenticateRequest;
@ -71,7 +70,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsync
} }
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule { protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule {
@Override @Override
protected void installLocations() { protected void installLocations() {
@ -127,7 +125,7 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsync
} }
@Override @Override
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() { protected ApiMetadata createApiMetadata() {
return new CloudLoadBalancersApiMetadata(); return new CloudLoadBalancersApiMetadata();
} }

View File

@ -20,6 +20,7 @@ package org.jclouds.cloudloadbalancers.internal;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
@ -30,11 +31,10 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseContextLiveTest;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.reflect.TypeToken;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
@ -42,9 +42,7 @@ import com.google.inject.Injector;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class BaseCloudLoadBalancersClientLiveTest public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest<LoadBalancerServiceContext> {
extends
BaseContextLiveTest<LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> {
public BaseCloudLoadBalancersClientLiveTest() { public BaseCloudLoadBalancersClientLiveTest() {
provider = "cloudloadbalancers"; provider = "cloudloadbalancers";
@ -63,7 +61,7 @@ public class BaseCloudLoadBalancersClientLiveTest
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
lbContext = context.getProviderSpecificContext(); lbContext = context.unwrap();
client = lbContext.getApi(); client = lbContext.getApi();
@ -76,10 +74,9 @@ public class BaseCloudLoadBalancersClientLiveTest
injector.injectMembers(loadBalancerDeleted); injector.injectMembers(loadBalancerDeleted);
} }
@AfterGroups(groups = "live") @Override
protected void tearDown() { protected TypeToken<LoadBalancerServiceContext> contextType() {
if (lbContext != null) return TypeToken.of(LoadBalancerServiceContext.class);
lbContext.close();
} }
} }

View File

@ -22,20 +22,30 @@ import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for CloudServers 1.0 API * Implementation of {@link ApiMetadata} for CloudServers 1.0 API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudServersApiMetadata public class CloudServersApiMetadata extends BaseRestApiMetadata {
extends
BaseComputeServiceApiMetadata<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> { /** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
@ -50,16 +60,15 @@ public class CloudServersApiMetadata
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
return properties; return properties;
} }
public static class Builder public static class Builder extends BaseRestApiMetadata.Builder {
extends
BaseComputeServiceApiMetadata.Builder<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
protected Builder() { protected Builder() {
super(CloudServersClient.class, CloudServersAsyncClient.class);
id("cloudservers") id("cloudservers")
.name("Rackspace Cloud Servers API") .name("Rackspace Cloud Servers API")
.identityName("Username") .identityName("Username")
@ -67,9 +76,9 @@ public class CloudServersApiMetadata
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")) .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION) .version(OpenStackAuthAsyncClient.VERSION)
.defaultEndpoint("https://auth.api.rackspacecloud.com") .defaultEndpoint("https://auth.api.rackspacecloud.com")
.javaApi(CloudServersClient.class, CloudServersAsyncClient.class)
.defaultProperties(CloudServersApiMetadata.defaultProperties()) .defaultProperties(CloudServersApiMetadata.defaultProperties())
.contextBuilder(TypeToken.of(CloudServersContextBuilder.class)); .wrapper(TypeToken.of(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class));
} }
@Override @Override
@ -78,7 +87,7 @@ public class CloudServersApiMetadata
} }
@Override @Override
public Builder fromApiMetadata(CloudServersApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,57 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudservers;
import java.util.List;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudServersContextBuilder
extends
ComputeServiceContextBuilder<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
public CloudServersContextBuilder(
ProviderMetadata<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> providerMetadata) {
super(providerMetadata);
}
public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudServersComputeServiceContextModule());
}
protected void addClientModule(List<Module> modules) {
modules.add(new CloudServersRestClientModule());
}
}

View File

@ -22,8 +22,6 @@ import java.util.Map;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudservers.CloudServersAsyncClient;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage; import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage;
import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem; import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem;
import org.jclouds.cloudservers.compute.functions.FlavorToHardware; import org.jclouds.cloudservers.compute.functions.FlavorToHardware;
@ -55,12 +53,8 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudServersComputeServiceContextModule public class CloudServersComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
ComputeServiceAdapterContextModule<CloudServersClient, CloudServersAsyncClient, Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
public CloudServersComputeServiceContextModule() {
super(CloudServersClient.class, CloudServersAsyncClient.class);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override

View File

@ -32,7 +32,6 @@ import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -53,7 +52,6 @@ import com.google.inject.Provides;
* @author Adrian Cole * @author Adrian Cole
*/ */
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
public class CloudServersRestClientModule extends RestClientModule<CloudServersClient, CloudServersAsyncClient> { public class CloudServersRestClientModule extends RestClientModule<CloudServersClient, CloudServersAsyncClient> {
public CloudServersRestClientModule() { public CloudServersRestClientModule() {

View File

@ -50,7 +50,6 @@ import org.jclouds.cloudservers.options.ListOptions;
import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.cloudservers.options.RebuildServerOptions;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnFalseOn404;
import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.ReturnTrueIf2xx;
@ -890,8 +889,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
} }
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
@Provides @Provides
@Singleton @Singleton
@ -909,7 +907,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
protected String provider = "cloudservers"; protected String provider = "cloudservers";
@Override @Override
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() { protected ApiMetadata createApiMetadata() {
return new CloudServersApiMetadata(); return new CloudServersApiMetadata();
} }

View File

@ -44,7 +44,6 @@ import org.jclouds.cloudservers.domain.ServerStatus;
import org.jclouds.cloudservers.domain.SharedIpGroup; import org.jclouds.cloudservers.domain.SharedIpGroup;
import org.jclouds.cloudservers.domain.WeeklyBackup; import org.jclouds.cloudservers.domain.WeeklyBackup;
import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.cloudservers.options.RebuildServerOptions;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
@ -72,9 +71,7 @@ import com.google.inject.Injector;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest") @Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
public class CloudServersClientLiveTest public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest {
extends
BaseComputeServiceContextLiveTest<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>> {
public CloudServersClientLiveTest() { public CloudServersClientLiveTest() {
provider = "cloudservers"; provider = "cloudservers";

View File

@ -22,9 +22,6 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import org.jclouds.cloudservers.CloudServersAsyncClient;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.domain.LocationScope; import org.jclouds.domain.LocationScope;
@ -40,9 +37,7 @@ import com.google.inject.Module;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest") @Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
public class CloudServersComputeServiceLiveTest public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
extends
BaseComputeServiceLiveTest<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>> {
public CloudServersComputeServiceLiveTest() { public CloudServersComputeServiceLiveTest() {
provider = "cloudservers"; provider = "cloudservers";

View File

@ -28,7 +28,6 @@ import org.jclouds.cloudservers.CloudServersApiMetadata;
import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.RequiresHttp;
import org.jclouds.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule;
import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest; import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest;
@ -49,7 +48,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
} }
@Override @Override
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() { protected ApiMetadata createApiMetadata() {
return new CloudServersApiMetadata(); return new CloudServersApiMetadata();
} }
@ -81,8 +80,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
} }
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
@Override @Override
public Supplier<Date> provideCacheBusterDate() { public Supplier<Date> provideCacheBusterDate() {

View File

@ -24,20 +24,29 @@ import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for the Cloud Sigma API * Implementation of {@link ApiMetadata} for the Cloud Sigma API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudSigmaApiMetadata public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
extends /** The serialVersionUID */
BaseComputeServiceApiMetadata<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> { private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
return new Builder().fromApiMetadata(this); return new Builder().fromApiMetadata(this);
@ -51,8 +60,8 @@ public class CloudSigmaApiMetadata
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
// passwords are set post-boot, so auth failures are possible // passwords are set post-boot, so auth failures are possible
// from a race condition applying the password set script // from a race condition applying the password set script
@ -61,11 +70,10 @@ public class CloudSigmaApiMetadata
return properties; return properties;
} }
public static class Builder public static class Builder extends BaseRestApiMetadata.Builder {
extends
BaseComputeServiceApiMetadata.Builder<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
protected Builder() { protected Builder() {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
id("cloudsigma") id("cloudsigma")
.name("CloudSigma API") .name("CloudSigma API")
.identityName("Email") .identityName("Email")
@ -74,8 +82,8 @@ public class CloudSigmaApiMetadata
.version("1.0") .version("1.0")
.defaultEndpoint("https://api.cloudsigma.com") .defaultEndpoint("https://api.cloudsigma.com")
.defaultProperties(CloudSigmaApiMetadata.defaultProperties()) .defaultProperties(CloudSigmaApiMetadata.defaultProperties())
.javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class) .wrapper(TypeToken.of(ComputeServiceContext.class))
.contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class)); .defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class));
} }
@Override @Override
@ -84,7 +92,7 @@ public class CloudSigmaApiMetadata
} }
@Override @Override
public Builder fromApiMetadata(CloudSigmaApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,57 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudsigma;
import java.util.List;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudSigmaContextBuilder
extends
ComputeServiceContextBuilder<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
public CloudSigmaContextBuilder(
ProviderMetadata<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> providerMetadata) {
super(providerMetadata);
}
public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudSigmaComputeServiceContextModule());
}
protected void addClientModule(List<Module> modules) {
modules.add(new CloudSigmaRestClientModule());
}
}

View File

@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
import org.jclouds.cloudsigma.CloudSigmaClient; import org.jclouds.cloudsigma.CloudSigmaClient;
import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter; import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl; import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl;
@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudSigmaComputeServiceContextModule public class CloudSigmaComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<ServerInfo, Hardware, DriveInfo, Location> {
ComputeServiceAdapterContextModule<CloudSigmaClient, CloudSigmaAsyncClient, ServerInfo, Hardware, DriveInfo, Location> {
public CloudSigmaComputeServiceContextModule() {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
}
@Override @Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {

View File

@ -25,8 +25,8 @@ import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamilyVersion64Bit;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import com.google.common.base.Function; import com.google.common.base.Function;

View File

@ -33,14 +33,13 @@ import org.jclouds.cloudsigma.domain.ServerMetrics;
import org.jclouds.cloudsigma.functions.BaseDriveToMap; import org.jclouds.cloudsigma.functions.BaseDriveToMap;
import org.jclouds.cloudsigma.functions.DriveDataToMap; import org.jclouds.cloudsigma.functions.DriveDataToMap;
import org.jclouds.cloudsigma.functions.MapToDevices; import org.jclouds.cloudsigma.functions.MapToDevices;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.cloudsigma.functions.MapToDriveMetrics; import org.jclouds.cloudsigma.functions.MapToDriveMetrics;
import org.jclouds.cloudsigma.functions.MapToNICs; import org.jclouds.cloudsigma.functions.MapToNICs;
import org.jclouds.cloudsigma.functions.MapToServerMetrics; import org.jclouds.cloudsigma.functions.MapToServerMetrics;
import org.jclouds.cloudsigma.functions.ServerToMap; import org.jclouds.cloudsigma.functions.ServerToMap;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler; import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> { public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> {

View File

@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableSet.Builder;
/** /**
* *

View File

@ -648,7 +648,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
} }
@Override @Override
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() { protected ApiMetadata createApiMetadata() {
return new CloudSigmaApiMetadata(); return new CloudSigmaApiMetadata();
} }

View File

@ -43,7 +43,6 @@ import org.jclouds.cloudsigma.domain.VLANInfo;
import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.cloudsigma.options.CloneDriveOptions;
import org.jclouds.cloudsigma.predicates.DriveClaimed; import org.jclouds.cloudsigma.predicates.DriveClaimed;
import org.jclouds.cloudsigma.util.Servers; import org.jclouds.cloudsigma.util.Servers;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
@ -71,9 +70,7 @@ import com.google.inject.Guice;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest") @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest")
public class CloudSigmaClientLiveTest public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest {
extends
BaseComputeServiceContextLiveTest<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>> {
public CloudSigmaClientLiveTest() { public CloudSigmaClientLiveTest() {
provider = "cloudsigma"; provider = "cloudsigma";
@ -92,7 +89,7 @@ public class CloudSigmaClientLiveTest
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
cloudSigmaContext = context.getProviderSpecificContext(); cloudSigmaContext = context.unwrap();
client = cloudSigmaContext.getApi(); client = cloudSigmaContext.getApi();
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,

View File

@ -18,9 +18,6 @@
*/ */
package org.jclouds.cloudsigma.compute; package org.jclouds.cloudsigma.compute;
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
import org.jclouds.cloudsigma.CloudSigmaClient;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
@ -34,9 +31,7 @@ import com.google.inject.Module;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live") @Test(groups = "live")
public class CloudSigmaComputeServiceLiveTest public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
extends
BaseComputeServiceLiveTest<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>> {
public CloudSigmaComputeServiceLiveTest() { public CloudSigmaComputeServiceLiveTest() {
provider = "cloudsigma"; provider = "cloudsigma";

View File

@ -22,9 +22,14 @@ import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api. * Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api.
@ -43,9 +48,15 @@ import com.google.common.reflect.TypeToken;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> public class CloudStackApiMetadata extends BaseRestApiMetadata {
{
/** The serialVersionUID */
private static final long serialVersionUID = -3936131452958663245L;
public static final TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
return new Builder().fromApiMetadata(this); return new Builder().fromApiMetadata(this);
@ -59,17 +70,18 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudSt
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "7"); properties.setProperty("jclouds.ssh.max-retries", "7");
properties.setProperty("jclouds.ssh.retry-auth", "true"); properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties; return properties;
} }
public static class Builder public static class Builder
extends BaseComputeServiceApiMetadata.Builder<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> { extends BaseRestApiMetadata.Builder {
protected Builder() { protected Builder() {
super(CloudStackClient.class, CloudStackAsyncClient.class);
id("cloudstack") id("cloudstack")
.name("Citrix CloudStack API") .name("Citrix CloudStack API")
.identityName("API Key") .identityName("API Key")
@ -77,10 +89,9 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudSt
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")) .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))
.defaultEndpoint("http://localhost:8080/client/api") .defaultEndpoint("http://localhost:8080/client/api")
.version("2.2") .version("2.2")
.wrapper(TypeToken.of(CloudStackContext.class))
.defaultProperties(CloudStackApiMetadata.defaultProperties()) .defaultProperties(CloudStackApiMetadata.defaultProperties())
.javaApi(CloudStackClient.class, CloudStackAsyncClient.class) .defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class));
.context(TypeToken.of(CloudStackContext.class))
.contextBuilder(TypeToken.of(CloudStackContextBuilder.class));
} }
@Override @Override
@ -89,7 +100,7 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudSt
} }
@Override @Override
public Builder fromApiMetadata(CloudStackApiMetadata in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -31,8 +31,9 @@ import com.google.inject.ImplementedBy;
* *
*/ */
@ImplementedBy(CloudStackContextImpl.class) @ImplementedBy(CloudStackContextImpl.class)
public interface CloudStackContext extends ComputeServiceContext<CloudStackClient, CloudStackAsyncClient> { public interface CloudStackContext extends ComputeServiceContext {
@SuppressWarnings("unchecked")
@Override @Override
RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext(); RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext();

View File

@ -1,63 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudstack;
import java.util.List;
import java.util.Properties;
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.providers.ProviderMetadata;
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudStackContextBuilder extends
ComputeServiceContextBuilder<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> {
public CloudStackContextBuilder(
ProviderMetadata<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> providerMetadata) {
super(providerMetadata);
}
public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new CloudStackRestClientModule());
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudStackComputeServiceContextModule());
}
@VisibleForTesting
public Properties getOverrides() {
return overrides;
}
}

View File

@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder; import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
/** /**
* *

View File

@ -30,7 +30,6 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudstack.CloudStackAsyncClient;
import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware; import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware;
import org.jclouds.cloudstack.compute.functions.TemplateToImage; import org.jclouds.cloudstack.compute.functions.TemplateToImage;
@ -87,13 +86,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudStackComputeServiceContextModule public class CloudStackComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<VirtualMachine, ServiceOffering, Template, Zone> {
ComputeServiceAdapterContextModule<CloudStackClient, CloudStackAsyncClient, VirtualMachine, ServiceOffering, Template, Zone> {
public CloudStackComputeServiceContextModule() {
super(CloudStackClient.class, CloudStackAsyncClient.class);
}
@Override @Override
protected void configure() { protected void configure() {

View File

@ -33,8 +33,8 @@ import org.jclouds.cloudstack.domain.OSType;
import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.Template;
import org.jclouds.collect.Memoized; import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;

View File

@ -63,8 +63,8 @@ import com.google.common.base.Supplier;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
/** /**

View File

@ -27,11 +27,11 @@ import java.util.Set;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.Account.State;
import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.FirewallRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.PortForwardingRule; import org.jclouds.cloudstack.domain.PortForwardingRule;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.Account.State;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.cloudstack.config; package org.jclouds.cloudstack.config;
import org.jclouds.compute.ComputeServiceContextBuilder;
/** /**
* Configuration properties and constants used in CloudStack connections. * Configuration properties and constants used in CloudStack connections.

View File

@ -123,7 +123,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -155,7 +154,6 @@ import com.google.inject.name.Named;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> { public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {

View File

@ -21,13 +21,13 @@ package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.Map.Entry;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**

View File

@ -26,8 +26,8 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.filters.AuthenticationFilter;
import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions;
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;

View File

@ -22,8 +22,8 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions;
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions;

View File

@ -38,8 +38,8 @@ import org.jclouds.logging.Logger;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.ImmutableSet.Builder;
/** /**
* *

View File

@ -30,8 +30,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.json.internal.GsonWrapper; import org.jclouds.json.internal.GsonWrapper;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;

View File

@ -29,9 +29,7 @@ import javax.inject.Singleton;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.AsyncJob;
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJobError;
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.FirewallRule;
import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.IPForwardingRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
@ -45,6 +43,8 @@ import org.jclouds.cloudstack.domain.TemplateExtraction;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.Volume; import org.jclouds.cloudstack.domain.Volume;
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
import org.jclouds.domain.JsonBall; import org.jclouds.domain.JsonBall;
import org.jclouds.json.Json; import org.jclouds.json.Json;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.cloudstack.internal; package org.jclouds.cloudstack.internal;
import java.io.Closeable;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -34,34 +35,34 @@ import org.jclouds.compute.ComputeService;
import org.jclouds.compute.Utils; import org.jclouds.compute.Utils;
import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.location.Provider;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import com.google.common.reflect.TypeToken;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class CloudStackContextImpl extends ComputeServiceContextImpl<CloudStackClient, CloudStackAsyncClient> implements public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext {
CloudStackContext {
private final RestContext<CloudStackClient,CloudStackAsyncClient> providerSpecificContext;
private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext; private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext; private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
@Inject @Inject
public CloudStackContextImpl(ComputeService computeService, Map<String, Credentials> credentialStore, Utils utils, public CloudStackContextImpl(@Provider Closeable wrapped, @Provider TypeToken<? extends Closeable> wrappedType,
RestContext<CloudStackClient,CloudStackAsyncClient> providerSpecificContext, ComputeService computeService, Map<String, Credentials> credentialStore, Utils utils,
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext, RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) { RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
super(computeService, credentialStore, utils, providerSpecificContext); super(wrapped, wrappedType, computeService, credentialStore, utils);
this.providerSpecificContext=providerSpecificContext;
this.domainContext = domainContext; this.domainContext = domainContext;
this.globalContext = globalContext; this.globalContext = globalContext;
} }
@Override @Override
public RestContext<CloudStackClient,CloudStackAsyncClient> getProviderSpecificContext() { public RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext() {
return providerSpecificContext; return unwrap();
} }
@Override @Override
public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() { public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
return domainContext; return domainContext;

View File

@ -21,8 +21,8 @@ package org.jclouds.cloudstack.predicates;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.Account.Type;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.Account.Type;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;

View File

@ -26,13 +26,13 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.ContextBuilder;
import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackApiMetadata;
import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.ApiKeyPair; import org.jclouds.cloudstack.domain.ApiKeyPair;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
import org.jclouds.compute.ComputeServiceContextBuilder;
/** /**
* @author Andrei Savu * @author Andrei Savu
@ -62,12 +62,12 @@ public class ApiKeyPairs {
overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials"); overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials");
context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata()) context = ContextBuilder.newBuilder(new CloudStackApiMetadata())
.endpoint(checkNotNull(endpoint, "endpoint").toASCIIString()) .endpoint(checkNotNull(endpoint, "endpoint").toASCIIString())
.credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password) .credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password)
.overrides(overrides).build(); .overrides(overrides).build(CloudStackContext.class);
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); CloudStackClient client = context.getProviderSpecificContext().getApi();
Set<Account> listOfAccounts = client.getAccountClient().listAccounts(); Set<Account> listOfAccounts = client.getAccountClient().listAccounts();
domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain; domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain;

View File

@ -53,8 +53,8 @@ import org.jclouds.cloudstack.suppliers.GetCurrentUser;
import org.jclouds.cloudstack.suppliers.NetworksForCurrentUser; import org.jclouds.cloudstack.suppliers.NetworksForCurrentUser;
import org.jclouds.cloudstack.suppliers.ZoneIdToZoneSupplier; import org.jclouds.cloudstack.suppliers.ZoneIdToZoneSupplier;
import org.jclouds.collect.Memoized; import org.jclouds.collect.Memoized;
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
import org.jclouds.compute.ComputeTestUtils; import org.jclouds.compute.ComputeTestUtils;
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
@ -102,7 +102,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
@Override @Override
protected void configure() { protected void configure() {
bindProperties(binder(), setupProperties()); bindProperties(binder(), setupProperties());
bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity()); bind(String.class).annotatedWith(Identity.class).toInstance(identity);
bind(new TypeLiteral<Supplier<User>>() { bind(new TypeLiteral<Supplier<User>>() {
}).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON); }).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON);
bind(new TypeLiteral<Supplier<Map<Long, Network>>>() { bind(new TypeLiteral<Supplier<Map<Long, Network>>>() {

View File

@ -18,12 +18,8 @@
*/ */
package org.jclouds.cloudstack.compute; package org.jclouds.cloudstack.compute;
import org.jclouds.cloudstack.CloudStackAsyncClient;
import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.rest.RestContext;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -37,8 +33,7 @@ import com.google.inject.Module;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", enabled = true, singleThreaded = true) @Test(groups = "live", enabled = true, singleThreaded = true)
public class CloudStackComputeServiceLiveTest extends public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest {
BaseComputeServiceLiveTest<CloudStackClient, CloudStackAsyncClient, CloudStackContext> {
public CloudStackComputeServiceLiveTest() { public CloudStackComputeServiceLiveTest() {
provider = "cloudstack"; provider = "cloudstack";
} }
@ -48,11 +43,6 @@ public class CloudStackComputeServiceLiveTest extends
return new SshjSshClientModule(); return new SshjSshClientModule();
} }
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<CloudStackClient, CloudStackAsyncClient> tmContext = context.getProviderSpecificContext();
}
// cloudstack does not support metadata // cloudstack does not support metadata
@Override @Override
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) { protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {

View File

@ -24,7 +24,6 @@ import org.jclouds.cloudstack.CloudStackApiMetadata;
import org.jclouds.cloudstack.config.CloudStackRestClientModule; import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.ProviderMetadata;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
@ -37,8 +36,7 @@ import com.google.inject.Module;
*/ */
public abstract class BaseCloudStackAsyncClientTest<T> extends BaseAsyncClientTest<T> { public abstract class BaseCloudStackAsyncClientTest<T> extends BaseAsyncClientTest<T> {
@RequiresHttp @ConfiguresRestClient
@ConfiguresRestClient
public static class CloudStackRestClientModuleExtension extends CloudStackRestClientModule { public static class CloudStackRestClientModuleExtension extends CloudStackRestClientModule {
} }
@ -55,7 +53,7 @@ public abstract class BaseCloudStackAsyncClientTest<T> extends BaseAsyncClientTe
} }
@Override @Override
protected ProviderMetadata<?, ?, ?, ?> createProviderMetadata() { protected ProviderMetadata createProviderMetadata() {
return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(), return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(),
"http://localhost:8080/client/api"); "http://localhost:8080/client/api");
} }

View File

@ -73,8 +73,7 @@ import com.google.inject.Module;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class BaseCloudStackClientLiveTest extends public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveTest {
BaseComputeServiceContextLiveTest<CloudStackClient, CloudStackAsyncClient, CloudStackContext> {
protected String domainAdminIdentity; protected String domainAdminIdentity;
protected String domainAdminCredential; protected String domainAdminCredential;
protected String globalAdminIdentity; protected String globalAdminIdentity;
@ -195,13 +194,13 @@ public class BaseCloudStackClientLiveTest extends
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
computeClient = context.getComputeService(); computeClient = context.getComputeService();
cloudStackContext = context.getProviderSpecificContext(); cloudStackContext = context.unwrap();
client = cloudStackContext.getApi(); client = cloudStackContext.getApi();
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER); user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
domainAdminEnabled = setupDomainAdminProperties() != null; domainAdminEnabled = setupDomainAdminProperties() != null;
if (domainAdminEnabled) { if (domainAdminEnabled) {
domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()); domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()).unwrap();
domainAdminContext = domainAdminComputeContext.getDomainContext(); domainAdminContext = domainAdminComputeContext.getDomainContext();
domainAdminClient = domainAdminContext.getApi(); domainAdminClient = domainAdminContext.getApi();
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN); domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
@ -210,7 +209,7 @@ public class BaseCloudStackClientLiveTest extends
globalAdminEnabled = setupGlobalAdminProperties() != null; globalAdminEnabled = setupGlobalAdminProperties() != null;
if (globalAdminEnabled) { if (globalAdminEnabled) {
globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()); globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()).unwrap();
globalAdminContext = globalAdminComputeContext.getGlobalContext(); globalAdminContext = globalAdminComputeContext.getGlobalContext();
globalAdminClient = globalAdminContext.getApi(); globalAdminClient = globalAdminContext.getApi();
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN); globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);

View File

@ -47,7 +47,7 @@ public abstract class BaseCloudStackRestClientExpectTest<S> extends BaseRestClie
} }
@Override @Override
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() { protected ApiMetadata createApiMetadata() {
return new CloudStackApiMetadata(); return new CloudStackApiMetadata();
} }

View File

@ -83,7 +83,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
} }
private void checkAuthAsUser(ApiKeyPair keyPair) { private void checkAuthAsUser(ApiKeyPair keyPair) {
ComputeServiceContext<?, ?> context = createContext(credentialsAsProperties(keyPair), setupModules()); ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules());
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
Set<Account> accounts = client.getAccountClient().listAccounts(); Set<Account> accounts = client.getAccountClient().listAccounts();

View File

@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import org.jclouds.cloudstack.domain.OSType; import org.jclouds.cloudstack.domain.OSType;
import org.jclouds.cloudstack.options.ListOSTypesOptions; import org.jclouds.cloudstack.options.ListOSTypesOptions;

View File

@ -35,11 +35,11 @@ import javax.annotation.Nullable;
import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.AsyncJob;
import org.jclouds.cloudstack.domain.JobResult; import org.jclouds.cloudstack.domain.JobResult;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
import org.jclouds.cloudstack.domain.Network; import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.domain.PublicIPAddress;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
import org.jclouds.cloudstack.predicates.LoadBalancerRuleActive; import org.jclouds.cloudstack.predicates.LoadBalancerRuleActive;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;

View File

@ -22,13 +22,13 @@ import static org.testng.Assert.assertEquals;
import java.net.URI; import java.net.URI;
import org.jclouds.ContextBuilder;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient; import org.jclouds.http.IntegrationTestClient;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.jclouds.rest.internal.ContextBuilder;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;

View File

@ -24,14 +24,14 @@ import static org.testng.Assert.assertTrue;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.AsyncJob;
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
import org.jclouds.cloudstack.domain.AsyncJob.Status;
import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJobError;
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.IPForwardingRule;
import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.domain.PublicIPAddress;
import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.Template;
import org.jclouds.cloudstack.domain.TemplateExtraction; import org.jclouds.cloudstack.domain.TemplateExtraction;
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
import org.jclouds.cloudstack.domain.AsyncJob.Status;
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.domain.JsonBall; import org.jclouds.domain.JsonBall;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;

View File

@ -22,9 +22,9 @@ import java.util.Set;
import org.jclouds.cloudstack.config.CloudStackParserModule; import org.jclouds.cloudstack.config.CloudStackParserModule;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.Account.State; import org.jclouds.cloudstack.domain.Account.State;
import org.jclouds.cloudstack.domain.Account.Type; import org.jclouds.cloudstack.domain.Account.Type;
import org.jclouds.cloudstack.domain.User;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.BaseSetParserTest;
import org.jclouds.json.config.GsonModule; import org.jclouds.json.config.GsonModule;

View File

@ -28,9 +28,9 @@ import static org.testng.Assert.fail;
import org.jclouds.cloudstack.AsyncJobException; import org.jclouds.cloudstack.AsyncJobException;
import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.AsyncJob;
import org.jclouds.cloudstack.domain.AsyncJobError;
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
import org.jclouds.cloudstack.domain.AsyncJob.Status; import org.jclouds.cloudstack.domain.AsyncJob.Status;
import org.jclouds.cloudstack.domain.AsyncJobError;
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
import org.jclouds.cloudstack.features.AsyncJobClient; import org.jclouds.cloudstack.features.AsyncJobClient;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;

View File

@ -25,73 +25,68 @@ import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType; import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
import org.jclouds.apis.internal.BaseApiMetadata;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata; import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.reflect.TypeToken;
/** /**
* Implementation of {@link ApiMetadata} for Amazon's CloudWatch api. * Implementation of {@link ApiMetadata} for Amazon's CloudWatch api.
* *
* <h3>note</h3>
* <p/>
* This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that
* children can add additional methods not declared here, such as new features
* from AWS.
* <p/>
*
* This class is not setup to allow a different context than {@link RestContext}
* . By doing so, it reduces the type complexity.
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudWatchApiMetadata<S extends CloudWatchClient, A extends CloudWatchAsyncClient> extends public class CloudWatchApiMetadata extends BaseRestApiMetadata {
BaseRestApiMetadata<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
/** The serialVersionUID */
private static final long serialVersionUID = 3450830053589179249L;
public static final TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override @Override
public Builder<S, A> toBuilder() { public Builder toBuilder() {
return new Builder<S, A>(getApi(), getAsyncApi()).fromApiMetadata(this); return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
} }
public CloudWatchApiMetadata() { public CloudWatchApiMetadata() {
this(new Builder<CloudWatchClient, CloudWatchAsyncClient>(CloudWatchClient.class, CloudWatchAsyncClient.class)); this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class));
} }
@SuppressWarnings("unchecked") protected CloudWatchApiMetadata(Builder builder) {
protected CloudWatchApiMetadata(Builder<?, ?> builder) {
super(Builder.class.cast(builder)); super(Builder.class.cast(builder));
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseApiMetadata.Builder.defaultProperties(); Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_HEADER_TAG, "amz");
return properties; return properties;
} }
public static class Builder<S extends CloudWatchClient, A extends CloudWatchAsyncClient> extends public static class Builder extends BaseRestApiMetadata.Builder {
BaseRestApiMetadata.Builder<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
protected Builder(Class<S> client, Class<A> asyncClient) { protected Builder(Class<?> client, Class<?> asyncClient) {
super(client, asyncClient); super(client, asyncClient);
id("cloudwatch") id("cloudwatch")
.type(ApiType.MONITOR)
.name("Amazon CloudWatch Api") .name("Amazon CloudWatch Api")
.identityName("Access Key ID") .identityName("Access Key ID")
.credentialName("Secret Access Key") .credentialName("Secret Access Key")
.version(CloudWatchAsyncClient.VERSION) .version(CloudWatchAsyncClient.VERSION)
.defaultProperties(CloudWatchApiMetadata.defaultProperties()) .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"))
.defaultEndpoint("https://monitoring.us-east-1.amazonaws.com") .defaultEndpoint("https://monitoring.us-east-1.amazonaws.com")
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")); .defaultProperties(CloudWatchApiMetadata.defaultProperties())
.defaultModule(CloudWatchRestClientModule.class);
} }
@Override @Override
public CloudWatchApiMetadata<S, A> build() { public CloudWatchApiMetadata build() {
return new CloudWatchApiMetadata<S, A>(this); return new CloudWatchApiMetadata(this);
} }
@Override @Override
public Builder<S, A> fromApiMetadata(CloudWatchApiMetadata<S, A> in) { public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in); super.fromApiMetadata(in);
return this; return this;
} }

View File

@ -1,64 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudwatch;
import java.util.List;
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextBuilder;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Creates {@link MonitoringContext} or {@link Injector} instances based on the
* most commonly requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or
* Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default
* {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
* installed.
*
* @author Adrian Cole
* @see MonitoringContext
*/
public class CloudWatchContextBuilder<S extends CloudWatchClient, A extends CloudWatchAsyncClient>
extends RestContextBuilder<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
public CloudWatchContextBuilder(ProviderMetadata<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> providerMetadata) {
super(providerMetadata);
}
public CloudWatchContextBuilder(CloudWatchApiMetadata<S, A> apiMetadata) {
super(apiMetadata);
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new CloudWatchRestClientModule());
}
}

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudwatch.config;
import org.jclouds.aws.config.FormSigningRestClientModule; import org.jclouds.aws.config.FormSigningRestClientModule;
import org.jclouds.cloudwatch.CloudWatchAsyncClient; import org.jclouds.cloudwatch.CloudWatchAsyncClient;
import org.jclouds.cloudwatch.CloudWatchClient; import org.jclouds.cloudwatch.CloudWatchClient;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
/** /**
@ -29,7 +28,6 @@ import org.jclouds.rest.ConfiguresRestClient;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchClient, CloudWatchAsyncClient> { public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchClient, CloudWatchAsyncClient> {
public CloudWatchRestClientModule() { public CloudWatchRestClientModule() {

View File

@ -18,19 +18,22 @@
*/ */
package org.jclouds.cloudwatch; package org.jclouds.cloudwatch;
import org.jclouds.apis.ApiType; import org.jclouds.Wrapper;
import org.jclouds.apis.internal.BaseRestApiMetadataTest; import org.jclouds.rest.internal.BaseRestApiMetadataTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@SuppressWarnings("rawtypes")
@Test(groups = "unit", testName = "CloudWatchApiMetadataTest") @Test(groups = "unit", testName = "CloudWatchApiMetadataTest")
public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest { public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest {
// no monitoring abstraction, yet
public CloudWatchApiMetadataTest() { public CloudWatchApiMetadataTest() {
super(new CloudWatchApiMetadata(), ApiType.MONITOR); super(new CloudWatchApiMetadata(), ImmutableSet.<TypeToken<? extends Wrapper>> of());
} }
} }

View File

@ -39,7 +39,6 @@ import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler; import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.location.config.LocationModule; import org.jclouds.location.config.LocationModule;
import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToURISupplier;
@ -91,8 +90,7 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy
}; };
} }
@RequiresHttp @ConfiguresRestClient
@ConfiguresRestClient
private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule { private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule {
@Override @Override
@ -123,9 +121,8 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy
return new TestMonitoringRestClientModule(); return new TestMonitoringRestClientModule();
} }
@SuppressWarnings("rawtypes")
@Override @Override
public ApiMetadata<?, ?, ?, ?> createApiMetadata() { public ApiMetadata createApiMetadata() {
return new CloudWatchApiMetadata(); return new CloudWatchApiMetadata();
} }

View File

@ -24,15 +24,17 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.cloudwatch.domain.Datapoint; import org.jclouds.cloudwatch.domain.Datapoint;
import org.jclouds.cloudwatch.domain.Statistics; import org.jclouds.cloudwatch.domain.Statistics;
import org.jclouds.cloudwatch.domain.Unit; import org.jclouds.cloudwatch.domain.Unit;
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseContextLiveTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/** /**
* Tests behavior of {@code CloudWatchClient} * Tests behavior of {@code CloudWatchClient}
* *
@ -67,4 +69,9 @@ public class CloudWatchClientLiveTest extends BaseContextLiveTest<RestContext<Cl
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region "); return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
} }
@Override
protected TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> contextType() {
return CloudWatchApiMetadata.CONTEXT_TOKEN;
}
} }

View File

@ -23,16 +23,28 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule;
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Apache Deltacloud API * Implementation of {@link ApiMetadata} for Apache Deltacloud API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> { public class DeltacloudApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<DeltacloudClient, DeltacloudAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<DeltacloudClient, DeltacloudAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
@ -47,13 +59,14 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<Deltacl
super(builder); super(builder);
} }
protected static Properties defaultProperties() { public static Properties defaultProperties() {
return BaseComputeServiceApiMetadata.Builder.defaultProperties(); return BaseRestApiMetadata.defaultProperties();
} }
public static class Builder extends BaseComputeServiceApiMetadata.Builder<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> { public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() { protected Builder() {
super(DeltacloudClient.class, DeltacloudAsyncClient.class);
id("deltacloud") id("deltacloud")
.name("Apache Deltacloud API") .name("Apache Deltacloud API")
.identityName("Username") .identityName("Username")
@ -61,21 +74,22 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<Deltacl
.documentation(URI.create("http://deltacloud.apache.org/api.html")) .documentation(URI.create("http://deltacloud.apache.org/api.html"))
.version("0.3.0") .version("0.3.0")
.defaultEndpoint("http://localhost:3001/api") .defaultEndpoint("http://localhost:3001/api")
.javaApi(DeltacloudClient.class, DeltacloudAsyncClient.class) .defaultProperties(DeltacloudApiMetadata.defaultProperties())
.contextBuilder(TypeToken.of(DeltacloudContextBuilder.class)); .wrapper(TypeToken.of(ComputeServiceContext.class))
} .defaultModules(ImmutableSet.<Class<? extends Module>>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class));
@Override
public DeltacloudApiMetadata build() {
return new DeltacloudApiMetadata(this);
}
@Override
public Builder fromApiMetadata(DeltacloudApiMetadata in) {
super.fromApiMetadata(in);
return this;
}
} }
} @Override
public DeltacloudApiMetadata build() {
return new DeltacloudApiMetadata(this);
}
@Override
public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in);
return this;
}
}
}

View File

@ -36,9 +36,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection;
import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.HardwareProfile;
import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Image;
import org.jclouds.deltacloud.domain.Instance; import org.jclouds.deltacloud.domain.Instance;
import org.jclouds.deltacloud.domain.Instance.State;
import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Realm;
import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.Transition;
import org.jclouds.deltacloud.domain.Instance.State;
import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete; import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete;
import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.options.CreateInstanceOptions;
import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler; import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler;

View File

@ -27,9 +27,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection;
import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.HardwareProfile;
import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Image;
import org.jclouds.deltacloud.domain.Instance; import org.jclouds.deltacloud.domain.Instance;
import org.jclouds.deltacloud.domain.Instance.State;
import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Realm;
import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.Transition;
import org.jclouds.deltacloud.domain.Instance.State;
import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.options.CreateInstanceOptions;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;

View File

@ -1,57 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.deltacloud;
import java.util.List;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule;
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class DeltacloudContextBuilder
extends
ComputeServiceContextBuilder<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
public DeltacloudContextBuilder(
ProviderMetadata<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> providerMetadata) {
super(providerMetadata);
}
public DeltacloudContextBuilder(DeltacloudApiMetadata apiMetadata) {
super(apiMetadata);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new DeltacloudComputeServiceContextModule());
}
protected void addClientModule(List<Module> modules) {
modules.add(new DeltacloudRestClientModule());
}
}

View File

@ -21,8 +21,6 @@ package org.jclouds.deltacloud.compute.config;
import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.deltacloud.DeltacloudAsyncClient;
import org.jclouds.deltacloud.DeltacloudClient;
import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage; import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage;
import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware; import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware;
import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata; import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata;
@ -40,13 +38,8 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class DeltacloudComputeServiceContextModule public class DeltacloudComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<Instance, HardwareProfile, org.jclouds.deltacloud.domain.Image, Realm> {
ComputeServiceAdapterContextModule<DeltacloudClient, DeltacloudAsyncClient, Instance, HardwareProfile, org.jclouds.deltacloud.domain.Image, Realm> {
public DeltacloudComputeServiceContextModule() {
super(DeltacloudClient.class, DeltacloudAsyncClient.class);
}
@Override @Override
protected void configure() { protected void configure() {

Some files were not shown because too many files have changed in this diff Show More