Revision 35e7942d

b/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="src" path="gen"/>
5
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
b/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>android-rackspacecloud</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.jdt.core.javabuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
	</natures>
33
</projectDescription>
b/AndroidManifest.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
      package="com.rackspacecloud.android"
4
      android:versionCode="1"
5
      android:versionName="1.0">
6
    <application android:icon="@drawable/rackspace60" android:label="@string/app_name">
7
        <activity android:name=".RackspaceCloudActivity"
8
                  android:label="@string/app_name">
9
            <intent-filter>
10
                <action android:name="android.intent.action.MAIN" />
11
                <category android:name="android.intent.category.LAUNCHER" />
12
            </intent-filter>
13
        </activity>
14

  
15
        <activity android:name=".TabViewActivity" android:label="@string/app_name">
16
            <intent-filter>
17
                <action android:name="android.intent.action.MAIN"/>
18
                <category android:name="android.intent.category.APPLICATION"/>
19
            </intent-filter>
20
        </activity>
21

  
22
        <activity android:name=".ListServersActivity" android:label="@string/app_name">
23
            <intent-filter>
24
                <action android:name="android.intent.action.MAIN"/>
25
                <category android:name="android.intent.category.APPLICATION"/>
26
            </intent-filter>
27
        </activity>
28

  
29
    </application>
30
    <uses-sdk android:minSdkVersion="4" />
31

  
32
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
33
</manifest> 
b/default.properties
1
# This file is automatically generated by Android Tools.
2
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3
# 
4
# This file must be checked in Version Control Systems.
5
# 
6
# To customize properties used by the Ant build system use,
7
# "build.properties", and override values to adapt the script to your
8
# project structure.
9

  
10
# Indicates whether an apk should be generated for each density.
11
split.density=false
12
# Project target.
13
target=android-7
b/extensions/.gitignore
1
target
2
# use glob syntax.
3
syntax: glob
4
.settings
5
.classpath
6
.project
7
jclouds-extensions-project.iml
8
jclouds-extensions-project.ipr
9
jclouds-extensions-project.iws
b/extensions/apachehc/.gitignore
1
# use glob syntax.
2
syntax: glob
3
target
4
.settings
5
.classpath
6
.project
7
jclouds-apachehc.iml
8
jclouds-apachehc.ipr
9
jclouds-apachehc.iws
b/extensions/apachehc/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3

  
4

  
5
    Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
6

  
7
    ====================================================================
8
    Licensed under the Apache License, Version 2.0 (the "License");
9
    you may not use this file except in compliance with the License.
10
    You may obtain a copy of the License at
11

  
12
    http://www.apache.org/licenses/LICENSE-2.0
13

  
14
    Unless required by applicable law or agreed to in writing, software
15
    distributed under the License is distributed on an "AS IS" BASIS,
16
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
    See the License for the specific language governing permissions and
18
    limitations under the License.
19
    ====================================================================
20

  
21
-->
22

  
23
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24
    <modelVersion>4.0.0</modelVersion>
25
    <parent>
26
        <artifactId>jclouds-extensions-project</artifactId>
27
        <groupId>org.jclouds</groupId>
28
        <version>1.0-SNAPSHOT</version>
29
    </parent>
30
    <artifactId>jclouds-apachehc</artifactId>
31
    <name>jclouds Apache Http Components Client</name>
32
    <packaging>jar</packaging>
33
    <description>Apache HttpComponents client</description>
34

  
35
    <scm>
36
        <connection>scm:svn:http://jclouds.googlecode.com/svn/trunk</connection>
37
        <developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk</developerConnection>
38
        <url>http://jclouds.googlecode.com/svn/trunk</url>
39
    </scm>
40

  
41
    <dependencies>
42
        <dependency>
43
            <groupId>org.apache.httpcomponents</groupId>
44
            <artifactId>httpclient</artifactId>
45
            <version>4.0.1</version>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.mortbay.jetty</groupId>
49
            <artifactId>jetty</artifactId>
50
            <scope>test</scope>
51
        </dependency>
52
    </dependencies>
53

  
54
</project>
b/extensions/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19

  
20
package org.jclouds.http.apachehc;
21

  
22
import java.io.IOException;
23
import java.net.URI;
24
import java.util.concurrent.ExecutorService;
25

  
26
import javax.inject.Named;
27

  
28
import org.apache.http.HttpHost;
29
import org.apache.http.client.ClientProtocolException;
30
import org.apache.http.client.HttpClient;
31
import org.apache.http.client.methods.HttpUriRequest;
32
import org.jclouds.Constants;
33
import org.jclouds.http.HttpRequest;
34
import org.jclouds.http.HttpResponse;
35
import org.jclouds.http.handlers.DelegatingErrorHandler;
36
import org.jclouds.http.handlers.DelegatingRetryHandler;
37
import org.jclouds.http.internal.BaseHttpCommandExecutorService;
38
import org.jclouds.http.internal.HttpWire;
39

  
40
import com.google.inject.Inject;
41

  
42
/**
43
 * Simple implementation of a {@link HttpFutureCommandClient}, Apache Components HttpClient 4.x.
44
 * 
45
 * @author Sam Tunnicliffe
46
 * @author Adrian Cole
47
 */
48
public class ApacheHCHttpCommandExecutorService extends
49
         BaseHttpCommandExecutorService<HttpUriRequest> {
50
   private final HttpClient client;
51

  
52
   @Inject
53
   ApacheHCHttpCommandExecutorService(
54
            @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioWorkerExecutor,
55
            DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler,
56
            HttpWire wire, HttpClient client) {
57
      super(ioWorkerExecutor, retryHandler, errorHandler, wire);
58
      this.client = client;
59
   }
60

  
61
   @Override
62
   protected HttpUriRequest convert(HttpRequest request) throws IOException {
63
      return ApacheHCUtils.convertToApacheRequest(request);
64
   }
65

  
66
   @Override
67
   protected HttpResponse invoke(HttpUriRequest nativeRequest) throws IOException {
68
      org.apache.http.HttpResponse nativeResponse = executeRequest(nativeRequest);
69
      return ApacheHCUtils.convertToJCloudsResponse(nativeResponse);
70
   }
71

  
72
   private org.apache.http.HttpResponse executeRequest(HttpUriRequest nativeRequest)
73
            throws IOException, ClientProtocolException {
74
      URI endpoint = URI.create(nativeRequest.getRequestLine().getUri());
75
      HttpHost host = new HttpHost(endpoint.getHost(), endpoint.getPort(), endpoint.getScheme());
76
      org.apache.http.HttpResponse nativeResponse = client.execute(host, nativeRequest);
77
      return nativeResponse;
78
   }
79

  
80
   @Override
81
   protected void cleanup(HttpUriRequest nativeResponse) {
82
      // No cleanup necessary
83
   }
84
}
b/extensions/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCUtils.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.http.apachehc;
20

  
21
import java.io.File;
22
import java.io.FilterInputStream;
23
import java.io.IOException;
24
import java.io.InputStream;
25
import java.io.UnsupportedEncodingException;
26

  
27
import javax.inject.Singleton;
28
import javax.ws.rs.HttpMethod;
29
import javax.ws.rs.core.HttpHeaders;
30

  
31
import org.apache.http.Header;
32
import org.apache.http.HttpEntity;
33
import org.apache.http.HttpEntityEnclosingRequest;
34
import org.apache.http.client.methods.HttpDelete;
35
import org.apache.http.client.methods.HttpGet;
36
import org.apache.http.client.methods.HttpHead;
37
import org.apache.http.client.methods.HttpPost;
38
import org.apache.http.client.methods.HttpPut;
39
import org.apache.http.client.methods.HttpUriRequest;
40
import org.apache.http.entity.ByteArrayEntity;
41
import org.apache.http.entity.FileEntity;
42
import org.apache.http.entity.InputStreamEntity;
43
import org.apache.http.entity.StringEntity;
44
import org.jclouds.http.HttpRequest;
45
import org.jclouds.http.HttpResponse;
46
import org.jclouds.http.Payload;
47

  
48
/**
49
 * 
50
 * @author Adrian Cole
51
 */
52
@Singleton
53
public class ApacheHCUtils {
54

  
55
   public static final String USER_AGENT = "jclouds/1.0 httpclient/4.0.1";
56

  
57
   public static HttpUriRequest convertToApacheRequest(HttpRequest request) {
58
      HttpUriRequest apacheRequest;
59
      if (request.getMethod().equals(HttpMethod.HEAD)) {
60
         apacheRequest = new HttpHead(request.getEndpoint());
61
      } else if (request.getMethod().equals(HttpMethod.GET)) {
62
         apacheRequest = new HttpGet(request.getEndpoint());
63
      } else if (request.getMethod().equals(HttpMethod.DELETE)) {
64
         apacheRequest = new HttpDelete(request.getEndpoint());
65
      } else if (request.getMethod().equals(HttpMethod.PUT)) {
66
         apacheRequest = new HttpPut(request.getEndpoint());
67
      } else if (request.getMethod().equals(HttpMethod.POST)) {
68
         apacheRequest = new HttpPost(request.getEndpoint());
69
      } else {
70
         throw new UnsupportedOperationException(request.getMethod());
71
      }
72
      Payload payload = request.getPayload();
73

  
74
      // Since we may remove headers, ensure they are added to the apache
75
      // request after this block
76
      if (apacheRequest instanceof HttpEntityEnclosingRequest) {
77
         if (payload != null) {
78
            String lengthString = request.getFirstHeaderOrNull(HttpHeaders.CONTENT_LENGTH);
79
            if (lengthString == null) {
80
               throw new IllegalStateException("no Content-Length header on request: "
81
                        + apacheRequest);
82
            }
83
            long contentLength = Long.parseLong(lengthString);
84
            String contentType = request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE);
85
            addEntityForContent(HttpEntityEnclosingRequest.class.cast(apacheRequest), payload
86
                     .getRawContent(), contentType, contentLength);
87
         }
88
      } else {
89
         apacheRequest.addHeader(HttpHeaders.CONTENT_LENGTH, "0");
90
      }
91

  
92
      for (String header : request.getHeaders().keySet()) {
93
         for (String value : request.getHeaders().get(header))
94
            // apache automatically tries to add content length header
95
            if (!header.equals(HttpHeaders.CONTENT_LENGTH))
96
               apacheRequest.addHeader(header, value);
97
      }
98
      apacheRequest.addHeader(HttpHeaders.USER_AGENT, USER_AGENT);
99
      return apacheRequest;
100
   }
101

  
102
   public static void addEntityForContent(HttpEntityEnclosingRequest apacheRequest, Object content,
103
            String contentType, long length) {
104
      if (content instanceof InputStream) {
105
         InputStream inputStream = (InputStream) content;
106
         if (length == -1)
107
            throw new IllegalArgumentException(
108
                     "you must specify size when content is an InputStream");
109
         InputStreamEntity Entity = new InputStreamEntity(inputStream, length);
110
         Entity.setContentType(contentType);
111
         apacheRequest.setEntity(Entity);
112
      } else if (content instanceof String) {
113
         StringEntity nStringEntity = null;
114
         try {
115
            nStringEntity = new StringEntity((String) content);
116
         } catch (UnsupportedEncodingException e) {
117
            throw new UnsupportedOperationException("Encoding not supported", e);
118
         }
119
         nStringEntity.setContentType(contentType);
120
         apacheRequest.setEntity(nStringEntity);
121
      } else if (content instanceof File) {
122
         apacheRequest.setEntity(new FileEntity((File) content, contentType));
123
      } else if (content instanceof byte[]) {
124
         ByteArrayEntity Entity = new ByteArrayEntity((byte[]) content);
125
         Entity.setContentType(contentType);
126
         apacheRequest.setEntity(Entity);
127
      } else {
128
         throw new UnsupportedOperationException("Content class not supported: "
129
                  + content.getClass().getName());
130
      }
131
      assert (apacheRequest.getEntity() != null);
132
   }
133

  
134
   public static HttpResponse convertToJCloudsResponse(org.apache.http.HttpResponse apacheResponse)
135
            throws IOException {
136

  
137
      HttpResponse response = new HttpResponse();
138
      if (apacheResponse.getEntity() != null) {
139
         // response.setContent(consumeOnClose(apacheResponse.getEntity()));
140
         response.setContent(apacheResponse.getEntity().getContent());
141
      }
142
      for (Header header : apacheResponse.getAllHeaders()) {
143
         response.getHeaders().put(header.getName(), header.getValue());
144
      }
145
      response.setStatusCode(apacheResponse.getStatusLine().getStatusCode());
146
      response.setMessage(apacheResponse.getStatusLine().getReasonPhrase());
147
      return response;
148
   }
149

  
150
   public static InputStream consumeOnClose(HttpEntity httpEntity) throws IllegalStateException,
151
            IOException {
152
      return new ConsumeOnCloseInputStream(httpEntity);
153
   }
154

  
155
   static class ConsumeOnCloseInputStream extends FilterInputStream {
156

  
157
      private final HttpEntity httpEntity;
158

  
159
      protected ConsumeOnCloseInputStream(HttpEntity httpEntity) throws IllegalStateException,
160
               IOException {
161
         super(httpEntity.getContent());
162
         this.httpEntity = httpEntity;
163
      }
164

  
165
      boolean closed;
166

  
167
      @Override
168
      public void close() throws IOException {
169
         try {
170
            if (!closed) {
171
               httpEntity.consumeContent();
172
            }
173
         } finally {
174
            closed = true;
175
            super.close();
176
         }
177
      }
178

  
179
   }
180

  
181
}
b/extensions/apachehc/src/main/java/org/jclouds/http/apachehc/config/ApacheHCHttpCommandExecutorServiceModule.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.http.apachehc.config;
20

  
21
import java.io.Closeable;
22
import java.io.IOException;
23
import java.net.ProxySelector;
24
import java.security.KeyManagementException;
25
import java.security.NoSuchAlgorithmException;
26

  
27
import javax.inject.Singleton;
28
import javax.net.ssl.SSLContext;
29

  
30
import org.apache.http.HttpVersion;
31
import org.apache.http.client.HttpClient;
32
import org.apache.http.conn.ClientConnectionManager;
33
import org.apache.http.conn.params.ConnManagerParams;
34
import org.apache.http.conn.params.ConnPerRoute;
35
import org.apache.http.conn.params.ConnPerRouteBean;
36
import org.apache.http.conn.scheme.PlainSocketFactory;
37
import org.apache.http.conn.scheme.Scheme;
38
import org.apache.http.conn.scheme.SchemeRegistry;
39
import org.apache.http.conn.ssl.SSLSocketFactory;
40
import org.apache.http.conn.ssl.X509HostnameVerifier;
41
import org.apache.http.impl.client.DefaultHttpClient;
42
import org.apache.http.impl.conn.ProxySelectorRoutePlanner;
43
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
44
import org.apache.http.params.BasicHttpParams;
45
import org.apache.http.params.CoreConnectionPNames;
46
import org.apache.http.params.CoreProtocolPNames;
47
import org.apache.http.params.HttpParams;
48
import org.apache.http.params.HttpProtocolParams;
49
import org.jclouds.http.HttpCommandExecutorService;
50
import org.jclouds.http.HttpUtils;
51
import org.jclouds.http.TransformingHttpCommandExecutorService;
52
import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl;
53
import org.jclouds.http.apachehc.ApacheHCHttpCommandExecutorService;
54
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
55
import org.jclouds.lifecycle.Closer;
56

  
57
import com.google.inject.AbstractModule;
58
import com.google.inject.Provides;
59
import com.google.inject.Scopes;
60

  
61
/**
62
 * Configures {@link ApacheHCHttpCommandExecutorService}.
63
 * 
64
 * Note that this uses threads
65
 * 
66
 * @author Sam Tunnicliffe
67
 * @author Adrian Cole
68
 */
69
@ConfiguresHttpCommandExecutorService
70
public class ApacheHCHttpCommandExecutorServiceModule extends AbstractModule {
71

  
72
   @Override
73
   protected void configure() {
74
      bindClient();
75
   }
76

  
77
   @Singleton
78
   @Provides
79
   HttpParams newBasicHttpParams(HttpUtils utils) {
80
      BasicHttpParams params = new BasicHttpParams();
81

  
82
      params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
83
               .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, true)
84
               .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(
85
                        CoreProtocolPNames.ORIGIN_SERVER, "jclouds/1.0");
86

  
87
      if (utils.getConnectionTimeout() > 0) {
88
         params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, utils
89
                  .getConnectionTimeout());
90
      }
91

  
92
      if (utils.getSocketOpenTimeout() > 0) {
93
         params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, utils.getSocketOpenTimeout());
94
      }
95

  
96
      if (utils.getMaxConnections() > 0)
97
         ConnManagerParams.setMaxTotalConnections(params, utils.getMaxConnections());
98
      
99
      if (utils.getMaxConnectionsPerHost() > 0) {
100
         ConnPerRoute connectionsPerRoute = new ConnPerRouteBean(utils.getMaxConnectionsPerHost());
101
         ConnManagerParams.setMaxConnectionsPerRoute(params, connectionsPerRoute);
102
      }
103
      HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
104
      return params;
105
   }
106

  
107
   @Singleton
108
   @Provides
109
   X509HostnameVerifier newHostnameVerifier(HttpUtils utils) {
110
      return utils.relaxHostname() ? SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
111
               : SSLSocketFactory.STRICT_HOSTNAME_VERIFIER;
112
   }
113

  
114
   @Singleton
115
   @Provides
116
   ClientConnectionManager newClientConnectionManager(HttpParams params,
117
            X509HostnameVerifier verifier, Closer closer) throws NoSuchAlgorithmException,
118
            KeyManagementException {
119

  
120
      SchemeRegistry schemeRegistry = new SchemeRegistry();
121

  
122
      Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
123
      SSLContext context = SSLContext.getInstance("TLS");
124

  
125
      context.init(null, null, null);
126
      SSLSocketFactory sf = new SSLSocketFactory(context);
127
      sf.setHostnameVerifier(verifier);
128

  
129
      Scheme https = new Scheme("https", sf, 443);
130

  
131
      SchemeRegistry sr = new SchemeRegistry();
132
      sr.register(http);
133
      sr.register(https);
134

  
135
      schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
136
      schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
137
      final ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
138
      closer.addToClose(new Closeable() {
139
         @Override
140
         public void close() throws IOException {
141
            cm.shutdown();
142
         }
143
      });
144
      return cm;
145
   }
146

  
147
   @Provides
148
   @Singleton
149
   HttpClient newDefaultHttpClient(HttpUtils utils, BasicHttpParams params,
150
            ClientConnectionManager cm) {
151
      DefaultHttpClient client = new DefaultHttpClient(cm, params);
152
      if (utils.useSystemProxies()) {
153
         ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(client
154
                  .getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault());
155
         client.setRoutePlanner(routePlanner);
156
      }
157
      return client;
158
   }
159

  
160
   protected void bindClient() {
161
      bind(HttpCommandExecutorService.class).to(ApacheHCHttpCommandExecutorService.class).in(
162
               Scopes.SINGLETON);
163

  
164
      bind(TransformingHttpCommandExecutorService.class).to(
165
               TransformingHttpCommandExecutorServiceImpl.class).in(Scopes.SINGLETON);
166
   }
167

  
168
}
b/extensions/apachehc/src/test/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorServiceTest.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.http.apachehc;
20

  
21
import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS;
22
import static org.jclouds.Constants.*;
23
import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST;
24
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
25

  
26
import java.util.Properties;
27

  
28
import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest;
29
import org.jclouds.http.apachehc.config.ApacheHCHttpCommandExecutorServiceModule;
30
import org.testng.annotations.Test;
31

  
32
import com.google.inject.Module;
33

  
34
/**
35
 * Tests the functionality of the {@link ApacheHCHttpCommandExecutorService}
36
 * 
37
 * @author Adrian Cole
38
 */
39
@Test
40
public class ApacheHCHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorServiceIntegrationTest {
41
   static {
42
      System.setProperty("http.conn-manager.timeout", 1000 + "");
43
   }
44

  
45
   protected Module createConnectionModule() {
46
      return new ApacheHCHttpCommandExecutorServiceModule();
47
   }
48

  
49
   protected void addConnectionProperties(Properties props) {
50
      props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + "");
51
      props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + "");
52
      props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 100 + "");
53
      props.setProperty(PROPERTY_SO_TIMEOUT, 100 + "");
54
      props.setProperty(PROPERTY_IO_WORKER_THREADS, 3 + "");
55
      props.setProperty(PROPERTY_USER_THREADS, 0 + "");
56
   }
57

  
58
}
b/extensions/bouncycastle/.gitignore
1
# use glob syntax.
2
syntax: glob
3
target
4
.settings
5
.classpath
6
.project
7
jclouds-bouncycastle.iml
8
jclouds-bouncycastle.ipr
9
jclouds-bouncycastle.iws
b/extensions/bouncycastle/README.txt
1
====
2

  
3
    Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4

  
5
    ====================================================================
6
    Licensed under the Apache License, Version 2.0 (the "License");
7
    you may not use this file except in compliance with the License.
8
    You may obtain a copy of the License at
9

  
10
    http://www.apache.org/licenses/LICENSE-2.0
11

  
12
    Unless required by applicable law or agreed to in writing, software
13
    distributed under the License is distributed on an "AS IS" BASIS,
14
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
    See the License for the specific language governing permissions and
16
    limitations under the License.
17
    ====================================================================
18
====
19
#
20
# An extension to use the Bouncy Castle Crypto API (http://www.bouncycastle.org/) 
21
# as an encryption library in jclouds.
22
#
23
# TODO: Usage example.
b/extensions/bouncycastle/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3

  
4

  
5
    Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
6

  
7
    ====================================================================
8
    Licensed under the Apache License, Version 2.0 (the "License");
9
    you may not use this file except in compliance with the License.
10
    You may obtain a copy of the License at
11

  
12
    http://www.apache.org/licenses/LICENSE-2.0
13

  
14
    Unless required by applicable law or agreed to in writing, software
15
    distributed under the License is distributed on an "AS IS" BASIS,
16
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
    See the License for the specific language governing permissions and
18
    limitations under the License.
19
    ====================================================================
20

  
21
-->
22

  
23
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24
    <modelVersion>4.0.0</modelVersion>
25
    <parent>
26
        <groupId>org.jclouds</groupId>
27
        <artifactId>jclouds-extensions-project</artifactId>
28
        <version>1.0-SNAPSHOT</version>
29
    </parent>
30
    <artifactId>jclouds-bouncycastle</artifactId>
31
    <name>jclouds bouncycastle EncryptionService Module</name>
32
    <description>jclouds bouncycastle EncryptionService Module</description>
33

  
34
    <dependencies>
35
        <dependency>
36
            <groupId>org.bouncycastle</groupId>
37
            <artifactId>bcprov-jdk15</artifactId>
38
            <version>1.44</version>
39
        </dependency>
40
    </dependencies>
41
    
42
</project>
b/extensions/bouncycastle/src/main/java/org/jclouds/encryption/bouncycastle/BouncyCastleEncryptionService.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.encryption.bouncycastle;
20

  
21
import java.io.ByteArrayOutputStream;
22
import java.io.IOException;
23
import java.io.InputStream;
24
import java.io.OutputStream;
25
import java.security.InvalidKeyException;
26
import java.security.NoSuchAlgorithmException;
27
import java.security.NoSuchProviderException;
28

  
29
import javax.inject.Singleton;
30

  
31
import org.bouncycastle.crypto.Digest;
32
import org.bouncycastle.crypto.digests.MD5Digest;
33
import org.bouncycastle.crypto.digests.SHA1Digest;
34
import org.bouncycastle.crypto.digests.SHA256Digest;
35
import org.bouncycastle.crypto.io.DigestOutputStream;
36
import org.bouncycastle.crypto.macs.HMac;
37
import org.bouncycastle.crypto.params.KeyParameter;
38
import org.bouncycastle.util.encoders.Base64;
39
import org.jclouds.encryption.internal.BaseEncryptionService;
40
import org.jclouds.util.Utils;
41

  
42
import com.google.common.io.Closeables;
43

  
44
/**
45
 * 
46
 * @author Adrian Cole
47
 */
48
@Singleton
49
public class BouncyCastleEncryptionService extends BaseEncryptionService {
50
   public String hmacSha256Base64(String toEncode, byte[] key) throws NoSuchAlgorithmException,
51
            NoSuchProviderException, InvalidKeyException {
52
      Digest digest = new SHA256Digest();
53
      return hmacBase64(toEncode, key, digest);
54
   }
55

  
56
   private String hmacBase64(String toEncode, byte[] key, Digest digest) {
57
      byte[] resBuf = hmac(toEncode, key, digest);
58
      return toBase64String(resBuf);
59
   }
60

  
61
   public byte[] hmac(String toEncode, byte[] key, Digest digest) {
62
      HMac hmac = new HMac(digest);
63
      byte[] resBuf = new byte[hmac.getMacSize()];
64
      byte[] plainBytes = Utils.encodeString(toEncode);
65
      byte[] keyBytes = key;
66
      hmac.init(new KeyParameter(keyBytes));
67
      hmac.update(plainBytes, 0, plainBytes.length);
68
      hmac.doFinal(resBuf, 0);
69
      return resBuf;
70
   }
71

  
72
   public String hmacSha1Base64(String toEncode, byte[] key) throws NoSuchAlgorithmException,
73
            NoSuchProviderException, InvalidKeyException {
74
      Digest digest = new SHA1Digest();
75
      return hmacBase64(toEncode, key, digest);
76
   }
77

  
78
   public byte[] md5(byte[] plainBytes) {
79
      MD5Digest eTag = new MD5Digest();
80
      byte[] resBuf = new byte[eTag.getDigestSize()];
81
      eTag.update(plainBytes, 0, plainBytes.length);
82
      eTag.doFinal(resBuf, 0);
83
      return resBuf;
84
   }
85

  
86
   public byte[] md5(InputStream toEncode) {
87
      MD5Digest eTag = new MD5Digest();
88
      byte[] resBuf = new byte[eTag.getDigestSize()];
89
      byte[] buffer = new byte[1024];
90
      int numRead = -1;
91
      try {
92
         do {
93
            numRead = toEncode.read(buffer);
94
            if (numRead > 0) {
95
               eTag.update(buffer, 0, numRead);
96
            }
97
         } while (numRead != -1);
98
      } catch (IOException e) {
99
         throw new RuntimeException(e);
100
      } finally {
101
         Closeables.closeQuietly(toEncode);
102
      }
103
      eTag.doFinal(resBuf, 0);
104
      return resBuf;
105
   }
106

  
107
   public String toBase64String(byte[] resBuf) {
108
      return new String(Base64.encode(resBuf));
109
   }
110

  
111
   public MD5InputStreamResult generateMD5Result(InputStream toEncode) {
112
      MD5Digest eTag = new MD5Digest();
113
      byte[] resBuf = new byte[eTag.getDigestSize()];
114
      byte[] buffer = new byte[1024];
115
      ByteArrayOutputStream out = new ByteArrayOutputStream();
116
      long length = 0;
117
      int numRead = -1;
118
      try {
119
         do {
120
            numRead = toEncode.read(buffer);
121
            if (numRead > 0) {
122
               length += numRead;
123
               eTag.update(buffer, 0, numRead);
124
               out.write(buffer, 0, numRead);
125
            }
126
         } while (numRead != -1);
127
      } catch (IOException e) {
128
         throw new RuntimeException(e);
129
      } finally {
130
         Closeables.closeQuietly(out);
131
         Closeables.closeQuietly(toEncode);
132
      }
133
      eTag.doFinal(resBuf, 0);
134
      return new MD5InputStreamResult(out.toByteArray(), resBuf, length);
135
   }
136

  
137
   public byte[] fromBase64String(String encoded) {
138
      return Base64.decode(encoded);
139
   }
140

  
141
   @Override
142
   public MD5OutputStream md5OutputStream(OutputStream out) {
143
      return new BouncyCastleMD5OutputStream(out);
144
   }
145

  
146
   public static class BouncyCastleMD5OutputStream extends MD5OutputStream {
147
      public BouncyCastleMD5OutputStream(OutputStream out) {
148
         super(new DigestOutputStream(out, new MD5Digest()));
149
      }
150

  
151
      @Override
152
      public byte[] getMD5() {
153
         MD5Digest digest = (MD5Digest) ((DigestOutputStream) out).getDigest();
154
         byte[] resBuf = new byte[digest.getDigestSize()];
155
         digest.doFinal(resBuf, 0);
156
         return resBuf;
157
      }
158
   }
159
}
b/extensions/bouncycastle/src/main/java/org/jclouds/encryption/bouncycastle/config/BouncyCastleEncryptionServiceModule.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.encryption.bouncycastle.config;
20

  
21
import org.jclouds.encryption.EncryptionService;
22
import org.jclouds.encryption.bouncycastle.BouncyCastleEncryptionService;
23

  
24
import com.google.inject.AbstractModule;
25

  
26
/**
27
 * Configures EncryptionService of type {@link BouncyCastleEncryptionService}
28
 * 
29
 * @author Adrian Cole
30
 * 
31
 */
32
public class BouncyCastleEncryptionServiceModule extends AbstractModule {
33

  
34
   @Override
35
   protected void configure() {
36
      bind(EncryptionService.class).to(BouncyCastleEncryptionService.class);
37
   }
38

  
39
}
b/extensions/bouncycastle/src/test/java/org/jclouds/encryption/bouncycastle/BouncyCastleEncryptionServiceTest.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.encryption.bouncycastle;
20

  
21
import org.jclouds.encryption.EncryptionService;
22
import org.jclouds.encryption.EncryptionServiceTest;
23
import org.jclouds.encryption.bouncycastle.config.BouncyCastleEncryptionServiceModule;
24
import org.testng.annotations.BeforeTest;
25
import org.testng.annotations.Test;
26

  
27
import com.google.inject.Guice;
28
import com.google.inject.Injector;
29

  
30
/**
31
 * This tests the performance of Digest commands.
32
 * 
33
 * @author Adrian Cole
34
 */
35
@Test(groups = "performance", sequential = true, testName = "jclouds.BouncyCastleEncryptionServiceTest")
36
public class BouncyCastleEncryptionServiceTest extends EncryptionServiceTest {
37

  
38
   @BeforeTest
39
   protected void createEncryptionService() {
40
      Injector i = Guice.createInjector(new BouncyCastleEncryptionServiceModule());
41
      encryptionService = i.getInstance(EncryptionService.class);
42
      assert encryptionService instanceof BouncyCastleEncryptionService;
43
   }
44
}
b/extensions/enterprise/.gitignore
1
# use glob syntax.
2
syntax: glob
3
target
4
.settings
5
.classpath
6
.project
7
jclouds-enterprise.iml
8
jclouds-enterprise.ipr
9
jclouds-enterprise.iws
b/extensions/enterprise/README.txt
1
====
2

  
3
    Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4

  
5
    ====================================================================
6
    Licensed under the Apache License, Version 2.0 (the "License");
7
    you may not use this file except in compliance with the License.
8
    You may obtain a copy of the License at
9

  
10
    http://www.apache.org/licenses/LICENSE-2.0
11

  
12
    Unless required by applicable law or agreed to in writing, software
13
    distributed under the License is distributed on an "AS IS" BASIS,
14
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
    See the License for the specific language governing permissions and
16
    limitations under the License.
17
    ====================================================================
18
====
19
#
20
# Sets up most commonly requested options for enterprise java support
21
#
22
# TODO: Usage example.
b/extensions/enterprise/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3

  
4

  
5
    Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
6

  
7
    ====================================================================
8
    Licensed under the Apache License, Version 2.0 (the "License");
9
    you may not use this file except in compliance with the License.
10
    You may obtain a copy of the License at
11

  
12
    http://www.apache.org/licenses/LICENSE-2.0
13

  
14
    Unless required by applicable law or agreed to in writing, software
15
    distributed under the License is distributed on an "AS IS" BASIS,
16
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
    See the License for the specific language governing permissions and
18
    limitations under the License.
19
    ====================================================================
20

  
21
-->
22

  
23
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24
    <modelVersion>4.0.0</modelVersion>
25
    <parent>
26
        <groupId>org.jclouds</groupId>
27
        <artifactId>jclouds-extensions-project</artifactId>
28
        <version>1.0-SNAPSHOT</version>
29
    </parent>
30
    <artifactId>jclouds-enterprise</artifactId>
31
    <name>jclouds enterprise Module</name>
32
    <description>jclouds enterprise configuration</description>
33

  
34
    <dependencies>
35
        <dependency>
36
            <groupId>${project.groupId}</groupId>
37
            <artifactId>jclouds-joda</artifactId>
38
            <version>${project.version}</version>
39
        </dependency>
40
        <dependency>
41
            <groupId>${project.groupId}</groupId> 
42
            <artifactId>jclouds-bouncycastle</artifactId>
43
            <version>${project.version}</version>
44
        </dependency>
45
        <dependency>
46
            <groupId>org.mortbay.jetty</groupId>
47
            <artifactId>jetty</artifactId>
48
            <scope>test</scope>
49
        </dependency>
50
    </dependencies>
51
    
52
    <build>
53
        <finalName>${project.artifactId}</finalName>
54
        <plugins>
55
            <plugin>
56
                <artifactId>maven-assembly-plugin</artifactId>
57
                <executions>
58
                    <execution>
59
                        <phase>package</phase>
60
                        <goals>
61
                            <goal>single</goal>
62
                        </goals>
63
                        <configuration>
64
                            <descriptorRefs>
65
                                <descriptorRef>jar-with-dependencies</descriptorRef>
66
                            </descriptorRefs>
67
                        </configuration>
68
                    </execution>
69
                </executions>
70
            </plugin>
71
        </plugins>
72
    </build>
73

  
74
</project>
b/extensions/enterprise/src/main/java/org/jclouds/enterprise/config/EnterpriseConfigurationModule.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.enterprise.config;
20

  
21
import java.util.concurrent.ExecutorService;
22

  
23
import org.jclouds.concurrent.config.ConfiguresExecutorService;
24
import org.jclouds.concurrent.config.ExecutorServiceModule;
25
import org.jclouds.date.joda.config.JodaDateServiceModule;
26
import org.jclouds.encryption.bouncycastle.config.BouncyCastleEncryptionServiceModule;
27

  
28
/**
29
 * Configures Enterprise-grade components
30
 * 
31
 * @author Adrian Cole
32
 * 
33
 */
34
@ConfiguresExecutorService
35
public class EnterpriseConfigurationModule extends ExecutorServiceModule {
36

  
37
   public EnterpriseConfigurationModule(ExecutorService userThreads, ExecutorService ioThreads) {
38
      super(userThreads, ioThreads);
39
   }
40

  
41
   public EnterpriseConfigurationModule() {
42
      super();
43
   }
44

  
45
   @Override
46
   protected void configure() {
47
      install(new BouncyCastleEncryptionServiceModule());
48
      install(new JodaDateServiceModule());
49
   }
50

  
51
}
b/extensions/enterprise/src/test/java/org/jclouds/enterprise/config/EnterpriseConfigurationModuleTest.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.enterprise.config;
20

  
21
import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS;
22
import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT;
23
import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST;
24
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
25

  
26
import java.util.Properties;
27

  
28
import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest;
29
import org.testng.annotations.Test;
30

  
31
import com.google.inject.Module;
32

  
33
/**
34
 * Tests the functionality of the {@link EnterpriseConfigurationModule}
35
 * 
36
 * @author Adrian Cole
37
 */
38
@Test
39
public class EnterpriseConfigurationModuleTest extends BaseHttpCommandExecutorServiceIntegrationTest {
40

  
41
   protected Module createConnectionModule() {
42
      return new EnterpriseConfigurationModule();
43
   }
44

  
45
   protected void addConnectionProperties(Properties props) {
46
      props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 50 + "");
47
      props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 50 + "");
48
      // IO workers not used in this executor
49
      props.setProperty(PROPERTY_IO_WORKER_THREADS, 0 + "");
50
      props.setProperty(PROPERTY_USER_THREADS, 5 + "");
51
   }
52

  
53
}
b/extensions/gae/.gitignore
1
# use glob syntax.
2
syntax: glob
3
target
4
.settings
5
.classpath
6
.project
7
jclouds-gae.iml
8
jclouds-gae.ipr
9
jclouds-gae.iws
b/extensions/gae/README.txt
1
====
2

  
3
    Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4

  
5
    ====================================================================
6
    Licensed under the Apache License, Version 2.0 (the "License");
7
    you may not use this file except in compliance with the License.
8
    You may obtain a copy of the License at
9

  
10
    http://www.apache.org/licenses/LICENSE-2.0
11

  
12
    Unless required by applicable law or agreed to in writing, software
13
    distributed under the License is distributed on an "AS IS" BASIS,
14
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
    See the License for the specific language governing permissions and
16
    limitations under the License.
17
    ====================================================================
18
====
19
#
20
# An extension to run jclouds on Google App Engine (http://code.google.com/appengine/).
21
#
22
# TODO: Usage example.
b/extensions/gae/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
    <!--
3

  
4

  
5
        Copyright (C) 2009 Cloud Conscious, LLC.
6
        <info@cloudconscious.com>
7

  
8
        ====================================================================
9
        Licensed under the Apache License, Version 2.0 (the "License");
10
        you may not use this file except in compliance with the License.
11
        You may obtain a copy of the License at
12

  
13
        http://www.apache.org/licenses/LICENSE-2.0 Unless required by
14
        applicable law or agreed to in writing, software distributed
15
        under the License is distributed on an "AS IS" BASIS, WITHOUT
16
        WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
        See the License for the specific language governing permissions
18
        and limitations under the License.
19
        ====================================================================
20
    -->
21

  
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24
    <modelVersion>4.0.0</modelVersion>
25
    <parent>
26
        <groupId>org.jclouds</groupId>
27
        <artifactId>jclouds-extensions-project</artifactId>
28
        <version>1.0-SNAPSHOT</version>
29
    </parent>
30
    <groupId>org.jclouds</groupId>
31
    <artifactId>jclouds-gae</artifactId>
32
    <name>jclouds Google App Engine Components</name>
33
    <description>Google App Engine Components</description>
34

  
35
    <scm>
36
        <connection>scm:svn:http://jclouds.googlecode.com/svn/trunk</connection>
37
        <developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk</developerConnection>
38
        <url>http://jclouds.googlecode.com/svn/trunk</url>
39
    </scm>
40

  
41
    <dependencies>
42
        <dependency>
43
            <groupId>${project.groupId}</groupId>
44
            <artifactId>jclouds-joda</artifactId>
45
            <version>${project.version}</version>
46
        </dependency>
47
        <dependency>
48
            <groupId>${project.groupId}</groupId> 
49
            <artifactId>jclouds-bouncycastle</artifactId>
50
            <version>${project.version}</version>
51
        </dependency>
52
        <dependency>
53
            <groupId>com.google.appengine</groupId>
54
            <artifactId>appengine-api</artifactId>
55
            <version>1.3.0</version>
56
        </dependency>
57
        <dependency>
58
            <groupId>com.google.appengine</groupId>
59
            <artifactId>appengine-api-stubs</artifactId>
60
            <version>1.3.0</version>
61
            <scope>test</scope>
62
        </dependency>
63
        <dependency>
64
            <groupId>com.google.appengine</groupId>
65
            <artifactId>appengine-local-runtime</artifactId>
66
            <version>1.3.0</version>
67
            <scope>test</scope>
68
        </dependency>
69
        <dependency>
70
            <groupId>${project.groupId}</groupId>
71
            <artifactId>jclouds-core</artifactId>
72
            <version>${project.version}</version>
73
            <type>test-jar</type>
74
            <scope>test</scope>
75
            <!--
76
                <exclusions> <exclusion>
77
                <groupId>org.mortbay.jetty</groupId>
78
                <artifactId>jetty</artifactId> </exclusion>
79
                </exclusions>
80
            -->
81
        </dependency>
82
        <dependency>
83
            <groupId>org.apache.geronimo.specs</groupId>
84
            <artifactId>geronimo-servlet_2.5_spec</artifactId>
85
            <version>1.2</version>
86
            <scope>test</scope>
87
        </dependency>
88
    </dependencies>
89

  
90
</project>
b/extensions/gae/src/main/java/org/jclouds/gae/GaeHttpCommandExecutorService.java
1
/**
2
 *
3
 * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
4
 *
5
 * ====================================================================
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 * ====================================================================
18
 */
19
package org.jclouds.gae;
20

  
21
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.disallowTruncate;
22

  
23
import java.io.ByteArrayInputStream;
24
import java.io.IOException;
25
import java.io.InputStream;
26
import java.net.URL;
27
import java.util.concurrent.ExecutorService;
28

  
29
import javax.inject.Inject;
30
import javax.inject.Named;
31
import javax.inject.Singleton;
32
import javax.ws.rs.core.HttpHeaders;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff