summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-12-08 23:45:29 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-12-08 23:45:29 +0000
commitad5fdef89966e011f61503244831225c0b9bdb6f (patch)
tree33bf75a188df478ddac1c77690dbc27d50f14b20 /sca-java-2.x/trunk
parent92af2b263ee06d75adad9256ec9d22cdf751efb9 (diff)
Move HttpClientFactory from common-http to host-http
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043774 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF3
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java15
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java2
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF7
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java37
-rw-r--r--sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF15
-rw-r--r--sca-java-2.x/trunk/modules/common-http/pom.xml8
-rw-r--r--sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF20
-rw-r--r--sca-java-2.x/trunk/modules/host-http/pom.xml7
-rw-r--r--sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java (renamed from sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java)2
10 files changed, 44 insertions, 72 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF
index 62bc96dd98..b077100048 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF
@@ -25,16 +25,17 @@ Import-Package: javax.servlet,
org.apache.http.client,
org.apache.http.client.entity,
org.apache.http.client.methods,
+ org.apache.http.conn,
org.apache.http.entity,
org.apache.http.message,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.binding.atom;version="2.0.0",
org.apache.tuscany.sca.common.http;version="2.0.0",
- org.apache.tuscany.sca.common.http.client;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.data.collection;version="2.0.0",
org.apache.tuscany.sca.databinding;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.host.http.client;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
index 3612442e90..9f4ea496c1 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
@@ -22,8 +22,8 @@ package org.apache.tuscany.sca.binding.atom.provider;
import org.apache.http.client.HttpClient;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.binding.atom.AtomBinding;
-import org.apache.tuscany.sca.common.http.client.HttpClientFactory;
import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.client.HttpClientFactory;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -69,9 +69,6 @@ class AtomReferenceBindingProvider implements ReferenceBindingProvider {
//String authorization = "admin" + ":" + "admin";
//authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
- // Create an HTTP client
- HttpClientFactory clientFactory = new HttpClientFactory();
- httpClient = clientFactory.createHttpClient();
}
public Invoker createInvoker(Operation operation) {
@@ -123,13 +120,15 @@ class AtomReferenceBindingProvider implements ReferenceBindingProvider {
//httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials);
// Find the get operation on the reference interface
- if (true) {
- return;
- }
+ // Create an HTTP client
+ HttpClientFactory clientFactory = new HttpClientFactory();
+ httpClient = clientFactory.createHttpClient();
}
public void stop() {
-
+ if (httpClient != null) {
+ httpClient.getConnectionManager().shutdown();
+ }
}
public boolean supportsOneWayInvocation() {
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
index 57eacab0e2..f3cb052e39 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
@@ -37,7 +37,7 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.FileEntity;
-import org.apache.tuscany.sca.common.http.client.HttpClientFactory;
+import org.apache.tuscany.sca.host.http.client.HttpClientFactory;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.ContributionLocationHelper;
import org.apache.tuscany.sca.node.Node;
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
index 0a40a2295a..cb951b84a2 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
@@ -9,17 +9,11 @@ Bundle-Description: Apache Tuscany SCA JSON-RPC Binding Runtime
Import-Package: javax.security.auth.login,
javax.servlet,
javax.servlet.http,
- org.apache.http.conn.ssl,
org.apache.http,
org.apache.http.client,
org.apache.http.client.methods,
org.apache.http.conn,
- org.apache.http.conn.scheme,
org.apache.http.entity,
- org.apache.http.impl.client,
- org.apache.http.impl.conn.tsccm,
- org.apache.http.params,
- org.apache.http.protocol,
org.apache.http.util,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.binding.jsonrpc;version="2.0.0",
@@ -27,6 +21,7 @@ Import-Package: javax.security.auth.login,
org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
org.apache.tuscany.sca.databinding.json;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.host.http.client;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java
index e04065eed2..d0b24a0253 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java
@@ -19,21 +19,9 @@
package org.apache.tuscany.sca.binding.jsonrpc.provider;
-import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.HTTP;
import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.host.http.client.HttpClientFactory;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -58,6 +46,7 @@ public class JSONRPCReferenceBindingProvider implements ReferenceBindingProvider
this.endpointReference = endpointReference;
this.reference = (RuntimeComponentReference)endpointReference.getReference();
+
//clone the service contract to avoid databinding issues
/*
try {
@@ -73,24 +62,6 @@ public class JSONRPCReferenceBindingProvider implements ReferenceBindingProvider
// httpClient = createHttpClient();
}
- public HttpClient createHttpClient() {
- HttpParams defaultParameters = new BasicHttpParams();
- //defaultParameters.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 10);
- HttpProtocolParams.setContentCharset(defaultParameters, HTTP.UTF_8);
- HttpConnectionParams.setConnectionTimeout(defaultParameters, 60000);
- HttpConnectionParams.setSoTimeout(defaultParameters, 60000);
-
- SchemeRegistry supportedSchemes = new SchemeRegistry();
- supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, PlainSocketFactory.getSocketFactory(), 80));
- supportedSchemes
- .register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
-
- ClientConnectionManager connectionManager =
- new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);
-
- return new DefaultHttpClient(connectionManager, defaultParameters);
- }
-
public InterfaceContract getBindingInterfaceContract() {
//return referenceContract;
return reference.getInterfaceContract();
@@ -102,7 +73,9 @@ public class JSONRPCReferenceBindingProvider implements ReferenceBindingProvider
}
public void start() {
- this.httpClient = createHttpClient();
+ // Create an HTTP client
+ HttpClientFactory clientFactory = new HttpClientFactory();
+ httpClient = clientFactory.createHttpClient();
}
public void stop() {
diff --git a/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
index 267a70a118..4afe089d61 100644
--- a/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
@@ -8,19 +8,8 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Common HTTP
Bundle-SymbolicName: org.apache.tuscany.sca.common.http
Bundle-DocURL: http://www.apache.org/
-Export-Package: org.apache.tuscany.sca.common.http;version="2.0.0";uses:="javax.servlet.http",
- org.apache.tuscany.sca.common.http.client;version="2.0.0";uses:="org.apache.http.client"
-Import-Package: javax.servlet.http,
- org.apache.http,
- org.apache.http.client,
- org.apache.http.conn,
- org.apache.http.conn.params,
- org.apache.http.conn.scheme,
- org.apache.http.conn.ssl,
- org.apache.http.impl.client,
- org.apache.http.impl.conn.tsccm,
- org.apache.http.params,
- org.apache.http.protocol
+Export-Package: org.apache.tuscany.sca.common.http;version="2.0.0";uses:="javax.servlet.http"
+Import-Package: javax.servlet.http
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sca-java-2.x/trunk/modules/common-http/pom.xml b/sca-java-2.x/trunk/modules/common-http/pom.xml
index 4cdd7fc98d..72d5493280 100644
--- a/sca-java-2.x/trunk/modules/common-http/pom.xml
+++ b/sca-java-2.x/trunk/modules/common-http/pom.xml
@@ -32,17 +32,11 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>2.5</version> <!-- to keep compatible with older servlet containers -->
+ <version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.0.3</version>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
diff --git a/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
index 33d1e52caf..3ab8b6de73 100644
--- a/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
@@ -1,6 +1,10 @@
Manifest-Version: 1.0
-Export-Package: org.apache.tuscany.sca.host.http;uses:="javax.servlet,
- javax.servlet.http";version="2.0.0"
+Export-Package: org.apache.tuscany.sca.host.http;version="2.0.0";
+ uses:="javax.servlet,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.extensibility,
+ javax.servlet.http",
+ org.apache.tuscany.sca.host.http.client;version="2.0.0";uses:="org.apache.http.client"
SCA-Version: 1.1
Bundle-Name: Apache Tuscany SCA HTTP Servlet Host Extension Point
Bundle-Vendor: The Apache Software Foundation
@@ -13,7 +17,17 @@ Import-Package: javax.servlet,
javax.servlet.http,
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.extensibility;version="2.0.0",
- org.apache.tuscany.sca.host.http;version="2.0.0"
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.http,
+ org.apache.http.client,
+ org.apache.http.conn,
+ org.apache.http.conn.params,
+ org.apache.http.conn.scheme,
+ org.apache.http.conn.ssl,
+ org.apache.http.impl.client,
+ org.apache.http.impl.conn.tsccm,
+ org.apache.http.params,
+ org.apache.http.protocol
Bundle-SymbolicName: org.apache.tuscany.sca.host.http
Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sca-java-2.x/trunk/modules/host-http/pom.xml b/sca-java-2.x/trunk/modules/host-http/pom.xml
index cc725d24d5..63ea0345f5 100644
--- a/sca-java-2.x/trunk/modules/host-http/pom.xml
+++ b/sca-java-2.x/trunk/modules/host-http/pom.xml
@@ -41,6 +41,13 @@
<version>2.5</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0.3</version>
+ </dependency>
+
</dependencies>
</project>
diff --git a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
index 73bb9ebb8f..b3f21728c8 100644
--- a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java
+++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.common.http.client;
+package org.apache.tuscany.sca.host.http.client;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;