diff --git a/aws/s3/samples/googleappengine/README.txt b/aws/s3/samples/googleappengine/README.txt
index d3734b58f4..bb31761a5e 100644
--- a/aws/s3/samples/googleappengine/README.txt
+++ b/aws/s3/samples/googleappengine/README.txt
@@ -21,7 +21,7 @@
under the License.
====================================================================
====
-This samples uses the Google App Engine for Java SDK located at http://googleappengine.googlecode.com/files/appengine-java-sdk-1.2.1.zip
+This samples uses the Google App Engine for Java SDK located at http://googleappengine.googlecode.com/files/appengine-java-sdk-1.2.5.zip
Please unzip the above file and modify your maven settings.xml like below before attempting to run 'mvn -Plive install'
@@ -31,7 +31,7 @@ Please unzip the above file and modify your maven settings.xml like below before
true
- /path/to/appengine-java-sdk-1.2.1
+ /path/to/appengine-java-sdk-1.2.5
diff --git a/aws/s3/samples/googleappengine/pom.xml b/aws/s3/samples/googleappengine/pom.xml
index d882bd10af..db32569b49 100644
--- a/aws/s3/samples/googleappengine/pom.xml
+++ b/aws/s3/samples/googleappengine/pom.xml
@@ -46,6 +46,16 @@
+
+ ${project.groupId}
+ jclouds-azureblob
+ ${project.version}
+
+
+ ${project.groupId}
+ jclouds-cloudfiles
+ ${project.version}
+
${project.groupId}
jclouds-gae
@@ -161,7 +171,7 @@
${appengine.home}/lib/appengine-tools-api.jar
-
+
true
@@ -194,11 +204,27 @@
- jclouds.test.user
+ jclouds.azure.storage.account
+ ${jclouds.azure.storage.account}
+
+
+ jclouds.azure.storage.key
+ ${jclouds.azure.storage.key}
+
+
+ jclouds.rackspace.user
+ ${jclouds.rackspace.user}
+
+
+ jclouds.rackspace.key
+ ${jclouds.rackspace.key}
+
+
+ jclouds.aws.accesskeyid
${jclouds.aws.accesskeyid}
- jclouds.test.key
+ jclouds.aws.secretaccesskey
${jclouds.aws.secretaccesskey}
diff --git a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllContainersController.java
old mode 100644
new mode 100755
similarity index 58%
rename from aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java
rename to aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllContainersController.java
index 869ffc7e1f..fcab7f0fcc
--- a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java
+++ b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllContainersController.java
@@ -24,14 +24,12 @@
package org.jclouds.samples.googleappengine;
import java.io.IOException;
-import java.util.SortedSet;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Provider;
import javax.inject.Singleton;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -39,59 +37,52 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.jclouds.aws.s3.S3Client;
-import org.jclouds.aws.s3.domain.BucketMetadata;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.logging.Logger;
-import org.jclouds.samples.googleappengine.domain.BucketResult;
-import org.jclouds.samples.googleappengine.functions.MetadataToBucketResult;
+import org.jclouds.samples.googleappengine.functions.BlobStoreContextToContainerResult;
-import com.google.appengine.repackaged.com.google.common.collect.Sets;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
/**
- * Shows an example of how to use @{link S3Client} injected with Guice.
+ * Shows an example of how to use @{link BlobStoreContext} injected with Guice.
*
* @author Adrian Cole
*/
@Singleton
-public class GetAllBucketsController extends HttpServlet {
+public class GetAllContainersController extends HttpServlet {
private static final long serialVersionUID = 1L;
- private final BlobStoreContext context;
- private final Provider metadataToBucketResultProvider;
+ private Map> contexts;
+ private final BlobStoreContextToContainerResult blobStoreContextToContainerResult;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public GetAllBucketsController(BlobStoreContext context,
- Provider metadataToBucketResultProvider) {
- this.context = context;
- this.metadataToBucketResultProvider = metadataToBucketResultProvider;
+ public GetAllContainersController(Map> contexts,
+ BlobStoreContextToContainerResult blobStoreContextToContainerResult) {
+ this.contexts = contexts;
+ this.blobStoreContextToContainerResult = blobStoreContextToContainerResult;
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
- addMyBucketsToRequest(request);
+ addMyContainersToRequest(request);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(
- "/WEB-INF/jsp/buckets.jsp");
+ "/WEB-INF/jsp/containers.jsp");
dispatcher.forward(request, response);
} catch (Exception e) {
- logger.error(e, "Error listing buckets");
+ logger.error(e, "Error listing containers");
throw new ServletException(e);
}
}
- private void addMyBucketsToRequest(HttpServletRequest request) throws InterruptedException,
+ private void addMyContainersToRequest(HttpServletRequest request) throws InterruptedException,
ExecutionException, TimeoutException {
- System.err.println(context.getAccount() + ":" + context.getEndPoint());
- SortedSet myBucketMetadata = context.getApi().listOwnedBuckets().get(10,
- TimeUnit.SECONDS);
- SortedSet myBuckets = Sets.newTreeSet(Iterables.transform(myBucketMetadata,
- metadataToBucketResultProvider.get()));
- request.setAttribute("buckets", myBuckets);
+ request.setAttribute("containers", Sets.newTreeSet(Iterables.transform(contexts.keySet(),
+ blobStoreContextToContainerResult)));
}
}
\ No newline at end of file
diff --git a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java
deleted file mode 100644
index 7e2ef902eb..0000000000
--- a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Cloud Conscious, LLC.
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- */
-package org.jclouds.samples.googleappengine;
-
-import java.io.IOException;
-import java.util.SortedSet;
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jclouds.aws.s3.S3Client;
-import org.jclouds.aws.s3.domain.BucketMetadata;
-import org.jclouds.aws.s3.domain.ListBucketResponse;
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.blobstore.ContainerNotFoundException;
-import org.jclouds.logging.Logger;
-
-import com.google.common.collect.Sets;
-
-/**
- * Shows an example of how to use @{link S3Client} injected with Guice.
- *
- * @author Adrian Cole
- */
-@Singleton
-public class JCloudsServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
-
- private final static String className;
-
- /**
- * Tests google's behaviour in static context
- */
- static {
- StackTraceElement[] sTrace = new Exception().getStackTrace();
- // sTrace[0] will be always there
- className = sTrace[0].getClassName();
- }
-
- @Inject
- BlobStoreContext context;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- public static class BucketResult implements Comparable {
- private String name;
- private String size = "unknown";
- private String status = "ok";
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setSize(String size) {
- this.size = size;
- }
-
- public String getSize() {
- return size;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getStatus() {
- return status;
- }
-
- public int compareTo(BucketResult o) {
- return (this == o) ? 0 : getName().compareTo(o.getName());
- }
- }
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- try {
- SortedSet myBucketMetadata = context.getApi().listOwnedBuckets().get(10,
- TimeUnit.SECONDS);
- SortedSet myBuckets = Sets.newTreeSet();
- for (BucketMetadata metadata : myBucketMetadata) {
- BucketResult result = new BucketResult();
- result.setName(metadata.getName());
- try {
- try {
- ListBucketResponse bucket = context.getApi().listBucket(metadata.getName()).get(
- 10, TimeUnit.SECONDS);
- result.setSize(bucket.size() + "");
- } catch (ContainerNotFoundException ex) {
- result.setStatus("not found");
- }
- } catch (Exception e) {
- logger.error(e, "Error listing bucket %1$s", result.getName());
- result.setStatus(e.getMessage());
- }
- myBuckets.add(result);
- }
- request.setAttribute("buckets", myBuckets);
- request.setAttribute("className", className);
- String nextJSP = "/WEB-INF/jsp/buckets.jsp";
- RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
- dispatcher.forward(request, response);
- } catch (Exception e) {
- logger.error(e, "Error listing buckets");
- throw new ServletException(e);
- }
- }
-}
\ No newline at end of file
diff --git a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java
index e1d02bed70..a347a42ab3 100644
--- a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java
+++ b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java
@@ -23,23 +23,28 @@
*/
package org.jclouds.samples.googleappengine.config;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.util.Map;
import java.util.Properties;
-import javax.inject.Inject;
import javax.servlet.ServletContextEvent;
import org.apache.commons.io.IOUtils;
-import org.jclouds.aws.s3.S3Client;
-import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder;
-import org.jclouds.aws.s3.blobstore.S3BlobStorePropertiesBuilder;
-import org.jclouds.aws.s3.reference.S3Constants;
import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.BlobStoreContextBuilder;
+import org.jclouds.blobstore.reference.BlobStoreConstants;
import org.jclouds.gae.config.GaeHttpCommandExecutorServiceModule;
-import org.jclouds.samples.googleappengine.GetAllBucketsController;
+import org.jclouds.samples.googleappengine.GetAllContainersController;
+import com.google.appengine.repackaged.com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+import com.google.inject.Guice;
import com.google.inject.Injector;
+import com.google.inject.TypeLiteral;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
@@ -49,16 +54,30 @@ import com.google.inject.servlet.ServletModule;
* @author Adrian Cole
*/
public class GuiceServletConfig extends GuiceServletContextListener {
- @Inject
- BlobStoreContext context;
- String accessKeyId;
- String secretAccessKey;
+ private Map> contexts;
+
+ @SuppressWarnings("unchecked")
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
Properties props = loadJCloudsProperties(servletContextEvent);
- this.accessKeyId = props.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
- this.secretAccessKey = props.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
+ ImmutableList list = ImmutableList. of(checkNotNull(
+ props.getProperty(BlobStoreConstants.PROPERTY_BLOBSTORE_CONTEXTBUILDERS),
+ BlobStoreConstants.PROPERTY_BLOBSTORE_CONTEXTBUILDERS).split(","));
+ contexts = Maps.newHashMap();
+ for (String className : list) {
+ try {
+ Class> builderClass;
+ builderClass = (Class>) Class.forName(className);
+ String name = builderClass.getSimpleName().replaceAll("BlobStoreContextBuilder", "");
+ Constructor> constructor = builderClass
+ .getConstructor(Properties.class);
+ contexts.put(name, constructor.newInstance(props).withModules(
+ new GaeHttpCommandExecutorServiceModule()).buildContext());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
super.contextInitialized(servletContextEvent);
}
@@ -78,20 +97,24 @@ public class GuiceServletConfig extends GuiceServletContextListener {
@Override
protected Injector getInjector() {
- return new S3BlobStoreContextBuilder(new S3BlobStorePropertiesBuilder(accessKeyId,
- secretAccessKey).build()).withModules(new GaeHttpCommandExecutorServiceModule(),
- new ServletModule() {
- @Override
- protected void configureServlets() {
- serve("*.s3").with(GetAllBucketsController.class);
- requestInjection(this);
- }
- }).buildInjector();
+ return Guice.createInjector(new ServletModule() {
+ @Override
+ protected void configureServlets() {
+ bind(new TypeLiteral