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 sc...@apache.org on 2008/01/03 16:26:45 UTC

svn commit: r608527 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context: AbstractContext.java MessageContext.java

Author: scheu
Date: Thu Jan  3 07:26:44 2008
New Revision: 608527

URL: http://svn.apache.org/viewvc?rev=608527&view=rev
Log:
AXIS2-3422
Contributor:Rich Scheuerle
Performance Analysis: David Strite
Recode the MessageContext.getProperty(String) method to avoid duplicate lookups.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java?rev=608527&r1=608526&r2=608527&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java Thu Jan  3 07:26:44 2008
@@ -59,6 +59,24 @@
     }
 
     /**
+     * @param context
+     * @return true if the context is an ancestor
+     */
+    public boolean isAncestor(AbstractContext context) {
+        if (context == null) {
+            return false;
+        }
+        for (AbstractContext ancestor = getParent();
+            ancestor != null;
+            ancestor = ancestor.getParent()) {
+            if (ancestor == context) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    /**
      * @return The properties
      * @deprecated Use {@link #getPropertyNames()}, {@link #getProperty(String)},
      *             {@link #setProperty(String, Object)} & {@link #removeProperty(String)}instead.

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=608527&r1=608526&r2=608527&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Thu Jan  3 07:26:44 2008
@@ -919,21 +919,29 @@
 
         // My own context hierarchy may not all be present. So look for whatever
         // nearest level is present and ask that to find the property.
+        //
+        // If the context is already an ancestor, it was checked during
+        // the super.getProperty call.  In such cases, the second check 
+        // is not performed.
         if (operationContext != null) {
-            return operationContext.getProperty(name);
-        }
-        if (serviceContext != null) {
-            return serviceContext.getProperty(name);
-        }
-        if (serviceGroupContext != null) {
-            return serviceGroupContext.getProperty(name);
-        }
-        if (configurationContext != null) {
-            return configurationContext.getProperty(name);
+            if (!isAncestor(operationContext)) {
+                obj = operationContext.getProperty(name);
+            }
+        } else if (serviceContext != null) {
+            if (!isAncestor(serviceContext)) {
+                obj = serviceContext.getProperty(name);
+            }
+        } else if (serviceGroupContext != null) {
+            if (!isAncestor(serviceGroupContext)) {
+                obj =  serviceGroupContext.getProperty(name);
+            }
+        } else if (configurationContext != null) {
+            if (!isAncestor(configurationContext)) {
+                obj = configurationContext.getProperty(name);
+            }
         }
 
-        // tough
-        return null;
+        return obj;
     }
 
     /**



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