org.jclouds.rest
Class RestContextFactory

java.lang.Object
  extended by org.jclouds.rest.RestContextFactory

public class RestContextFactory
extends Object

Helper class to instantiate RestContext instances. "blobstore.properties" At least one property is needed needed per context:

Optional properties are as follows Ex.
 azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureRestContextBuilder
 azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder
 

Author:
Adrian Cole

Constructor Summary
RestContextFactory()
          Initializes with the default properties built-in to jclouds.
RestContextFactory(Properties properties)
          Initializes the RestContext definitions from the specified properties.
RestContextFactory(String filename)
          Initializes with the default properties built-in to jclouds.
 
Method Summary
static
<S,A> RestContext<S,A>
buildContextUnwrappingExceptions(RestContextBuilder<S,A> builder)
           
static
<S,A> RestContextSpec<S,A>
contextSpec(String provider, String endpoint, String apiVersion, String buildVersion, String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async)
           
static
<S,A> RestContextSpec<S,A>
contextSpec(String provider, String endpoint, String apiVersion, String buildVersion, String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async, Class<PropertiesBuilder> propertiesBuilderClass, Class<RestContextBuilder<S,A>> contextBuilderClass, Iterable<com.google.inject.Module> modules)
           
static
<S,A> RestContextSpec<S,A>
contextSpec(String provider, String endpoint, String apiVersion, String buildVersion, String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async, Iterable<com.google.inject.Module> modules)
           
static
<S,A> RestContext<S,A>
createContext(RestContextSpec<S,A> contextSpec)
           
static
<S,A> RestContext<S,A>
createContext(RestContextSpec<S,A> contextSpec, Iterable<com.google.inject.Module> modules)
           
static
<S,A> RestContext<S,A>
createContext(RestContextSpec<S,A> contextSpec, Iterable<com.google.inject.Module> modules, Properties overrides)
           
static
<S,A> RestContext<S,A>
createContext(RestContextSpec<S,A> contextSpec, Properties overrides)
           
<S,A> RestContext<S,A>
createContext(String provider, Iterable<? extends com.google.inject.Module> wiring, Properties overrides)
           
<S,A> RestContext<S,A>
createContext(String provider, Properties overrides)
           
<S,A> RestContext<S,A>
createContext(String provider, String identity, String credential)
           
<S,A> RestContext<S,A>
createContext(String provider, String identity, String credential, Iterable<? extends com.google.inject.Module> wiring)
           
<S,A> RestContext<S,A>
createContext(String provider, String identity, String credential, Iterable<? extends com.google.inject.Module> wiring, Properties overrides)
           
<S,A> RestContext<S,A>
createContext(String provider, String identity, String credential, Properties properties)
           
static
<S,A> RestContextBuilder<S,A>
createContextBuilder(RestContextSpec<S,A> contextSpec)
           
static
<S,A> RestContextBuilder<S,A>
createContextBuilder(RestContextSpec<S,A> contextSpec, Iterable<com.google.inject.Module> modules)
           
static
<S,A> RestContextBuilder<S,A>
createContextBuilder(RestContextSpec<S,A> contextSpec, Iterable<com.google.inject.Module> modules, Properties overrides)
           
static
<S,A> RestContextBuilder<S,A>
createContextBuilder(RestContextSpec<S,A> contextSpec, Properties overrides)
           
<S,A> RestContextBuilder<S,A>
createContextBuilder(String provider, Iterable<? extends com.google.inject.Module> wiring, Properties overrides)
          Identity will be found by searching jclouds.identity failing that provider.identity where provider corresponds to the parameter.
<S,A> RestContextBuilder<S,A>
createContextBuilder(String provider, Iterable<com.google.inject.Module> modules)
           
<S,A> RestContextBuilder<S,A>
createContextBuilder(String provider, Properties overrides)
           
<S,A> RestContextBuilder<S,A>
createContextBuilder(String provider, String identity, String credential)
           
<S,A> RestContextBuilder<S,A>
createContextBuilder(String provider, String identity, String credential, Iterable<? extends com.google.inject.Module> wiring)
           
<S,A> RestContextBuilder<S,A>
createContextBuilder(String providerName, String identity, String credential, Iterable<? extends com.google.inject.Module> wiring, Properties _overrides)
          Creates a new remote context.
<S,A> RestContextBuilder<S,A>
createContextBuilder(String provider, String identity, String credential, Properties properties)
           
<S,A> RestContextSpec<S,A>
createContextSpec(String providerName, String identity, String credential, Iterable<? extends com.google.inject.Module> wiring, Properties _overrides)
           
<S,A> RestContextSpec<S,A>
createContextSpec(String providerName, String identity, String credential, Properties _overrides)
           
static Properties getPropertiesFromResource(String filename)
          Loads the default properties that define the RestContext objects.
static Properties toProperties(RestContextSpec<?,?> contextSpec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestContextFactory

public RestContextFactory()
Initializes with the default properties built-in to jclouds. This is typically stored in the classpath resource rest.properties

See Also:
getPropertiesFromResource(java.lang.String)

RestContextFactory

public RestContextFactory(String filename)
Initializes with the default properties built-in to jclouds. This is typically stored in the classpath resource filename

Parameters:
filename - name of the properties file to initialize from
Throws:
IOException - if the default properties file cannot be loaded
See Also:
getPropertiesFromResource(java.lang.String)

RestContextFactory

@Inject
public RestContextFactory(Properties properties)
Initializes the RestContext definitions from the specified properties.

Method Detail

contextSpec

public static <S,A> RestContextSpec<S,A> contextSpec(String provider,
                                                     String endpoint,
                                                     String apiVersion,
                                                     String buildVersion,
                                                     String iso3166Codes,
                                                     String identity,
                                                     String credential,
                                                     Class<S> sync,
                                                     Class<A> async,
                                                     Class<PropertiesBuilder> propertiesBuilderClass,
                                                     Class<RestContextBuilder<S,A>> contextBuilderClass,
                                                     Iterable<com.google.inject.Module> modules)

contextSpec

public static <S,A> RestContextSpec<S,A> contextSpec(String provider,
                                                     String endpoint,
                                                     String apiVersion,
                                                     String buildVersion,
                                                     String iso3166Codes,
                                                     String identity,
                                                     String credential,
                                                     Class<S> sync,
                                                     Class<A> async)

contextSpec

public static <S,A> RestContextSpec<S,A> contextSpec(String provider,
                                                     String endpoint,
                                                     String apiVersion,
                                                     String buildVersion,
                                                     String iso3166Codes,
                                                     String identity,
                                                     String credential,
                                                     Class<S> sync,
                                                     Class<A> async,
                                                     Iterable<com.google.inject.Module> modules)

getPropertiesFromResource

public static Properties getPropertiesFromResource(String filename)
Loads the default properties that define the RestContext objects.

properties file format

Two properties are needed per context: Ex.
 azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureRestContextBuilder
 azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder
 

Parameters:
filename - name of file to load from in the resource path
Returns:
properties object with these items loaded for each tag

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String provider,
                                                          String identity,
                                                          String credential)

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String provider,
                                                          Properties overrides)
See Also:
RestContextFactory#createContextBuilder(String, Properties, Iterable, Properties)

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String provider,
                                                          Iterable<com.google.inject.Module> modules)
See Also:
RestContextFactory#createContextBuilder(String, Properties, Iterable, Properties)

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String provider,
                                                          Iterable<? extends com.google.inject.Module> wiring,
                                                          Properties overrides)
Identity will be found by searching jclouds.identity failing that provider.identity where provider corresponds to the parameter. Same pattern is used for credential (jclouds.credential failing that provider.credential).

Type Parameters:
S - Type of the provider specific client
A - Type of the provide specific async client (same as above, yet all methods return Future results)
Parameters:
provider - name of the provider (ex. s3, bluelock, etc.)
wiring - defines how objects are bound to interfaces, pass in here to override this, or specify service implementations.
overrides - properties to pass to the context.

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String provider,
                                                          @Nullable
                                                          String identity,
                                                          @Nullable
                                                          String credential,
                                                          Properties properties)

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String provider,
                                                          @Nullable
                                                          String identity,
                                                          @Nullable
                                                          String credential,
                                                          Iterable<? extends com.google.inject.Module> wiring)

createContextBuilder

public <S,A> RestContextBuilder<S,A> createContextBuilder(String providerName,
                                                          @Nullable
                                                          String identity,
                                                          @Nullable
                                                          String credential,
                                                          Iterable<? extends com.google.inject.Module> wiring,
                                                          Properties _overrides)
Creates a new remote context.

Parameters:
provider -
identity - nullable, if credentials are present in the overrides
credential - nullable, if credentials are present in the overrides
wiring - Configuration you'd like to pass to the context. Ex. ImmutableSet.of(new ExecutorServiceModule(myexecutor))
overrides - properties to override defaults with.
Returns:
initialized context ready for use

toProperties

public static Properties toProperties(RestContextSpec<?,?> contextSpec)

createContextSpec

public <S,A> RestContextSpec<S,A> createContextSpec(String providerName,
                                                    String identity,
                                                    String credential,
                                                    Properties _overrides)

createContextSpec

public <S,A> RestContextSpec<S,A> createContextSpec(String providerName,
                                                    String identity,
                                                    String credential,
                                                    Iterable<? extends com.google.inject.Module> wiring,
                                                    Properties _overrides)

createContextBuilder

public static <S,A> RestContextBuilder<S,A> createContextBuilder(RestContextSpec<S,A> contextSpec)

createContextBuilder

public static <S,A> RestContextBuilder<S,A> createContextBuilder(RestContextSpec<S,A> contextSpec,
                                                                 Properties overrides)

createContextBuilder

public static <S,A> RestContextBuilder<S,A> createContextBuilder(RestContextSpec<S,A> contextSpec,
                                                                 Iterable<com.google.inject.Module> modules)

createContextBuilder

public static <S,A> RestContextBuilder<S,A> createContextBuilder(RestContextSpec<S,A> contextSpec,
                                                                 Iterable<com.google.inject.Module> modules,
                                                                 Properties overrides)

createContext

public <S,A> RestContext<S,A> createContext(String provider,
                                            String identity,
                                            String credential)
See Also:
createContextBuilder(String, String, String)

buildContextUnwrappingExceptions

public static <S,A> RestContext<S,A> buildContextUnwrappingExceptions(RestContextBuilder<S,A> builder)

createContext

public <S,A> RestContext<S,A> createContext(String provider,
                                            Properties overrides)
See Also:
createContextBuilder(String, Properties)

createContext

public <S,A> RestContext<S,A> createContext(String provider,
                                            Iterable<? extends com.google.inject.Module> wiring,
                                            Properties overrides)
See Also:
createContextBuilder(String, Iterable)

createContext

public <S,A> RestContext<S,A> createContext(String provider,
                                            @Nullable
                                            String identity,
                                            @Nullable
                                            String credential,
                                            Properties properties)
See Also:
createContextBuilder(String, String,String, Properties)

createContext

public <S,A> RestContext<S,A> createContext(String provider,
                                            @Nullable
                                            String identity,
                                            @Nullable
                                            String credential,
                                            Iterable<? extends com.google.inject.Module> wiring)
See Also:
createContextBuilder(String, String,String, Iterable)

createContext

public <S,A> RestContext<S,A> createContext(String provider,
                                            @Nullable
                                            String identity,
                                            @Nullable
                                            String credential,
                                            Iterable<? extends com.google.inject.Module> wiring,
                                            Properties overrides)
See Also:
createContextBuilder(String, String,String, Iterable, Properties)

createContext

public static <S,A> RestContext<S,A> createContext(RestContextSpec<S,A> contextSpec)
See Also:
createContextBuilder(RestContextSpec)

createContext

public static <S,A> RestContext<S,A> createContext(RestContextSpec<S,A> contextSpec,
                                                   Properties overrides)
See Also:
createContextBuilder(RestContextSpec, Properties)

createContext

public static <S,A> RestContext<S,A> createContext(RestContextSpec<S,A> contextSpec,
                                                   Iterable<com.google.inject.Module> modules)
See Also:
createContextBuilder(RestContextSpec, Iterable)

createContext

public static <S,A> RestContext<S,A> createContext(RestContextSpec<S,A> contextSpec,
                                                   Iterable<com.google.inject.Module> modules,
                                                   Properties overrides)
See Also:
createContextBuilder(RestContextSpec, Iterable, Properties)


Copyright © 2009-2012 jclouds. All Rights Reserved.