axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r573377 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context: ConfigurationContext.java OperationContext.java
Date Thu, 06 Sep 2007 21:01:21 GMT
Author: scheu
Date: Thu Sep  6 14:01:21 2007
New Revision: 573377

URL: http://svn.apache.org/viewvc?rev=573377&view=rev
Log:
AXIS2-3180
Contributor: Bill Nagy
When a persisted OperationContext is "activated", it should only be registered on 
the ConfigurationContext if a response is expected.  Otherwise the OperationContext
will never be freed and could lead to out-of-memory problems.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?rev=573377&r1=573376&r2=573377&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
Thu Sep  6 14:01:21 2007
@@ -37,6 +37,8 @@
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.threadpool.ThreadFactory;
 import org.apache.axis2.util.threadpool.ThreadPool;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.io.File;
 import java.net.URL;
@@ -63,6 +65,7 @@
  */
 public class ConfigurationContext extends AbstractContext {
 
+    private static final Log log = LogFactory.getLog(ConfigurationContext.class);
     /**
      * Map containing <code>MessageID</code> to
      * <code>OperationContext</code> mapping.
@@ -277,23 +280,49 @@
      * If the given message id already has a registered operation context,
      * no change is made and the methid resturns false.
      *
-     * @param messageID  the message-id to register
-     * @param mepContext the OperationContext for the specified message-id
-     * @return true if we added a new context, false if the messageID was already there and
we did
-     *         nothing
+     * @param messageID
+     * @param mepContext
      */
-    public boolean registerOperationContext(String messageID,
+    public boolean registerOperationContext(String messageID, 
                                             OperationContext mepContext) {
-        mepContext.setKey(messageID);  // TODO: Doing this here seems dangerous....
+        return registerOperationContext(messageID, mepContext, false);
+    }
+    
+    /**
+     * Registers a OperationContext with a given message ID.
+     * If the given message id already has a registered operation context,
+     * no change is made unless the override flag is set. 
+     *
+     * @param messageID
+     * @param mepContext
+     * @param override
+     */
+    public boolean registerOperationContext(String messageID, 
+                                            OperationContext mepContext, 
+                                            boolean override) {
+        boolean alreadyInMap;
+        mepContext.setKey(messageID);
         synchronized (operationContextMap) {
-            if (!operationContextMap.containsKey(messageID)) {
+            alreadyInMap = operationContextMap.containsKey(messageID);
+            if (!alreadyInMap || override) {
                 this.operationContextMap.put(messageID, mepContext);
-                return true;
+            }
+
+            if (log.isDebugEnabled())
+            {
+                log.debug("registerOperationContext ("+override+"): "+
+                          mepContext+" with key: "+messageID);
+                HashMap msgContextMap = mepContext.getMessageContexts();
+                Iterator msgContextIterator = msgContextMap.values().iterator();
+                while (msgContextIterator.hasNext())
+                {
+                    MessageContext msgContext = (MessageContext)msgContextIterator.next();
+                    log.debug("msgContext: "+msgContext+" action: "+msgContext.getWSAAction());
+                }
             }
         }
-        return false;
+        return (!alreadyInMap || override);
     }
-
     /**
      * Unregisters the operation context associated with the given messageID
      *

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java?rev=573377&r1=573376&r2=573377&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java
Thu Sep  6 14:01:21 2007
@@ -27,6 +27,8 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.util.MetaDataEntry;
 import org.apache.axis2.util.ObjectStateUtils;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004_Constants;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2006Constants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -759,14 +761,23 @@
         }
 
         if (key != null) {
-            // make sure this OperationContext object is registered in the
-            // list maintained by the ConfigurationContext object
-            boolean registrationSuceeded = activeCC.registerOperationContext(key, this);
-            if (!registrationSuceeded) {
-                // trace point
-                log.trace(logCorrelationIDString + ":activate():  OperationContext key ["
+ key +
-                        "] already exists in ConfigurationContext map.  This OperationContext
[" +
-                        this.toString() + "] was not added to the table.");
+            // We only want to (re)register this if it's an outbound message
+            String mepString = getAxisOperation().getMessageExchangePattern();
+            if (mepString.equals(WSDL20_2006Constants.MEP_URI_OUT_ONLY)
+                || mepString.equals(WSDL20_2004_Constants.MEP_URI_OUT_ONLY)
+                || ((mepString.equals(WSDL20_2006Constants.MEP_URI_OUT_IN)
+                    || mepString.equals(WSDL20_2004_Constants.MEP_URI_OUT_IN))
+                    && !isComplete)) {
+                    
+                // make sure this OperationContext object is registered in the 
+                // list maintained by the ConfigurationContext object
+                boolean registrationSuceeded = activeCC.registerOperationContext(key, this,
true);
+                if (!registrationSuceeded) {
+                    // trace point
+                    log.trace(logCorrelationIDString + ":activate():  OperationContext key
[" + key
+                              + "] already exists in ConfigurationContext map.  This OperationContext
["
+                              + this.toString() + "] was not added to the table.");
+                }
             }
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message