You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2008/01/14 17:12:55 UTC

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

Author: scheu
Date: Mon Jan 14 08:12:49 2008
New Revision: 611844

URL: http://svn.apache.org/viewvc?rev=611844&view=rev
Log:
AXIS2-3442
Contributor: Rich Scheuerle
Performance Tester: David Strite
David suggested a change to lazily create the propertyDifferences map.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.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=611844&r1=611843&r2=611844&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 Mon Jan 14 08:12:49 2008
@@ -42,7 +42,7 @@
 
     protected transient AbstractContext parent;
     protected transient Map properties;
-    private transient Map propertyDifferences = new HashMap();
+    private transient Map propertyDifferences;
 
     protected AbstractContext(AbstractContext parent) {
         this.parent = parent;
@@ -115,7 +115,7 @@
 
             // Assume that a property is which is read may be updated.
             // i.e. The object pointed to by 'value' may be modified after it is read
-            addPropertyDifference(key, obj);
+            addPropertyDifference(key, obj, false);
         }
         return obj;
     }
@@ -137,7 +137,7 @@
 
             // Assume that a property is which is read may be updated.
             // i.e. The object pointed to by 'value' may be modified after it is read
-            addPropertyDifference(key, obj);
+            addPropertyDifference(key, obj, false);
         }
         return obj;
     }
@@ -168,26 +168,46 @@
             this.properties = new HashMap();
         }
         properties.put(key, value);
-        addPropertyDifference(key, value);
+        addPropertyDifference(key, value, false);
     }
 
-    private void addPropertyDifference(String key, Object value) {
+    private void addPropertyDifference(String key, Object value,  boolean isRemoved) {
+        
+        if (!needPropertyDifferences()) {
+            return;
+        }
+        // Narrowed the synchronization so that we only wait
+        // if a property difference is added.
+        synchronized(this) {
+            // Lazizly create propertyDifferences map
+            if (propertyDifferences == null) {
+                propertyDifferences = new HashMap();
+            }
+            propertyDifferences.put(key, new PropertyDifference(key, value, isRemoved));
+        }
+    }
+    
+    /**
+     * @return true if we need to store property differences for this 
+     * context in this scenario.
+     */
+    private boolean needPropertyDifferences() {
+        
+        // Don't store property differences if there are no 
+        // cluster members.
+        
         ConfigurationContext cc = getRootContext();
         if (cc == null) {
-            return;
+            return false;
         }
         // Add the property differences only if Context replication is enabled,
         // and there are members in the cluster
         ClusterManager clusterManager = cc.getAxisConfiguration().getClusterManager();
         if (clusterManager == null ||
             clusterManager.getContextManager() == null) {
-            return;
-        }
-        // Narrowed the synchronization so that we only wait
-        // if a property difference is added.
-        synchronized(this) {
-            propertyDifferences.put(key, new PropertyDifference(key, value, false));
+            return false;
         }
+        return true;
     }
 
     /**
@@ -216,7 +236,7 @@
             if (properties != null) {
                 properties.remove(key);
             }
-            propertyDifferences.put(key, new PropertyDifference(key, value, true));
+            addPropertyDifference(key, value, true);
         }
     }
 
@@ -240,6 +260,9 @@
      * @return The property differences
      */
     public synchronized Map getPropertyDifferences() {
+        if (propertyDifferences == null) {
+            propertyDifferences = new HashMap();
+        }
         return propertyDifferences;
     }
 
@@ -249,7 +272,9 @@
      * been sent.
      */
     public synchronized void clearPropertyDifferences() {
-        propertyDifferences.clear();
+        if (propertyDifferences != null) {
+            propertyDifferences.clear();
+        }
     }
 
     /**



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