summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-03-02 18:49:59 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-03-02 18:49:59 +0000
commite5d0edc3a0250f8fc528d7520c980f999b05ae86 (patch)
treeff98a6f63ea89613e557bb6f442d60fb4d416edb /sca-java-2.x
parent32d377bee8b46b9db2b2edee9060b37feca99e33 (diff)
Use Apache HTTP client for REST reference binding
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1296382 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE3
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml2
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml14
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java10
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java13
5 files changed, 34 insertions, 8 deletions
diff --git a/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE b/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
index aa5999deb0..e60f55f787 100644
--- a/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
+++ b/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
@@ -259,7 +259,7 @@ The following components come under Apache Software License 2.0
gson-1.4.jar
hazelcast-1.9.2.2.jar
hazelcast-client-1.9.2.2.jar
- httpclient-4.1.2.jar
+ httpclient-4.1.3.jar
httpcore-4.1.3.jar
jackson-core-asl-1.9.4.jar
jackson-mapper-asl-1.9.4.jar
@@ -311,6 +311,7 @@ The following components come under Apache Software License 2.0
tribes-6.0.26.jar
wink-common-1.1.3-incubating.jar
wink-client-1.1.3-incubating.jar
+ wink-client-apache-httpclient-1.1.3-incubating.jar
wink-server-1.1.3-incubating.jar
wss4j-1.5.10.jar
xalan-2.7.0.jar
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
index 8bdf25b8d8..6c11bc53a4 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
@@ -81,7 +81,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.1.2</version>
+ <version>4.1.3</version>
</dependency>
<dependency>
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
index 8e73fa58a8..c61e8e8876 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
@@ -159,7 +159,7 @@
<dependency>
<groupId>org.apache.wink</groupId>
- <artifactId>wink-client</artifactId>
+ <artifactId>wink-client-apache-httpclient</artifactId>
<version>1.1.3-incubating</version>
<exclusions>
<exclusion>
@@ -180,6 +180,18 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.1.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.1.3</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
index e5de008fa5..b6c598996f 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
@@ -52,6 +52,7 @@ import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
+import org.apache.http.client.HttpClient;
import org.apache.tuscany.sca.assembly.WireFormat;
import org.apache.tuscany.sca.binding.rest.RESTBinding;
import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
@@ -63,6 +64,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.wink.client.ApacheHttpClientConfig;
import org.apache.wink.client.ClientConfig;
import org.apache.wink.client.Resource;
import org.apache.wink.client.RestClient;
@@ -79,12 +81,12 @@ public class RESTBindingInvoker implements Invoker {
private String httpMethod;
private Class<?> responseType;
- public RESTBindingInvoker(ExtensionPointRegistry registry, RESTBinding binding, Operation operation) {
+ public RESTBindingInvoker(ExtensionPointRegistry registry, RESTBinding binding, Operation operation, HttpClient httpClient) {
super();
this.registry = registry;
this.binding = binding;
this.operation = operation;
- this.restClient = createRestClient();
+ this.restClient = createRestClient(httpClient);
}
private static Map<Class<?>, String> mapping = new HashMap<Class<?>, String>();
@@ -106,8 +108,8 @@ public class RESTBindingInvoker implements Invoker {
return null;
}
- private RestClient createRestClient() {
- ClientConfig config = new ClientConfig();
+ private RestClient createRestClient(HttpClient httpClient) {
+ ClientConfig config = new ApacheHttpClientConfig(httpClient);
// configureBasicAuth(config, userName, password);
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
index e218f32573..71d7aa79ba 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
@@ -19,8 +19,10 @@
package org.apache.tuscany.sca.binding.rest.provider;
+import org.apache.http.client.HttpClient;
import org.apache.tuscany.sca.binding.rest.RESTBinding;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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;
@@ -33,18 +35,22 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
public class RESTReferenceBindingProvider implements EndpointReferenceProvider {
private ExtensionPointRegistry registry;
private RuntimeEndpointReference endpointReference;
+
+ private HttpClientFactory httpClientFactory;
+ private HttpClient httpClient;
public RESTReferenceBindingProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) {
super();
this.registry = registry;
this.endpointReference = endpointReference;
+ this.httpClientFactory = HttpClientFactory.getInstance(registry);
}
public void configure() {
}
public Invoker createInvoker(Operation operation) {
- return new RESTBindingInvoker(registry, (RESTBinding)endpointReference.getBinding(), operation);
+ return new RESTBindingInvoker(registry, (RESTBinding)endpointReference.getBinding(), operation, httpClient);
}
public InterfaceContract getBindingInterfaceContract() {
@@ -56,9 +62,14 @@ public class RESTReferenceBindingProvider implements EndpointReferenceProvider {
}
public void start() {
+ // Create an HTTP client
+ httpClient = httpClientFactory.createHttpClient();
}
public void stop() {
+ if (httpClient != null) {
+ httpClient.getConnectionManager().shutdown();
+ }
}
}