[Jboss-cvs] JBossAS SVN: r56400 - branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 29 11:31:20 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-29 11:31:20 -0400 (Tue, 29 Aug 2006)
New Revision: 56400
Modified:
branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/AttributeBasedClusteredSession.java
Log:
For multiple changes, use TreeCache.put(Fqn, Map)
Modified: branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/AttributeBasedClusteredSession.java
===================================================================
--- branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/AttributeBasedClusteredSession.java 2006-08-29 13:19:16 UTC (rev 56399)
+++ branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/AttributeBasedClusteredSession.java 2006-08-29 15:31:20 UTC (rev 56400)
@@ -26,6 +26,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
/**
* Implementation of a clustered session for the JBossCacheManager. The replication granularity
@@ -128,23 +129,31 @@
if (getSessionAttributesDirty())
{
// Go thru the modified attr list first
- Set set = attrModifiedMap_.keySet();
- Iterator it = set.iterator();
- while (it.hasNext())
+ int modCount = attrModifiedMap_.size();
+ if (modCount == 1)
{
- Object key = it.next();
- proxy_.putAttribute(realId, (String) key, attrModifiedMap_.get(key));
+ for (Iterator it = attrModifiedMap_.entrySet().iterator(); it.hasNext(); )
+ {
+ Map.Entry entry = (Entry) it.next();
+ proxy_.putAttribute(realId, (String) entry.getKey(), entry.getValue());
+ }
}
-
- // Go thru the remove attr list
- set = attrRemovedMap_.keySet();
- it = set.iterator();
- while (it.hasNext())
+ else if (modCount > 0)
{
- Object key = it.next();
- proxy_.removeAttribute(realId, (String) key);
+ // It's more efficient to write a map than 2 method calls,
+ // plus it reduces the number of CacheListener notifications
+ proxy_.putAttribute(realId, attrModifiedMap_);
}
-
+
+ // Go thru the remove attr list
+ if (attrRemovedMap_.size() > 0)
+ {
+ for (Iterator it = attrRemovedMap_.keySet().iterator(); it.hasNext(); )
+ {
+ proxy_.removeAttribute(realId, (String) it.next());
+ }
+ }
+
clearAttrChangedMaps();
}
More information about the jboss-cvs-commits
mailing list