diff --git a/documentation/quickstart/aws.markdown b/documentation/quickstart/aws.markdown index 5ecf079..f0b5a7b 100644 --- a/documentation/quickstart/aws.markdown +++ b/documentation/quickstart/aws.markdown @@ -21,8 +21,9 @@ import static org.jclouds.aws.s3.options.PutObjectOptions.Builder.withAcl; // get a context with amazon that offers the portable BlobStore API -BlobStoreContext context = new BlobStoreContextFactory(). - createContext("aws-s3", accesskeyid, secretkey); +BlobStoreContext context = ContextBuilder.newBuilder("aws-s3") + .credentials(accesskeyid, secretkey) + .buildView(BlobStoreContext.class); // create a container in the default location BlobStore blobStore = context.getBlobStore(); @@ -53,12 +54,11 @@ context.close(); {% highlight java %} // get a context with ec2 that offers the portable ComputeService API -ComputeServiceContext context = - new ComputeServiceContextFactory().createContext("aws-ec2", - accesskeyid, - secretkey, - ImmutableSet. of(new Log4JLoggingModule(), - new SshjSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2") + .credentials(accesskeyid, secretkey) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // here's an example of the portable api Set locations = diff --git a/documentation/quickstart/azure-storage.markdown b/documentation/quickstart/azure-storage.markdown index c3436f1..3a21838 100644 --- a/documentation/quickstart/azure-storage.markdown +++ b/documentation/quickstart/azure-storage.markdown @@ -23,7 +23,9 @@ title: Quick Start - Azure Storage Service import static org.jclouds.azure.storage.blob.options.CreateContainerOptions.Builder.withPublicAcl; // get a context with amazon that offers the portable BlobStore api -BlobStoreContext context = new BlobStoreContextFactory().createContext("azureblob", accesskeyid, secretkey); +BlobStoreContext context = ContextBuilder.newBuilder("azureblob") + .credentials(accesskeyid, secretkey) + .buildView(BlobStoreContext.class); //create a container in the default location context.getBlobStore().createContainerInLocation(null, bucket); diff --git a/documentation/quickstart/bluelock.markdown b/documentation/quickstart/bluelock.markdown index 819457c..c620f07 100644 --- a/documentation/quickstart/bluelock.markdown +++ b/documentation/quickstart/bluelock.markdown @@ -15,12 +15,11 @@ title: Quick Start - BlueLock vCloud Service {% highlight java %} -ComputeServiceContext context = - new ComputeServiceContextFactory().createContext("bluelock-vcdirector", - "username@orgname", - password, - ImmutableSet. of(new JschSshClientModule())); - +ComputeServiceContext context = ContextBuilder.newBuilder("bluelock-vcdirector") + .credentials("username@orgname", password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // create a customization script to run when the machine starts up String script = "cat > /root/foo.txt< of(new JschSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("cloudsigma-zrh") + .credentials(email, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // run a couple nodes accessible via group webserver nodes = context.getComputeService().client.runNodesInGroup("webserver", 2); diff --git a/documentation/quickstart/filesystem.md b/documentation/quickstart/filesystem.md index 68524a4..38e8bcb 100644 --- a/documentation/quickstart/filesystem.md +++ b/documentation/quickstart/filesystem.md @@ -17,7 +17,9 @@ properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, "./local/filesystem String containerName = "test-container"; // get a context with filesystem that offers the portable BlobStore api -BlobStoreContext context = new BlobStoreContextFactory().createContext("filesystem", properties); +BlobStoreContext context = ContextBuilder.newBuilder("filesystem") + .overrides(properties) + .buildView(BlobStoreContext.class); // create a container in the default location BlobStore blobStore = context.getBlobStore(); diff --git a/documentation/quickstart/go-grid.markdown b/documentation/quickstart/go-grid.markdown index 1c30501..2b386ff 100644 --- a/documentation/quickstart/go-grid.markdown +++ b/documentation/quickstart/go-grid.markdown @@ -23,8 +23,12 @@ To create a context for all subsequent API calls, use: {% highlight java %} RestContext context = - new ComputeServiceFactory().createContext(key, sharedSecret) - .getProviderSpecificContext(); + ContextBuilder.newBuilder("gogrid") + .credentials(key, sharedSecret) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class) + .getProviderSpecificContext(); GoGridClient client = context.getApi(); @@ -98,8 +102,12 @@ sshClient.disconnect(); To create a generic context, use (as in the previous section): {% highlight java %} -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("gogrid", user, password, - ImmutableSet.of(new Log4JLoggingModule(), new JschSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("gogrid") + .credentials(key, sharedSecret) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); + ComputeService service = context.getComputeService(); {% endhighlight %} diff --git a/documentation/quickstart/hpcloud.markdown b/documentation/quickstart/hpcloud.markdown index 4cbd055..52dea80 100644 --- a/documentation/quickstart/hpcloud.markdown +++ b/documentation/quickstart/hpcloud.markdown @@ -27,7 +27,9 @@ To get the CredentialTypes class, please see the [Javadoc](http://demobox.github {% highlight java %} // Get a context with hpcloud that offers the portable BlobStore API -BlobStoreContext context = new BlobStoreContextFactory().createContext("hpcloud-objectstorage", "tenantName:accessKey", "password"); +BlobStoreContext context = ContextBuilder.newBuilder("hpcloud-objectstorage") + .credentials("tenantName:accessKey", "password") + .buildView(BlobStoreContext.class); // Create a container in the default location context.getBlobStore().createContainerInLocation(null, container); @@ -67,7 +69,12 @@ context.close(); {% highlight java %} // Get a context with hpcloud-compute that offers the portable ComputeService API -ComputeServiceContext ctx = new ComputeServiceContextFactory().createContext("hpcloud-compute", "tenantName:accessKey", "password"); +ComputeServiceContext ctx = ContextBuilder.newBuilder("hpcloud-compute") + .credentials("tenantName:accessKey", "password") + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); + ComputeService cs = ctx.getComputeService(); // List availability zones diff --git a/documentation/quickstart/terremark-ecloud.markdown b/documentation/quickstart/terremark-ecloud.markdown index 0eadb6a..45bdbb4 100644 --- a/documentation/quickstart/terremark-ecloud.markdown +++ b/documentation/quickstart/terremark-ecloud.markdown @@ -17,8 +17,11 @@ title: Quick Start - Terremark eCloud import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount; // get a context with Terremark that offers the portable ComputeService api - ComputeServiceContext context = new ComputeServiceContextFactory().createContext("trmk-ecloud", email, password, - ImmutableSet. of(new JschSshClientModule())); + ComputeServiceContext context = ContextBuilder.newBuilder("trmk-ecloud") + .credentials(email, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // TODO: eCloud in ComputeService example diff --git a/documentation/quickstart/terremark-vcloud-express.markdown b/documentation/quickstart/terremark-vcloud-express.markdown index 3fcea4d..9d7cbde 100644 --- a/documentation/quickstart/terremark-vcloud-express.markdown +++ b/documentation/quickstart/terremark-vcloud-express.markdown @@ -18,8 +18,11 @@ title: Quick Start- Terremark vCloud Express import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount; // get a context with terremark that offers the portable ComputeService api -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("trmk-vcloudexpress", email, password, - ImmutableSet. of(new JschSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("trmk-vcloudexpress") + .credentials(email, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // here's an example of the portable api diff --git a/documentation/reference/jclouds-api.markdown b/documentation/reference/jclouds-api.markdown index 42cc620..e4513b2 100644 --- a/documentation/reference/jclouds-api.markdown +++ b/documentation/reference/jclouds-api.markdown @@ -44,8 +44,16 @@ import static org.jclouds.Constants.*; Set wiring = ImmutableSet.of(new EnterpriseConfigurationModule(), new Log4JLoggingModule()); // same properties and wiring can be used for many services, although the limits are per context - blobStoreContext = new BlobStoreContextFactory().createContext("s3", account, key, wiring, overrides); - computeContext = new ComputeServiceContextFactory().createContext("ec2", account, key, wiring, overrides); + blobStoreContext = ContextBuilder.newBuilder("s3") + .credentials(account, key) + .modules(wiring) + .overrides(overrides) + .buildView(BlobStoreContext.class); + computeContext = ContextBuilder.newBuilder("ec2") + .credentials(account, key) + .modules(wiring) + .overrides(overrides) + .buildView(ComputeServiceContext.class); {% endhighlight %} ### Timeout diff --git a/documentation/userguide/blobstore-guide.md b/documentation/userguide/blobstore-guide.md index b0fbb8f..67df7f1 100644 --- a/documentation/userguide/blobstore-guide.md +++ b/documentation/userguide/blobstore-guide.md @@ -126,7 +126,9 @@ At a minimum, you need to specify your identity (in the case of S3, AWS Access K Once you have your credentials, connecting to your `BlobStore` service is easy: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", identity, credential); +BlobStoreContext context = ContextBuilder.newBuilder("aws-s3") + .credentials(identity, credential) + .buildView(BlobStoreContext.class); {% endhighlight %} This will give you a connection to the BlobStore, and if it is remote, it will be SSL unless unsupported by @@ -157,7 +159,9 @@ If you don't want to be bothered with the details of a BlobStore like Amazon S3, you want to manage, and get to work: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", identity, credential); +BlobStoreContext context = ContextBuilder.newBuilder("aws-s3") + .credentials(identity, credential) + .buildView(BlobStoreContext.class); Map map = context.createInputStreamMap("adrian.photos"); // do work context.close(); @@ -201,7 +205,9 @@ Considering it is only one class at this point, this is a decent tradeoff for ma Here is an example that shows how to use the `BlobMap` API: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", identity, credential); +BlobStoreContext context = ContextBuilder.newBuilder("aws-s3") + .credentials(identity, credential) + .buildView(BlobStoreContext.class); BlobMap map = context.createBlobMap("adrian.photos"); Blob blob = map.blobBuilder("sushi.jpg") @@ -222,10 +228,10 @@ Here is an example of the `BlobStore` interface. {% highlight java %} // init -context = new BlobStoreContextFactory().createContext( - "aws-s3", - accesskeyid, - secretaccesskey); +context = ContextBuilder.newBuilder("aws-s3") + .credentials(accesskeyid, secretaccesskey) + .buildView(BlobStoreContext.class); + blobStore = context.getBlobStore(); // create container @@ -291,10 +297,9 @@ Here's an example of `multipart upload` using aws-s3 provider, which [allow uplo import static org.jclouds.blobstore.options.PutOptions.Builder.multipart; // init - context = new BlobStoreContextFactory().createContext( - "aws-s3", - accesskeyid, - secretaccesskey); + context = ContextBuilder.newBuilder("aws-s3") + .credentials(accesskeyid, secretaccesskey) + .buildView(BlobStoreContext.class); AsyncBlobStore blobStore = context.getAsyncBlobStore(); // create container diff --git a/documentation/userguide/compute.markdown b/documentation/userguide/compute.markdown index 0b0d1a2..0705ce9 100644 --- a/documentation/userguide/compute.markdown +++ b/documentation/userguide/compute.markdown @@ -89,8 +89,11 @@ Here, you specify the particular service you wish to manage and get a reference {% highlight java %} -ComputeServiceContext context = - new ComputeServiceContextFactory().createContext("terremark", user, password); +ComputeServiceContext context = ContextBuilder.newBuilder("trmk-ecloud") + .credentials(user, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); ComputeService computeService = context.getComputeService(); @@ -280,12 +283,19 @@ If you'd like to have credentials persist across compute service contexts, then // set the location of the filesystem you wish to persist credentials to props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, "/var/gogrid"); -blobContext = new BlobStoreContextFactory().createContext("filesystem", "foo", "bar", ImmutableSet.of(), props); +blobContext = ContextBuilder.newBuilder("filesystem") + .credentials("foo", "bar") + .overrides(props) + .buildView(BlobStoreContext.class); credentialsMap = blobContext.createInputStreamMap("credentials"); -computeContext = new ComputeServiceContextFactory().createContext("gogrid", secret, apiKey, - ImmutableSet.of(new CredentialStoreModule(credentialsMap))); +computeContext = ContextBuilder.newBuilder("gogrid") + .credentials(apiKey, secret) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new CredentialStoreModule(credentialsMap), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); {% endhighlight %} ### Individual Node Commands Individual commands are executed against a specific node's `id` (not `providerId`!). @@ -358,8 +368,11 @@ enterprise configuration module. Here's how to configure these. {% highlight java %} Properties overrides = new Properties(); Set wiring = ImmutableSet.of(new JschSshClientModule(), new Log4JLoggingModule(), new EnterpriseConfigurationModule()); -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("terremark", user, password, - wiring, overrides); +ComputeServiceContext context = ContextBuilder.newBuilder("trmk-ecloud") + .credentials(user, password) + .modules(wiring) + .overrides(overrides) + .buildView(ComputeServiceContext.class); {% endhighlight %} For mode information, check out the [[jcloudsAPI]] wiki page. diff --git a/documentation/userguide/google-app-engine.md b/documentation/userguide/google-app-engine.md index 2cc1727..7f6b3f5 100644 --- a/documentation/userguide/google-app-engine.md +++ b/documentation/userguide/google-app-engine.md @@ -25,8 +25,14 @@ Configuration can be made via property or a typed module. Here's how you can do {% highlight java %} modules = ImmutableSet.of(new AsyncGoogleAppEngineConfigurationModule()); // note if you are using <= beta-9, providers will be ec2 and s3 -compute = new ComputeServiceContextFactory().createContext("aws-ec2", accesskey, secret, modules); -blobStore = new BlobStoreContextFactory().createContext("aws-s3", accesskey, secret, modules); +blobStoreContext = ContextBuilder.newBuilder("aws-s3") + .credentials(accesskey, secret) + .modules(modules) + .buildView(BlobStoreContext.class); +computeContext = ContextBuilder.newBuilder("aws-ec2") + .credentials(accesskey, sceret) + .modules(modules) + .buildView(ComputeServiceContext.class); {% endhighlight %} * Using property-based configuration @@ -43,8 +49,14 @@ overrides.setProperty("aws-ec2.credential","secret"); overrides.setProperty("aws-s3.identity","accessKey"); overrides.setProperty("aws-s3.credential","secret"); -compute = new ComputeServiceContextFactory().createContext("aws-ec2", overrides); -blobStore = new BlobStoreContextFactory().createContext("aws-s3", overrides); +blobStore = ContextBuilder.newBuilder("aws-s3") + .credentials(accesskey, secret) + .overrides(overrides) + .buildView(BlobStoreContext.class); +compute = ContextBuilder.newBuilder("aws-ec2") + .credentials(accesskey, sceret) + .overrides(overrides) + .buildView(ComputeServiceContext.class); {% endhighlight %} ### Usage with Clojure @@ -103,9 +115,11 @@ public class BlobStoreRegistrationListener implements ServletContextListener { properties = loadJCloudsProperties("local",servletContextEvent); } servletContextEvent.getServletContext().setAttribute("blobstore", - new BlobStoreContextFactory().createContext( - properties.getProperty("jclouds.blobstore"), properties) - ).getBlobStore(); + ContextBuilder.newBuilder(properties.getProperty("jclouds.blobstore")) + .credentials(accesskey, secret) + .overrides(properties) + .buildView(BlobStoreContext.class) + .getBlobStore(); super.contextInitialized(servletContextEvent); } @@ -187,9 +201,12 @@ overrides.setProperty(PROPERTY_TIMEOUT_NODE_RUNNING, "25000"); overrides.setProperty(PROPERTY_TIMEOUT_SCRIPT_COMPLETE, "25000"); overrides.setProperty(PROPERTY_TIMEOUT_PORT_OPEN, "25000"); -context = new ComputeServiceContextFactory() - .createContext(service, identity, credential, ImmutableSet.of( - new AsyncGoogleAppEngineConfigurationModule()), overrides); +context = ContextBuilder.newBuilder(service) + .credentials(identity, credential) + .modules(ImmutableSet.of( + new AsyncGoogleAppEngineConfigurationModule())) + .overrides(overrides) + .buildView(ComputeServiceContext.class); {% endhighlight %} ### FAQ diff --git a/documentation/userguide/terremark.md b/documentation/userguide/terremark.md index 4350a97..fc64bd2 100644 --- a/documentation/userguide/terremark.md +++ b/documentation/userguide/terremark.md @@ -352,6 +352,11 @@ in the above, there are 4 networks to choose from. Choose one and set it as the {% highlight java %} Properties overrides = new Properties(); overrides.setProperty(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, "10.1.1.160/27"); -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("trmk-ecloud",USER ,PASSWORD,ImmutableSet. of(new JschSshClientModule()), overrides); +ComputeServiceContext context = ContextBuilder.newBuilder("trmk-ecloud") + .credentials(USER, PASSWORD) + .overrides(overrides) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); {% endhighlight %} diff --git a/documentation/userguide/using-ec2.md b/documentation/userguide/using-ec2.md index 95891ed..760a306 100644 --- a/documentation/userguide/using-ec2.md +++ b/documentation/userguide/using-ec2.md @@ -67,8 +67,12 @@ Even refining lists to a set of user ids, using EC2 can be bogged down, parsing // choose only amazon images that are ebs-backed overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989;state=available;image-type=machine;root-device-type=ebs"); - context = new ComputeServiceContextFactory().createContext("aws-ec2", access, secret, - ImmutableSet. of(new SshjSshClientModule()), overrides) + context = ContextBuilder.newBuilder("aws-ec2") + .credentials(access, secret) + .overrides(overrides) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); {% endhighlight %} #### Properties to set cluster compute images @@ -100,7 +104,7 @@ Template template = context.getComputeService().templateBuilder().imageId( "ami-ccb35ea5").build(); {% endhighlight %} -#### Release 1.1.0 and above +#### Release 1.1.0 to 1.5.x {% highlight java %} Properties overrides = new Properties(); @@ -115,6 +119,25 @@ Template template = context.getComputeService().templateBuilder().imageId( "ami-ccb35ea5").build(); {% endhighlight %} +#### Release 1.6.0 and above +{% highlight java %} + Properties overrides = new Properties(); + + // set AMI queries to nothing + overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, ""); + overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); + + context = ContextBuilder.newBuilder("aws-ec2") + .credentials(accessid, secretkey) + .overrides(overrides) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); + + Template template = context.getComputeService().templateBuilder().imageId( + "ami-ccb35ea5").build(); +{% endhighlight %} + ### Private Images Amazon EC2 has the concept of private-but-shared amis - images that were bundled on another account, and not made public, but shared with a specified account. @@ -142,7 +165,7 @@ ComputeServiceContext context = new ComputeServiceContextFactory().createContext ImmutableSet. of(new JschSshClientModule()), props); {% endhighlight %} -#### Release 1.1.0 and above +#### Releases 1.1.0 through 1.5.x {% highlight java %} Properties props = new Properties(); @@ -157,6 +180,24 @@ ComputeServiceContext context = new ComputeServiceContextFactory().createContext ImmutableSet. of(new JschSshClientModule()), props); {% endhighlight %} +#### Release 1.6.0 and abovex +{% highlight java %} +Properties props = new Properties(); + +//have a myFavoriteOwner - the user ID of the owner of the image. +props.setProperty(EC2Constants.PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989,063491364108,099720109477,411009282317,"+myFavoriteOwner+";state=available;image-type=machine"); + +// or.. you can remove the owner part of the query, but this will take forever on amazon's ec2 service +props.setProperty(EC2Constants.PROPERTY_EC2_AMI_QUERY, "state=available;image-type=machine"); + + +ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2") + .credentials(access, secret) + .overrides(props) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); +{% endhighlight %} You can then create nodes using the templateBuilder.imageId() method. @@ -276,15 +317,18 @@ Properties overrides = setupProperties(); // your owner id overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "123123123213123"); -context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new JschSshClientModule(), new AbstractModule(){ +context = ContextBuilder.newBuilder("aws-ec2") + .credentials(access, secret) + .overrides(overrides) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule(), + new AbstractModule(){ @Override protected void configure() { bind(AWSEC2ReviseParsedImage.class).to(FooAWSEC2ReviseParsedImage.class); - } - - }), overrides); + }))) + .buildView(ComputeServiceContext.class); {% endhighlight %} #### Use your image version @@ -362,7 +406,9 @@ Set monitoredNodes = compute.runNodesInGroup(group, 1, o You can then use the !CloudWatchClient to get statistics on your nodes. {% highlight java %} RestContext cloudWatchContext = - new RestContextFactory().createContext("cloudwatch", accessid, secretkey); + ContextBuilder.newBuilder("cloudwatch") + .credentials(access, secret) + .build(); String region = node.getLocation().getParent().getId(); diff --git a/documentation/userguide/using-maven.md b/documentation/userguide/using-maven.md index 6275785..b356fa8 100644 --- a/documentation/userguide/using-maven.md +++ b/documentation/userguide/using-maven.md @@ -29,7 +29,9 @@ Depending on what you want to do, you may need different dependencies. This assumes you are only interested in Basic BlobStore commands, like below: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext(provider, identity, credential); +BlobStoreContext context = ContextBuilder.newBuilder(provider) + .credentials(identity, credential) + .buildView(BlobStoreContext.class); Map map = context.createInputStreamMap("adrian.home"); // do work context.close(); @@ -60,7 +62,9 @@ Noting that you could alternatively ask for all of our supported blobstores usin Then, you'd substitute the correct credentials and such here: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", accessKey, secret); +BlobStoreContext context = ContextBuilder.newBuilder("aws-s3") + .credentials(accessKey, secret) + .buildView(BlobStoreContext.class); {% endhighlight %} ### BlobStore from Google App Engine @@ -69,8 +73,11 @@ There is no change to the api, in order to switch your code to use `URLFetchServ However, you do have to configure your connection differently: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext(provider, identity, credential, - ImmutableSet.of(new AsyncGoogleAppEngineConfigurationModule())); +BlobStoreContext context = ContextBuilder.newBuilder(provider) + .credentials(identity, credential) + .modules(ImmutableSet.of( + new AsyncGoogleAppEngineConfigurationModule())) + .buildView(BlobStoreContext.class); {% endhighlight %} Here are the dependencies needed to use google's UrlFetchService:: @@ -92,8 +99,10 @@ Here are the dependencies needed to use google's UrlFetchService:: jclouds will by default use JDK logging. To switch to log4J or slf4j, you have to add a logging module to your configuration code: {% highlight java %} -BlobStoreContext context = new BlobStoreContextFactory().createContext(provider, identity, credential, - ImmutableSet.of(new Log4JLoggingModule())); +BlobStoreContext context = ContextBuilder.newBuilder(provider) + .credentials(identity, credential) + .modules(ImmutableSet.of(new Log4JLoggingModule())) + .buildView(BlobStoreContext.class); {% endhighlight %} Here are the dependencies for BlobStore and log4j logging: diff --git a/documentation/userguide/vmware-vcloud.md b/documentation/userguide/vmware-vcloud.md index 37b702f..207387b 100644 --- a/documentation/userguide/vmware-vcloud.md +++ b/documentation/userguide/vmware-vcloud.md @@ -25,15 +25,18 @@ Here are the providers of the VMware vCloud API and the level of support in jclo ## Obtaining a context to vCloud Once you have jclouds libraries loaded, the easiest way to get started is to use the -`*ComputeServiceContextFactory`. This takes your username and password and gives you a context +`*ContextBuilder`. This takes your username and password and gives you a context to either get a portable cloud computing interface (`getComputeService()` ), or the direct vCloud API ( `getProviderContext().getApi()` ). * Getting a context to connect to Terremark vCloud Express: {% highlight java %} // add the ssh module, if you are using ComputeService, otherwise leave it out -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("trmk-vcloudexpress", - user, password, ImmutableSet.of(new JshSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("trmk-vcloudexpress") + .credentials(email, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // use context to obtain vcloud objects with terremark vCloud express extensions RestContext providerContext = context.getProviderContext(); @@ -44,8 +47,11 @@ RestContext pr {% highlight java %} // add the ssh module, if you are using ComputeService, otherwise leave it out -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("trmk-ecloud", - user, password, ImmutableSet.of(new JshSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("trmk-ecloud") + .credentials(email, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); // use context to obtain vcloud objects with terremark eCloud extensions RestContext providerContext = context.getProviderContext(); @@ -56,8 +62,11 @@ RestContext providerContext {% highlight java %} // add the ssh module, if you are using ComputeService, otherwise leave it out -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("bluelock-vcdirector", - user, password, ImmutableSet.of(new JshSshClientModule())); +ComputeServiceContext context = ContextBuilder.newBuilder("bluelock-vcdirector") + .credentials(user, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); RestContext providerContext = context.getProviderContext(); @@ -68,7 +77,11 @@ RestContext providerContext = context.getProvid {% highlight java %} // add the ssh module, if you are using ComputeService, otherwise leave it out - ComputeServiceContext context = new ComputeServiceContextFactory().createContext("stratogen-vcloud-mycloud", user, password, ImmutableSet.of(new JshSshClientModule())); + ComputeServiceContext context = ContextBuilder.newBuilder("stratogen-vcloud-mycloud") + .credentials(user, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); RestContext providerContext = context.getProviderContext(); {% endhighlight %} @@ -82,8 +95,11 @@ Properties overrides = new Properties(); overrides.setProperty("vcloud.endpoint", "https://****/api"); // add the ssh module, if you are using ComputeService, otherwise leave it out -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("vcloud", user, password, - ImmutableSet.of(new Log4JLoggingModule(), new JshSshClientModule()), overrides); +ComputeServiceContext context = ContextBuilder.newBuilder("vcloud") + .credentials(user, password) + .modules(ImmutableSet. of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); RestContext providerContext = context.getProviderContext(); {% endhighlight %}