You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by gd...@apache.org on 2009/10/06 03:43:38 UTC

svn commit: r822105 - /webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/client/ServiceClient.java

Author: gdaniels
Date: Tue Oct  6 01:43:37 2009
New Revision: 822105

URL: http://svn.apache.org/viewvc?rev=822105&view=rev
Log:
Two changes:

* Add AUTO_OPERATION_CLEANUP option, defaulting to true.  This cleans up the last OperationContext each time we make a new ServiceClient, rather than forcing the user to use setCallTransportCleanup() which always fully builds the Axiom model.

* Fix AXIS2-4163 while in there (trivial change).

Modified:
    webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/client/ServiceClient.java

Modified: webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/client/ServiceClient.java?rev=822105&r1=822104&r2=822105&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/client/ServiceClient.java Tue Oct  6 01:43:37 2009
@@ -50,6 +50,7 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.namespace.Constants;
 import org.apache.axis2.util.Counter;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -70,6 +71,9 @@
     /** Base name used for a service created without an existing configuration. */
     public static final String ANON_SERVICE = "anonService";
 
+    /** Option property name for automatically cleaning up old OperationContexts */
+    public static final String AUTO_OPERATION_CLEANUP = "ServiceClient.autoOperationCleanup";
+
     /** Counter used to generate the anonymous service name. */
     private static Counter anonServiceCounter = new Counter();
 
@@ -639,6 +643,13 @@
      * @throws AxisFault if the operation is not found
      */
     public OperationClient createClient(QName operationQName) throws AxisFault {
+        // If we're configured to do so, clean up the last OperationContext (thus
+        // releasing its resources) each time we create a new one.
+        if (JavaUtils.isTrue(getOptions().getProperty(AUTO_OPERATION_CLEANUP), true) &&
+                !getOptions().isUseSeparateListener()) {
+            cleanupTransport();
+        }
+
         AxisOperation axisOperation = axisService.getOperation(operationQName);
         if (axisOperation == null) {
             throw new AxisFault(Messages
@@ -775,8 +786,11 @@
     }
 
     protected void finalize() throws Throwable {
-        super.finalize();
-        cleanup();
+        try {
+            cleanup();
+        } finally {
+            super.finalize();
+        }
     }
 
     /**
@@ -801,9 +815,10 @@
     }
 
     public void cleanupTransport() throws AxisFault {
-        if (getLastOperationContext() != null) {
+        final OperationContext lastOperationContext = getLastOperationContext();
+        if (lastOperationContext != null) {
             MessageContext outMessageContext =
-                    getLastOperationContext()
+                    lastOperationContext
                             .getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
             if (outMessageContext != null) {
                 outMessageContext.getTransportOut().getSender().cleanup(outMessageContext);