tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1296382 - in /tuscany/sca-java-2.x/trunk: distribution/all/src/main/release/bin/ modules/binding-jsonrpc-runtime/ modules/binding-rest-runtime/ modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/
Date Fri, 02 Mar 2012 18:49:59 GMT
Author: rfeng
Date: Fri Mar  2 18:49:59 2012
New Revision: 1296382

URL: http://svn.apache.org/viewvc?rev=1296382&view=rev
Log:
Use Apache HTTP client for REST reference binding

Modified:
    tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java

Modified: tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE?rev=1296382&r1=1296381&r2=1296382&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE (original)
+++ tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE Fri Mar  2 18:49:59
2012
@@ -259,7 +259,7 @@ The following components come under Apac
  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 Apac
  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

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml?rev=1296382&r1=1296381&r2=1296382&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml Fri Mar  2 18:49:59
2012
@@ -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>

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml?rev=1296382&r1=1296381&r2=1296382&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml Fri Mar  2 18:49:59 2012
@@ -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>

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java?rev=1296382&r1=1296381&r2=1296382&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
Fri Mar  2 18:49:59 2012
@@ -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.interfaced
 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 implemen
     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 implemen
         return null;
     }
 
-    private RestClient createRestClient() {
-        ClientConfig config = new ClientConfig();
+    private RestClient createRestClient(HttpClient httpClient) {
+        ClientConfig config = new ApacheHttpClientConfig(httpClient);
 
         // configureBasicAuth(config, userName, password);
 

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java?rev=1296382&r1=1296381&r2=1296382&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
Fri Mar  2 18:49:59 2012
@@ -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.Ru
 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 RESTReferenceBindingProvide
     }
 
     public void start() {
+        // Create an HTTP client
+        httpClient = httpClientFactory.createHttpClient();
     }
 
     public void stop() {
+        if (httpClient != null) {
+            httpClient.getConnectionManager().shutdown();
+        }
     }
 
 }



Mime
View raw message