incubator-amber-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmo...@apache.org
Subject svn commit: r1199079 - in /incubator/amber/trunk/oauth-2.0: oauth2-client/src/main/java/org/apache/amber/oauth2/client/ oauth2-httpclient4/ oauth2-httpclient4/src/main/java/org/apache/amber/oauth2/httpclient4/
Date Tue, 08 Nov 2011 02:49:57 GMT
Author: lmoren
Date: Tue Nov  8 02:49:57 2011
New Revision: 1199079

URL: http://svn.apache.org/viewvc?rev=1199079&view=rev
Log:
[AMBER-35] Add a shutdown method to OAuthClient/HttpClient to allow graceful release of resources

Modified:
    incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/HttpClient.java
    incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
    incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/URLConnectionClient.java
    incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/pom.xml
    incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/src/main/java/org/apache/amber/oauth2/httpclient4/HttpClient4.java

Modified: incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/HttpClient.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/HttpClient.java?rev=1199079&r1=1199078&r2=1199079&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/HttpClient.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/HttpClient.java
Tue Nov  8 02:49:57 2011
@@ -41,4 +41,9 @@ public interface HttpClient {
         String requestMethod,
         Class<T> responseClass)
         throws OAuthSystemException, OAuthProblemException;
+    
+    /**
+     * Shut down the client and release the resources associated with the HttpClient
+     */
+    public void shutdown();
 }

Modified: incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java?rev=1199079&r1=1199078&r2=1199079&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
Tue Nov  8 02:49:57 2011
@@ -27,9 +27,9 @@ import java.util.Map;
 import org.apache.amber.oauth2.client.request.OAuthClientRequest;
 import org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse;
 import org.apache.amber.oauth2.client.response.OAuthJSONAccessTokenResponse;
+import org.apache.amber.oauth2.common.OAuth;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.exception.OAuthSystemException;
-import org.apache.amber.oauth2.common.OAuth;
 
 /**
  * OAuth Client - exposes a high-level API for Client Applications
@@ -63,4 +63,8 @@ public class OAuthClient {
         throws OAuthSystemException, OAuthProblemException {
         return accessToken(request, OAuthJSONAccessTokenResponse.class);
     }
+    
+    public void shutdown() {
+        httpClient.shutdown();
+    }
 }

Modified: incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/URLConnectionClient.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/URLConnectionClient.java?rev=1199079&r1=1199078&r2=1199079&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/URLConnectionClient.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client/src/main/java/org/apache/amber/oauth2/client/URLConnectionClient.java
Tue Nov  8 02:49:57 2011
@@ -34,9 +34,9 @@ import org.apache.amber.oauth2.client.re
 import org.apache.amber.oauth2.client.response.OAuthClientResponse;
 import org.apache.amber.oauth2.client.response.OAuthClientResponseFactory;
 import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.exception.OAuthSystemException;
 import org.apache.amber.oauth2.common.utils.OAuthUtils;
-import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 
 
 /**
@@ -106,4 +106,9 @@ public class URLConnectionClient impleme
             .createCustomResponse(responseBody, c.getContentType(), responseCode, responseClass);
     }
 
+    @Override
+    public void shutdown() {
+        // Nothing to do here
+    }
+
 }

Modified: incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/pom.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/pom.xml?rev=1199079&r1=1199078&r2=1199079&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/pom.xml (original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/pom.xml Tue Nov  8 02:49:57 2011
@@ -39,7 +39,7 @@
         <finalName>oauth2-httpclient4</finalName>
     </build>
     <properties>
-        <httpclient.version>4.0.1</httpclient.version>
+        <httpclient.version>4.1.2</httpclient.version>
     </properties>
 
     <dependencies>

Modified: incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/src/main/java/org/apache/amber/oauth2/httpclient4/HttpClient4.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/src/main/java/org/apache/amber/oauth2/httpclient4/HttpClient4.java?rev=1199079&r1=1199078&r2=1199079&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/src/main/java/org/apache/amber/oauth2/httpclient4/HttpClient4.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-httpclient4/src/main/java/org/apache/amber/oauth2/httpclient4/HttpClient4.java
Tue Nov  8 02:49:57 2011
@@ -26,7 +26,11 @@ import java.util.Map;
 
 import org.apache.amber.oauth2.client.HttpClient;
 import org.apache.amber.oauth2.client.request.OAuthClientRequest;
+import org.apache.amber.oauth2.client.response.OAuthClientResponse;
+import org.apache.amber.oauth2.client.response.OAuthClientResponseFactory;
+import org.apache.amber.oauth2.common.OAuth;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
 import org.apache.amber.oauth2.common.utils.OAuthUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
@@ -34,14 +38,10 @@ import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.util.EntityUtils;
-import org.apache.amber.oauth2.client.response.OAuthClientResponseFactory;
-
-import org.apache.amber.oauth2.client.response.OAuthClientResponse;
-import org.apache.amber.oauth2.common.OAuth;
-import org.apache.amber.oauth2.common.exception.OAuthSystemException;
 
 
 /**
@@ -53,14 +53,24 @@ import org.apache.amber.oauth2.common.ex
  */
 public class HttpClient4 implements HttpClient {
 
-    private org.apache.http.client.HttpClient client = new DefaultHttpClient();
+    private org.apache.http.client.HttpClient client;
 
     public HttpClient4() {
+        client = new DefaultHttpClient();
     }
 
     public HttpClient4(org.apache.http.client.HttpClient client) {
         this.client = client;
     }
+    
+    public void shutdown() {
+        if (client != null) {
+            ClientConnectionManager connectionManager = client.getConnectionManager();
+            if (connectionManager != null) {
+                connectionManager.shutdown();
+            }
+        }
+    }
 
     public <T extends OAuthClientResponse> T execute(OAuthClientRequest request,
                                                      Map<String, String> headers,



Mime
View raw message