synchronized (CloudStoreProxy.class)
{
logger.debug("Creating new connection for '{}' blob store.", profileName);
Properties properties = new Properties();
BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName);
ContextBuilder contextBuilder = ContextBuilder.newBuilder(profile.getProvider());
if (profile.getProvider().equals(PROVIDER_FILESYSTEM)) {
// use endpoint as fs basedir, see: http://code.google.com/p/jclouds/issues/detail?id=776
properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, profile.getEndpoint());
contextBuilder.endpoint(profile.getEndpoint());
//properties.setProperty(PROPERTY_CREDENTIAL, "dummy");
} else if (BLOBSTORE_PROVIDERS.contains(profile.getProvider())) {
if (profile.getEndpoint() != null) {
contextBuilder.endpoint(profile.getEndpoint());
}
if (profile.getApiversion() != null) {
contextBuilder.apiVersion(profile.getApiversion());
}
if (profile.getIdentity() != null && profile.getCredential() != null) {
contextBuilder.credentials(profile.getIdentity(), profile.getCredential());
}
} else {
throw new UnsupportedOperationException(
"Unsupported Blobstore provider: " + profile.getProvider());
}
// get a context with filesystem that offers the portable BlobStore api
BlobStoreContext context = contextBuilder
.overrides(properties)
.modules(ImmutableSet.of(new JcloudsSlf4JLoggingModule()))
.buildView(BlobStoreContext.class);
// create container for transient store
if(profile.getProvider().equals(PROVIDER_TRANSIENT)) {
context.getBlobStore().createContainerInLocation(null, profile.getContainer());
}
blobStoreContexts.put(profileName, context);
}