Package org.jclouds
Class ContextBuilder
java.lang.Object
org.jclouds.ContextBuilder
Creates
ex. to build a
ex. to build a
Context or Injector configured to an api and
endpoint. Alternatively, this can be used to make a portable View of
that api.
ex. to build a
Api on a particular endpoint using the typed
interface
api = ContextBuilder.newBuilder(new NovaApiMetadata())
.endpoint("http://10.10.10.10:5000/v2.0")
.credentials(user, pass)
.buildApi(NovaApi.class);
ex. to build a
View of a particular backend context, looked up by
key.
context = ContextBuilder.newBuilder("aws-s3")
.credentials(apikey, secret)
.buildView(BlobStoreContext.class);
Assumptions
Threadsafe objects will be bound as singletons to the Injector or Context provided. If noModules are specified, the default
logging and
http transports will be
installed.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ApiMetadataprotected Stringprotected Stringprotected Stringprotected com.google.common.base.Optional<com.google.common.base.Supplier<Credentials>> protected com.google.common.base.Optional<String> protected com.google.common.base.Optional<String> protected List<com.google.inject.Module> protected com.google.common.base.Optional<String> protected com.google.common.base.Optional<Properties> protected final Stringprotected com.google.common.base.Optional<ProviderMetadata> -
Constructor Summary
ConstructorsModifierConstructorDescriptionContextBuilder(ApiMetadata apiMetadata) protectedContextBuilder(ProviderMetadata providerMetadata) protectedContextBuilder(ProviderMetadata providerMetadata, ApiMetadata apiMetadata) -
Method Summary
Modifier and TypeMethodDescriptionapiVersion(String apiVersion) <C extends Context>
Cbuild()Builds the base context for this api.<C extends Context>
Cbuild(com.google.common.reflect.TypeToken<C> contextType) this will build thecontextsupported by the current ApiMetadata.<V extends View>
V<A extends Closeable>
AbuildApi(com.google.common.reflect.TypeToken<A> apiType) likebuildApi(Class)but permits a type-token for convenience.<A extends Closeable>
AThis will return the top-level interface for the api or provider.protected com.google.common.base.Supplier<Credentials> buildCredentialsSupplier(Properties expanded) com.google.inject.Injectorstatic com.google.inject.InjectorbuildInjector(String name, ProviderMetadata providerMetadata, com.google.common.base.Supplier<Credentials> creds, List<com.google.inject.Module> inputModules) buildVersion(String buildVersion) <V extends View>
VbuildView(com.google.common.reflect.TypeToken<V> viewType) this will build anyviewsupported by the ApiMetadata.<V extends View>
Vcredentials(String identity, String credential) constant value of the cloud identity and credential.credentialsSupplier(com.google.common.base.Supplier<Credentials> credentialsSupplier) returns the current login credentials.protected Propertiesstatic ContextBuildernewBuilder(String providerOrApi) looks up a provider or api with the given idstatic ContextBuildernewBuilder(ApiMetadata apiMetadata) static ContextBuildernewBuilder(ProviderMetadata providerMetadata) overrides(Properties overrides) static StringsearchPropertiesForProviderScopedProperty(Properties mutable, String prov, String key) toString()
-
Field Details
-
name
-
providerMetadata
-
providerId
-
endpoint
-
identity
-
credentialsSupplierOption
protected com.google.common.base.Optional<com.google.common.base.Supplier<Credentials>> credentialsSupplierOption -
credential
-
apiMetadata
-
apiVersion
-
buildVersion
-
overrides
-
modules
-
-
Constructor Details
-
ContextBuilder
-
ContextBuilder
-
ContextBuilder
-
-
Method Details
-
newBuilder
looks up a provider or api with the given id- Parameters:
providerOrApi- id of the provider or api- Returns:
- means to build a context to that provider
- Throws:
NoSuchElementException- if the id was not configured.
-
newBuilder
-
newBuilder
-
toString
-
name
-
credentialsSupplier
public ContextBuilder credentialsSupplier(com.google.common.base.Supplier<Credentials> credentialsSupplier) returns the current login credentials. jclouds will not cache this value. Use this when you need to change credentials at runtime. -
credentials
constant value of the cloud identity and credential.- Parameters:
credential- (optional depending onApiMetadata.getCredentialName()
-
endpoint
-
apiVersion
-
buildVersion
-
modules
-
overrides
-
searchPropertiesForProviderScopedProperty
public static String searchPropertiesForProviderScopedProperty(Properties mutable, String prov, String key) throws NoSuchElementException - Throws:
NoSuchElementException
-
buildInjector
public com.google.inject.Injector buildInjector() -
buildCredentialsSupplier
protected com.google.common.base.Supplier<Credentials> buildCredentialsSupplier(Properties expanded) -
getSystemProperties
-
buildInjector
public static com.google.inject.Injector buildInjector(String name, ProviderMetadata providerMetadata, com.google.common.base.Supplier<Credentials> creds, List<com.google.inject.Module> inputModules) -
build
Builds the base context for this api. Note that this may be of type, if nothing else was configured viainvalid reference
CloserApiMetadata.getContext(). Typically, the type returned isinvalid reference
ApiContext- See Also:
-
build
- See Also:
-
buildView
- See Also:
-
buildView
-
build
this will build thecontextsupported by the current ApiMetadata. -
buildApi
This will return the top-level interface for the api or provider. Ex.api = ContextBuilder.newBuilder("openstack-nova") ... .buildApi(NovaApi.class); -
buildApi
likebuildApi(Class)but permits a type-token for convenience. -
getApiMetadata
-