cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1469308 - in /cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client: AbstractClient.java Client.java
Date Thu, 18 Apr 2013 13:19:11 GMT
Author: sergeyb
Date: Thu Apr 18 13:19:10 2013
New Revision: 1469308

URL: http://svn.apache.org/r1469308
Log:
[CXF-4974] Adding close() method to Client interface

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/Client.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1469308&r1=1469307&r2=1469308&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Thu
Apr 18 13:19:10 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.jaxrs.client;
 
+import java.io.Closeable;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
@@ -58,6 +60,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.Retryable;
@@ -274,6 +277,29 @@ public abstract class AbstractClient imp
         return this;
     }
 
+    public void close() {
+        if (cfg.getBus() == null) {
+            return;
+        }
+        ClientLifeCycleManager mgr = cfg.getBus().getExtension(ClientLifeCycleManager.class);
+        if (null != mgr) {
+            mgr.clientDestroyed(new FrontendClientAdapter(getConfiguration()));
+        }
+
+        if (cfg.getConduitSelector() instanceof Closeable) {
+            try {
+                ((Closeable)cfg.getConduitSelector()).close();
+            } catch (IOException e) {
+                //ignore, we're destroying anyway
+            }
+        } else {
+            cfg.getConduit().close();
+        }
+        state.reset();
+        state = null;
+        cfg = null;
+    }
+    
     private void possiblyAddHeader(String name, String value) {
         if (!isDuplicate(name, value)) {
             state.getRequestHeaders().add(name, value);

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/Client.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/Client.java?rev=1469308&r1=1469307&r2=1469308&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/Client.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/Client.java Thu Apr 18
13:19:10 2013
@@ -156,4 +156,9 @@ public interface Client {
      * @return JAXRS Response response
      */
     Response getResponse();
+    
+    /**
+     * Releases the internal state and configuration associated with this client 
+     */
+    void close();
 }



Mime
View raw message