mirror of https://github.com/apache/jclouds.git
Issue 826: removed eager supplier of @Provider endpoint
This commit is contained in:
parent
fbb48454fb
commit
c388fc41b4
|
@ -39,6 +39,7 @@ import org.jclouds.location.Provider;
|
|||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* Signs the EMC Atmos Online Storage request.
|
||||
|
@ -52,7 +53,7 @@ public class ShareUrl implements Function<String, URI> {
|
|||
|
||||
private final String uid;
|
||||
private final byte[] key;
|
||||
private final URI provider;
|
||||
private final Supplier<URI> provider;
|
||||
private final javax.inject.Provider<Long> timeStampProvider;
|
||||
private final javax.inject.Provider<UriBuilder> uriBuilders;
|
||||
private final Crypto crypto;
|
||||
|
@ -66,7 +67,7 @@ public class ShareUrl implements Function<String, URI> {
|
|||
|
||||
@Inject
|
||||
public ShareUrl(@Named(PROPERTY_IDENTITY) String uid, @Named(PROPERTY_CREDENTIAL) String encodedKey,
|
||||
@Provider URI provider, @TimeStamp javax.inject.Provider<Long> timeStampProvider,
|
||||
@Provider Supplier<URI> provider, @TimeStamp javax.inject.Provider<Long> timeStampProvider,
|
||||
javax.inject.Provider<UriBuilder> uriBuilders, Crypto crypto) {
|
||||
this.uid = uid;
|
||||
this.key = CryptoStreams.base64(encodedKey);
|
||||
|
@ -81,7 +82,7 @@ public class ShareUrl implements Function<String, URI> {
|
|||
String requestedResource = new StringBuilder().append("/rest/namespace/").append(path).toString();
|
||||
long expires = timeStampProvider.get();
|
||||
String signature = signString(createStringToSign(requestedResource, expires));
|
||||
return uriBuilders.get().uri(provider).path(requestedResource).queryParam("uid", uid).queryParam("expires",
|
||||
return uriBuilders.get().uri(provider.get()).path(requestedResource).queryParam("uid", uid).queryParam("expires",
|
||||
expires).queryParam("signature", signature).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.util.Strings2;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
|
@ -43,15 +44,20 @@ import com.google.inject.name.Named;
|
|||
public class SupplyFromProviderURIOrNodesProperty implements Supplier<InputStream>, Function<URI, InputStream> {
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
private final URI url;
|
||||
private final Supplier<URI> url;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named("byon.nodes")
|
||||
@VisibleForTesting
|
||||
String nodes;
|
||||
|
||||
@VisibleForTesting
|
||||
public SupplyFromProviderURIOrNodesProperty(URI url) {
|
||||
this(Suppliers.ofInstance(checkNotNull(url, "url")));
|
||||
}
|
||||
|
||||
@Inject
|
||||
public SupplyFromProviderURIOrNodesProperty(@Provider URI url) {
|
||||
public SupplyFromProviderURIOrNodesProperty(@Provider Supplier<URI> url) {
|
||||
this.url = checkNotNull(url, "url");
|
||||
}
|
||||
|
||||
|
@ -59,7 +65,7 @@ public class SupplyFromProviderURIOrNodesProperty implements Supplier<InputStrea
|
|||
public InputStream get() {
|
||||
if (nodes != null)
|
||||
return Strings2.toInputStream(nodes);
|
||||
return apply(url);
|
||||
return apply(url.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -141,6 +141,7 @@ import org.jclouds.rest.internal.RestContextImpl;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
@ -256,12 +257,23 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
@Singleton
|
||||
@Provides
|
||||
@Integration
|
||||
protected URI providesIntegrationEndpoint(@Provider URI normal,
|
||||
@Named("jclouds.cloudstack.integration-api-port") int port,
|
||||
com.google.inject.Provider<UriBuilder> uriBuilder) {
|
||||
protected Supplier<URI> providesIntegrationEndpoint(@Provider final Supplier<URI> provider,
|
||||
@Named("jclouds.cloudstack.integration-api-port") final int port,
|
||||
final com.google.inject.Provider<UriBuilder> uriBuilder) {
|
||||
return Suppliers.compose(new Function<URI, URI>() {
|
||||
|
||||
@Override
|
||||
public URI apply(URI input) {
|
||||
URI normal = provider.get();
|
||||
return uriBuilder.get().scheme(normal.getScheme()).host(normal.getHost()).path("/").port(port).build();
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "getIntegrationEndpoint()";
|
||||
}
|
||||
}, provider);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class CredentialTypeFromPropertyOrDefault implements javax.inject.Provider<CredentialType> {
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jclouds.domain.LocationScope;
|
|||
import org.jclouds.location.suppliers.all.JustProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
|
@ -42,7 +43,8 @@ import com.google.common.collect.Iterables;
|
|||
@Test(singleThreaded = true, groups = "unit")
|
||||
public class ZoneToLocationTest {
|
||||
|
||||
static JustProvider justProvider = new JustProvider("cloudstack", URI.create("foo"), ImmutableSet.<String> of());
|
||||
static JustProvider justProvider = new JustProvider("cloudstack", Suppliers.ofInstance(URI.create("foo")),
|
||||
ImmutableSet.<String> of());
|
||||
static ZoneToLocation function = new ZoneToLocation(justProvider);
|
||||
static Location one = new LocationBuilder().parent(Iterables.get(justProvider.get(), 0)).scope(LocationScope.ZONE)
|
||||
.description("San Jose 1").id("1").build();
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.location.Iso3166;
|
|||
import org.jclouds.location.Provider;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -42,11 +43,11 @@ import com.google.common.base.Function;
|
|||
public class RealmToLocation implements Function<Realm, Location> {
|
||||
|
||||
private final String providerName;
|
||||
private final URI endpoint;
|
||||
private final Supplier<URI> endpoint;
|
||||
private final Set<String> isoCodes;
|
||||
|
||||
@Inject
|
||||
public RealmToLocation(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint) {
|
||||
public RealmToLocation(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider Supplier<URI> endpoint) {
|
||||
this.providerName = checkNotNull(providerName, "providerName");
|
||||
this.endpoint = checkNotNull(endpoint, "endpoint");
|
||||
this.isoCodes = checkNotNull(isoCodes, "isoCodes");
|
||||
|
@ -56,6 +57,6 @@ public class RealmToLocation implements Function<Realm, Location> {
|
|||
public Location apply(Realm from) {
|
||||
return new LocationBuilder().scope(LocationScope.ZONE).id(from.getHref().toASCIIString()).description(from.getName()).parent(
|
||||
new LocationBuilder().scope(LocationScope.PROVIDER).iso3166Codes(isoCodes).id(providerName).description(
|
||||
endpoint.toASCIIString()).parent(null).build()).build();
|
||||
endpoint.get().toASCIIString()).parent(null).build()).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,12 @@ import org.jclouds.util.Strings2;
|
|||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code DescribeRegionsResponseHandler}
|
||||
|
@ -52,8 +55,8 @@ public class DescribeRegionsResponseHandlerTest extends BaseHandlerTest {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(URI.class).annotatedWith(Provider.class).toInstance(
|
||||
URI.create("https://booya"));
|
||||
bind(new TypeLiteral<Supplier<URI>>(){}).annotatedWith(Provider.class).toInstance(
|
||||
Suppliers.ofInstance(URI.create("https://booya")));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -53,7 +53,8 @@ public class OrgAndVDCToLocationSupplier extends JustProvider implements Locatio
|
|||
private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
|
||||
|
||||
@Inject
|
||||
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
||||
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName,
|
||||
@Provider Supplier<URI> endpoint,
|
||||
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
|
||||
Supplier<Map<String, Org>> orgNameToVDCResource,
|
||||
@Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
|
||||
|
|
|
@ -91,8 +91,8 @@ public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudLoginAsyncC
|
|||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@VCloudLogin
|
||||
Supplier<URI> provideURI(@Provider URI uri) {
|
||||
return Suppliers.ofInstance(uri);
|
||||
Supplier<URI> provideURI(@Provider Supplier<URI> uri) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.jclouds.http.HttpUtils;
|
|||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.location.Provider;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -42,25 +44,25 @@ public class TransientBlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
private final BasicAuthentication basicAuth;
|
||||
private final BlobToHttpGetOptions blob2HttpGetOptions;
|
||||
private final String endpoint;
|
||||
private final Supplier<URI> endpoint;
|
||||
|
||||
@Inject
|
||||
public TransientBlobRequestSigner(BasicAuthentication basicAuth, BlobToHttpGetOptions blob2HttpGetOptions, @Provider URI endpoint) {
|
||||
public TransientBlobRequestSigner(BasicAuthentication basicAuth, BlobToHttpGetOptions blob2HttpGetOptions, @Provider Supplier<URI> endpoint) {
|
||||
this.basicAuth = checkNotNull(basicAuth, "basicAuth");
|
||||
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
||||
this.endpoint = endpoint.toString();
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name) {
|
||||
HttpRequest request = new HttpRequest("GET", URI.create(String.format("%s/%s/%s", endpoint, container, name)));
|
||||
HttpRequest request = new HttpRequest("GET", URI.create(String.format("%s/%s/%s", endpoint.get(), container, name)));
|
||||
return basicAuth.filter(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signPutBlob(String container, Blob blob) {
|
||||
HttpRequest request = HttpRequest.builder().method("PUT").endpoint(
|
||||
URI.create(String.format("%s/%s/%s", endpoint, container, blob.getMetadata().getName()))).payload(
|
||||
URI.create(String.format("%s/%s/%s", endpoint.get(), container, blob.getMetadata().getName()))).payload(
|
||||
blob.getPayload()).headers(
|
||||
HttpUtils.getContentHeadersFromMetadata(blob.getMetadata().getContentMetadata())).build();
|
||||
return basicAuth.filter(request);
|
||||
|
@ -68,7 +70,7 @@ public class TransientBlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
@Override
|
||||
public HttpRequest signRemoveBlob(String container, String name) {
|
||||
HttpRequest request = new HttpRequest("DELETE", URI.create(String.format("%s/%s/%s", endpoint, container,
|
||||
HttpRequest request = new HttpRequest("DELETE", URI.create(String.format("%s/%s/%s", endpoint.get(), container,
|
||||
name)));
|
||||
return basicAuth.filter(request);
|
||||
}
|
||||
|
@ -76,7 +78,7 @@ public class TransientBlobRequestSigner implements BlobRequestSigner {
|
|||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name, GetOptions options) {
|
||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create(String.format("%s/%s/%s", endpoint, container, name))).headers(
|
||||
URI.create(String.format("%s/%s/%s", endpoint.get(), container, name))).headers(
|
||||
blob2HttpGetOptions.apply(options).buildRequestHeaders()).build();
|
||||
return basicAuth.filter(request);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class OrgAndVDCToLocationSupplier extends JustProvider implements Locatio
|
|||
private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
|
||||
|
||||
@Inject
|
||||
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
||||
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider Supplier<URI> endpoint,
|
||||
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
|
||||
Supplier<Map<String, ? extends Org>> orgNameToVDCResource,
|
||||
@Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
@ -91,8 +90,8 @@ public class TerremarkVCloudLoginAsyncClientTest extends RestClientTest<Terremar
|
|||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@VCloudLogin
|
||||
Supplier<URI> provideURI(@Provider URI uri) {
|
||||
return Suppliers.ofInstance(uri);
|
||||
Supplier<URI> provideURI(@Provider Supplier<URI> uri) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -42,11 +42,11 @@ import com.google.common.collect.ImmutableSet;
|
|||
@Singleton
|
||||
public class JustProvider implements Supplier<Set<? extends Location>> {
|
||||
private final String providerName;
|
||||
private final URI endpointSupplier;
|
||||
private final Supplier<URI> endpointSupplier;
|
||||
private final Set<String> isoCodesSupplier;
|
||||
|
||||
@Inject
|
||||
public JustProvider(@Provider String providerName, @Provider URI endpointSupplier, @Iso3166 Set<String> isoCodesSupplier) {
|
||||
public JustProvider(@Provider String providerName, @Provider Supplier<URI> endpointSupplier, @Iso3166 Set<String> isoCodesSupplier) {
|
||||
this.providerName = checkNotNull(providerName, "providerName");
|
||||
this.endpointSupplier = checkNotNull(endpointSupplier, "endpoint");
|
||||
this.isoCodesSupplier = checkNotNull(isoCodesSupplier, "isoCodes");
|
||||
|
@ -55,7 +55,7 @@ public class JustProvider implements Supplier<Set<? extends Location>> {
|
|||
@Override
|
||||
public Set<? extends Location> get() {
|
||||
return ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id(providerName)
|
||||
.description(endpointSupplier.toASCIIString()).iso3166Codes(isoCodesSupplier).build());
|
||||
.description(endpointSupplier.get().toASCIIString()).iso3166Codes(isoCodesSupplier).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -26,13 +26,11 @@ import static org.jclouds.Constants.PROPERTY_API;
|
|||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_BUILD_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.Constants.PROPERTY_PROVIDER;
|
||||
import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -101,13 +99,6 @@ public class BindPropertiesToAnnotations extends ConfigurationModule {
|
|||
return in;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Provider
|
||||
protected URI bindProviderEndpoint(@Named(PROPERTY_ENDPOINT) String in){
|
||||
return URI.create(in);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Iso3166
|
||||
|
|
|
@ -429,7 +429,7 @@ public class RestAnnotationProcessor<T> {
|
|||
}
|
||||
} catch (IllegalStateException e) {
|
||||
logger.trace("looking up default endpoint for %s", cma);
|
||||
endpoint = injector.getInstance(Key.get(URI.class, org.jclouds.location.Provider.class));
|
||||
endpoint = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get();
|
||||
logger.trace("using default endpoint %s for %s", endpoint, cma);
|
||||
}
|
||||
GeneratedHttpRequest.Builder<T> requestBuilder;
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.jclouds.rest.annotations.BuildVersion;
|
|||
import org.jclouds.rest.annotations.Identity;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
|
@ -57,7 +58,7 @@ public class RestContextImpl<S, A> implements RestContext<S, A> {
|
|||
private final A asyncApi;
|
||||
private final S syncApi;
|
||||
private final Closer closer;
|
||||
private final URI endpoint;
|
||||
private final Supplier<URI> endpoint;
|
||||
private final String identity;
|
||||
private final String provider;
|
||||
private final String apiVersion;
|
||||
|
@ -68,7 +69,7 @@ public class RestContextImpl<S, A> implements RestContext<S, A> {
|
|||
|
||||
@Inject
|
||||
protected RestContextImpl(Closer closer, Map<String, Credentials> credentialStore, Utils utils, Injector injector,
|
||||
TypeLiteral<S> syncApi, TypeLiteral<A> asyncApi, @Provider URI endpoint, @Provider String provider,
|
||||
TypeLiteral<S> syncApi, TypeLiteral<A> asyncApi, @Provider Supplier<URI> endpoint, @Provider String provider,
|
||||
@Identity String identity, @ApiVersion String apiVersion, @BuildVersion String buildVersion,
|
||||
@Iso3166 Set<String> iso3166Codes) {
|
||||
this.credentialStore = credentialStore;
|
||||
|
@ -115,7 +116,7 @@ public class RestContextImpl<S, A> implements RestContext<S, A> {
|
|||
|
||||
@Override
|
||||
public URI getEndpoint() {
|
||||
return endpoint;
|
||||
return endpoint.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,9 +24,9 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.domain.LocationBuilder;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.location.suppliers.all.JustProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ public class JustProviderTest {
|
|||
|
||||
@Test
|
||||
public void test() throws SecurityException, NoSuchMethodException {
|
||||
JustProvider fn = new JustProvider("servo", URI.create("http://servo"), ImmutableSet.of("US"));
|
||||
JustProvider fn = new JustProvider("servo", Suppliers.ofInstance(URI.create("http://servo")), ImmutableSet.of("US"));
|
||||
assertEquals(
|
||||
fn.get(),
|
||||
ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id("servo").description("http://servo")
|
||||
|
|
|
@ -57,7 +57,7 @@ public class StartVBoxIfNotAlreadyRunning implements Supplier<VirtualBoxManager>
|
|||
private final Factory runScriptOnNodeFactory;
|
||||
private final RetryIfSocketNotYetOpen socketTester;
|
||||
private final Supplier<NodeMetadata> host;
|
||||
private final URI provider;
|
||||
private final Supplier<URI> providerSupplier;
|
||||
private final String identity;
|
||||
private final String credential;
|
||||
private final Function<Supplier<NodeMetadata>, VirtualBoxManager> managerForNode;
|
||||
|
@ -67,11 +67,11 @@ public class StartVBoxIfNotAlreadyRunning implements Supplier<VirtualBoxManager>
|
|||
@Inject
|
||||
public StartVBoxIfNotAlreadyRunning(Function<Supplier<NodeMetadata>, VirtualBoxManager> managerForNode,
|
||||
Factory runScriptOnNodeFactory, RetryIfSocketNotYetOpen socketTester, Supplier<NodeMetadata> host,
|
||||
@Provider URI provider, @Identity String identity, @Credential String credential) {
|
||||
@Provider Supplier<URI> providerSupplier, @Identity String identity, @Credential String credential) {
|
||||
this.runScriptOnNodeFactory = checkNotNull(runScriptOnNodeFactory, "runScriptOnNodeFactory");
|
||||
this.socketTester = checkNotNull(socketTester, "socketTester");
|
||||
this.host = checkNotNull(host, "host");
|
||||
this.provider = checkNotNull(provider, "endpoint to virtualbox websrvd is needed");
|
||||
this.providerSupplier = checkNotNull(providerSupplier, "endpoint to virtualbox websrvd is needed");
|
||||
this.identity = checkNotNull(identity, "identity");
|
||||
this.credential = checkNotNull(credential, "credential");
|
||||
this.managerForNode = checkNotNull(managerForNode, "managerForNode");
|
||||
|
@ -79,6 +79,7 @@ public class StartVBoxIfNotAlreadyRunning implements Supplier<VirtualBoxManager>
|
|||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
URI provider = providerSupplier.get();
|
||||
if (!socketTester.apply(new IPSocket(provider.getHost(), provider.getPort()))) {
|
||||
logger.debug("disabling password access");
|
||||
runScriptOnNodeFactory.create(host.get(), Statements.exec("VBoxManage setproperty websrvauthlibrary null"),
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions.admin;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -65,7 +65,7 @@ public class StartVBoxIfNotAlreadyRunningTest {
|
|||
replay(manager, runScriptOnNodeFactory, client);
|
||||
|
||||
new StartVBoxIfNotAlreadyRunning((Function) Functions.constant(manager), runScriptOnNodeFactory, client,
|
||||
Suppliers.ofInstance(host), provider, identity, credential).start();
|
||||
Suppliers.ofInstance(host), Suppliers.ofInstance(provider), identity, credential).start();
|
||||
|
||||
verify(manager, runScriptOnNodeFactory, client);
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class StartVBoxIfNotAlreadyRunningTest {
|
|||
|
||||
replay(manager, runScriptOnNodeFactory, runScriptOnNode, client);
|
||||
new StartVBoxIfNotAlreadyRunning((Function) Functions.constant(manager), runScriptOnNodeFactory, client,
|
||||
Suppliers.ofInstance(host), provider, identity, credential).start();
|
||||
Suppliers.ofInstance(host), Suppliers.ofInstance(provider), identity, credential).start();
|
||||
verify(manager, runScriptOnNodeFactory, runScriptOnNode, client);
|
||||
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class RimuHostingLocationSupplier extends JustProvider implements Locatio
|
|||
private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
|
||||
|
||||
@Inject
|
||||
RimuHostingLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
||||
RimuHostingLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider Supplier<URI> endpoint,
|
||||
RimuHostingClient sync, @Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
|
||||
super(providerName, endpoint, isoCodes);
|
||||
this.sync = checkNotNull(sync, "sync");
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.jclouds.savvis.vpdc.domain.Org;
|
|||
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -49,12 +50,12 @@ public class NetworkToLocation implements Function<Network, Location> {
|
|||
public static final Pattern netPattern = Pattern.compile(".*org/([0-9.]+)/vdc/([0-9.]+)/network/(.*)$");
|
||||
|
||||
private final String providerName;
|
||||
private final URI endpoint;
|
||||
private final Supplier<URI> endpoint;
|
||||
private final Set<String> isoCodes;
|
||||
private VPDCClient client;
|
||||
|
||||
@Inject
|
||||
public NetworkToLocation(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
||||
public NetworkToLocation(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider Supplier<URI> endpoint,
|
||||
VPDCClient client) {
|
||||
this.providerName = checkNotNull(providerName, "providerName");
|
||||
this.endpoint = checkNotNull(endpoint, "endpoint");
|
||||
|
@ -67,7 +68,7 @@ public class NetworkToLocation implements Function<Network, Location> {
|
|||
Matcher matcher = netPattern.matcher(from.getHref().toASCIIString());
|
||||
if (matcher.find()) {
|
||||
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id(providerName).description(
|
||||
endpoint.toASCIIString()).iso3166Codes(isoCodes).build();
|
||||
endpoint.get().toASCIIString()).iso3166Codes(isoCodes).build();
|
||||
|
||||
Org org = client.getBrowsingClient().getOrg(matcher.group(1));
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.softlayer.domain.Address;
|
|||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
@ -40,8 +41,8 @@ import com.google.common.collect.ImmutableSet;
|
|||
@Test(singleThreaded = true, groups = "unit")
|
||||
public class DatacenterToLocationTest {
|
||||
|
||||
static DatacenterToLocation function = new DatacenterToLocation(new JustProvider("softlayer", URI.create("foo"),
|
||||
ImmutableSet.<String> of()));
|
||||
static DatacenterToLocation function = new DatacenterToLocation(new JustProvider("softlayer", Suppliers
|
||||
.ofInstance(URI.create("foo")), ImmutableSet.<String> of()));
|
||||
|
||||
@Test
|
||||
public void testDatacenterToLocation() {
|
||||
|
|
Loading…
Reference in New Issue