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 da...@apache.org on 2007/01/30 10:45:30 UTC

svn commit: r501357 - in /webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/context/ test/org/apache/axis2/dispatchers/

Author: davidillsley
Date: Tue Jan 30 01:45:29 2007
New Revision: 501357

URL: http://svn.apache.org/viewvc?view=rev&rev=501357
Log:
Clean up access to the operation context map.

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
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedOperationDispatcherTest.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedServiceDispatcherTest.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?view=diff&rev=501357&r1=501356&r2=501357
==============================================================================
--- 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 Tue Jan 30 01:45:29 2007
@@ -201,15 +201,32 @@
 
     /**
      * Registers a OperationContext with a given message ID.
+     * If the given message id already has a registered operation context,
+     * no change is made and the methid resturns false.
      *
      * @param messageID
      * @param mepContext
      */
-    public void registerOperationContext(String messageID,
+    public boolean registerOperationContext(String messageID,
                                          OperationContext mepContext) {
+        boolean alreadyInMap = false;
         mepContext.setKey(messageID);
         synchronized (operationContextMap) {
-            this.operationContextMap.put(messageID, mepContext);
+            alreadyInMap = operationContextMap.containsKey(messageID);
+            if(!alreadyInMap){
+                this.operationContextMap.put(messageID, mepContext);
+            }
+        }
+        return (!alreadyInMap);
+    }
+    
+    /**
+     * Unregisters the operation context associated with the given messageID
+     * @param key
+     */
+    public void unregisterOperationContext(String key) {
+        synchronized (operationContextMap) {
+            operationContextMap.remove(key);
         }
     }
 
@@ -256,10 +273,6 @@
         }
 
         return opCtx;
-    }
-
-    public Map getOperationContextMap() {
-        return this.operationContextMap;
     }
 
     public OperationContext findOperationContext(String operationName, String serviceName, String serviceGroupName) {

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?view=diff&rev=501357&r1=501356&r2=501357
==============================================================================
--- 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 Tue Jan 30 01:45:29 2007
@@ -17,28 +17,26 @@
 
 package org.apache.axis2.context;
 
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.util.ObjectStateUtils;
-import org.apache.axis2.util.MetaDataEntry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
-import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.util.MetaDataEntry;
+import org.apache.axis2.util.ObjectStateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 /**
  * An OperationContext represents a running "instance" of an operation, which is
  * represented by an AxisOperation object. This concept is needed to allow
@@ -106,11 +104,6 @@
      */
     private transient HashMap messageContexts;
 
-    // this is the global MessageID -> OperationContext map which is stored in
-    // the EngineContext. We're caching it here for faster access.
-    private transient Map operationContextMap;
-
-
     //----------------------------------------------------------------
     // MetaData for data to be restored in activate after readExternal
     //----------------------------------------------------------------
@@ -203,15 +196,6 @@
         super(serviceContext);
         this.messageContexts = new HashMap();
         this.axisOperation = axisOperation;
-
-        ServiceContext serv = getServiceContext();
-
-        if (serv != null)
-        {
-            this.operationContextMap =
-                    serv.getConfigurationContext()
-                            .getOperationContextMap();
-        }
     }
 
     /**
@@ -241,17 +225,10 @@
      * being complete due to the optional nature of the MEP.
      */
     public void cleanup() {
-        if (key != null) {
-            if (operationContextMap == null) {
-                ServiceContext serv = getServiceContext();
-
-                if (serv != null) {
-                    this.operationContextMap =
-                            serv.getConfigurationContext()
-                                    .getOperationContextMap();
-                }
-            }
-            operationContextMap.remove(key);
+        ServiceContext serv = getServiceContext();
+
+        if (serv != null) {
+            serv.getConfigurationContext().unregisterOperationContext(key);
         }
     }
 
@@ -327,18 +304,6 @@
         isComplete = complete;
     }
 
-    public void setParent(AbstractContext context) {
-        super.setParent(context);
-
-        ServiceContext serv = getServiceContext();
-
-        if (serv != null) {
-            this.operationContextMap =
-                    serv.getConfigurationContext()
-                            .getOperationContextMap();
-        }
-    }
-
     public void setKey(String key) {
         this.key = key;
     }
@@ -695,14 +660,6 @@
 
         metaMessageContextMap = ObjectStateUtils.readHashMap(in, "OperationContext.metaMessageContextMap metadata table");
 
-
-        //---------------------------------------------------------
-        // other
-        //---------------------------------------------------------
-
-        operationContextMap = null;  //need to reseed from config context
-
-
         //---------------------------------------------------------
         // done
         //---------------------------------------------------------
@@ -850,30 +807,19 @@
             activeCC = cc;
         }
 
-        this.operationContextMap = activeCC.getOperationContextMap(); 
-
-        if ((this.operationContextMap != null) && (key != null))
-        {
-            // is the current key already in the list?
-            if (this.operationContextMap.containsKey(key) == false)
-            {
-                // make sure this OperationContext object is registered in the 
-                // list maintained by the ConfigurationContext object
-                activeCC.registerOperationContext(key, this);
-            }
-            else
-            {
+        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
                 if (log.isTraceEnabled())
                 {
                     log.trace(myClassName+":activate():  OperationContext key ["+key+"] already exists in ConfigurationContext map.  This OperationContext ["+this.toString()+"] was not added to the table.");
                 }
-                //System.out.println(myClassName+":activate():  OperationContext key ["+key+"] already exists in ConfigurationContext map.");
             }
-
         }
-
-
+        
         //-------------------------------------------------------
         // update the modified entries in the messageContexts table
         //-------------------------------------------------------

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedOperationDispatcherTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedOperationDispatcherTest.java?view=diff&rev=501357&r1=501356&r2=501357
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedOperationDispatcherTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedOperationDispatcherTest.java Tue Jan 30 01:45:29 2007
@@ -44,8 +44,8 @@
         ConfigurationContext cc = new ConfigurationContext(ac);
         OperationContext oc1 = new OperationContext(operation1);
         OperationContext oc2 = new OperationContext(operation2);
-        cc.getOperationContextMap().put("urn:org.apache.axis2.dispatchers.messageid:123", oc1);
-        cc.getOperationContextMap().put("urn:org.apache.axis2.dispatchers.messageid:456", oc2);
+        cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:123", oc1);
+        cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:456", oc2);
         
         messageContext.setConfigurationContext(cc);
         messageContext.addRelatesTo(new RelatesTo("urn:org.apache.axis2.dispatchers.messageid:456"));

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedServiceDispatcherTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedServiceDispatcherTest.java?view=diff&rev=501357&r1=501356&r2=501357
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedServiceDispatcherTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/dispatchers/RelatesToBasedServiceDispatcherTest.java Tue Jan 30 01:45:29 2007
@@ -60,8 +60,8 @@
         OperationContext oc2 = new OperationContext(operation2);
         oc2.setParent(sc2);
         
-        cc.getOperationContextMap().put("urn:org.apache.axis2.dispatchers.messageid:123", oc1);
-        cc.getOperationContextMap().put("urn:org.apache.axis2.dispatchers.messageid:456", oc2);
+        cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:123", oc1);
+        cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:456", oc2);
         
         messageContext.setConfigurationContext(cc);
         messageContext.addRelatesTo(new RelatesTo("urn:org.apache.axis2.dispatchers.messageid:456"));



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