public class ContextBuilder extends Object
Context
or Injector
configured to an api and
endpoint. Alternatively, this can be used to make a portable View
of
that api.
RestContext
on a particular endpoint using the typed
interface
context = ContextBuilder.newBuilder(new NovaApiMetadata()) .endpoint("http://10.10.10.10:5000/v2.0") .credentials(user, pass) .build(NovaApiMetadata.CONTEXT_TOKEN)
View
of a particular backend context, looked up by
key.
context = ContextBuilder.newBuilder("aws-s3") .credentials(apikey, secret) .buildView(BlobStoreContext.class);
Module
s are specified, the default
logging
and
http transports
will be
installed.Context
,
View
,
ApiMetadata
,
ProviderMetadata
Modifier and Type | Field and Description |
---|---|
protected ApiMetadata |
apiMetadata |
protected String |
apiVersion |
protected String |
buildVersion |
protected String |
credential |
protected com.google.common.base.Optional<com.google.common.base.Supplier<Credentials>> |
credentialsSupplierOption |
protected com.google.common.base.Optional<String> |
endpoint |
protected com.google.common.base.Optional<String> |
identity |
protected List<com.google.inject.Module> |
modules |
protected com.google.common.base.Optional<String> |
name |
protected com.google.common.base.Optional<Properties> |
overrides |
protected String |
providerId |
protected com.google.common.base.Optional<ProviderMetadata> |
providerMetadata |
Modifier | Constructor and Description |
---|---|
|
ContextBuilder(ApiMetadata apiMetadata) |
protected |
ContextBuilder(ProviderMetadata providerMetadata) |
protected |
ContextBuilder(ProviderMetadata providerMetadata,
ApiMetadata apiMetadata) |
Modifier and Type | Method and Description |
---|---|
ContextBuilder |
apiVersion(String apiVersion) |
<C extends Context> |
build()
Builds the base context for this api.
|
<V extends View> |
build(Class<V> viewType) |
<C extends Context> |
build(com.google.common.reflect.TypeToken<C> contextType)
this will build the
context supported by the current ApiMetadata. |
protected com.google.common.base.Supplier<Credentials> |
buildCredentialsSupplier(Properties expanded) |
com.google.inject.Injector |
buildInjector() |
static com.google.inject.Injector |
buildInjector(String name,
ProviderMetadata providerMetadata,
com.google.common.base.Supplier<Credentials> creds,
List<com.google.inject.Module> inputModules) |
ContextBuilder |
buildVersion(String buildVersion) |
<V extends View> |
buildView(Class<V> viewType) |
<V extends View> |
buildView(com.google.common.reflect.TypeToken<V> viewType)
this will build any
view supported by the ApiMetadata. |
ContextBuilder |
credentials(String identity,
String credential)
constant value of the cloud identity and credential.
|
ContextBuilder |
credentialsSupplier(com.google.common.base.Supplier<Credentials> credentialsSupplier)
returns the current login credentials.
|
ContextBuilder |
endpoint(String endpoint) |
ApiMetadata |
getApiMetadata() |
protected Properties |
getSystemProperties() |
ContextBuilder |
modules(Iterable<? extends com.google.inject.Module> modules) |
ContextBuilder |
name(String name) |
static ContextBuilder |
newBuilder(ApiMetadata apiMetadata) |
static ContextBuilder |
newBuilder(ProviderMetadata providerMetadata) |
static ContextBuilder |
newBuilder(String providerOrApi)
looks up a provider or api with the given id
|
ContextBuilder |
overrides(Properties overrides) |
static String |
searchPropertiesForProviderScopedProperty(Properties mutable,
String prov,
String key) |
String |
toString() |
protected com.google.common.base.Optional<String> name
protected com.google.common.base.Optional<ProviderMetadata> providerMetadata
protected final String providerId
protected com.google.common.base.Optional<String> endpoint
protected com.google.common.base.Optional<String> identity
protected com.google.common.base.Optional<com.google.common.base.Supplier<Credentials>> credentialsSupplierOption
protected ApiMetadata apiMetadata
protected String apiVersion
protected String buildVersion
protected com.google.common.base.Optional<Properties> overrides
protected List<com.google.inject.Module> modules
protected ContextBuilder(ProviderMetadata providerMetadata)
protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata)
public ContextBuilder(ApiMetadata apiMetadata)
public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException
providerOrApi
- id of the provider or apiNoSuchElementException
- if the id was not configured.public static ContextBuilder newBuilder(ApiMetadata apiMetadata)
public static ContextBuilder newBuilder(ProviderMetadata providerMetadata)
public ContextBuilder name(String name)
public ContextBuilder credentialsSupplier(com.google.common.base.Supplier<Credentials> credentialsSupplier)
public ContextBuilder credentials(String identity, @Nullable String credential)
credential
- (optional depending on ApiMetadata.getCredentialName()
public ContextBuilder endpoint(String endpoint)
public ContextBuilder apiVersion(String apiVersion)
public ContextBuilder buildVersion(String buildVersion)
public ContextBuilder modules(Iterable<? extends com.google.inject.Module> modules)
public ContextBuilder overrides(Properties overrides)
public static String searchPropertiesForProviderScopedProperty(Properties mutable, String prov, String key) throws NoSuchElementException
NoSuchElementException
public com.google.inject.Injector buildInjector()
protected com.google.common.base.Supplier<Credentials> buildCredentialsSupplier(Properties expanded)
protected Properties getSystemProperties()
public static com.google.inject.Injector buildInjector(String name, ProviderMetadata providerMetadata, com.google.common.base.Supplier<Credentials> creds, List<com.google.inject.Module> inputModules)
public <C extends Context> C build()
Closer
, if nothing
else was configured via ApiMetadata.getContext()
. Typically, the type returned is
RestContext
ApiMetadata.getContext()
,
build(TypeToken)
public <V extends View> V build(Class<V> viewType)
buildView(Class)
public <V extends View> V buildView(Class<V> viewType)
buildView(TypeToken)
public <V extends View> V buildView(com.google.common.reflect.TypeToken<V> viewType)
public <C extends Context> C build(com.google.common.reflect.TypeToken<C> contextType)
context
supported by the current ApiMetadata.public ApiMetadata getApiMetadata()
Copyright © 2009-2013 jclouds. All Rights Reserved.