myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r513208 - /myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java
Date Thu, 01 Mar 2007 07:28:44 GMT
Author: imario
Date: Wed Feb 28 23:28:44 2007
New Revision: 513208

URL: http://svn.apache.org/viewvc?view=rev&rev=513208
Log:
made access to conversation beans thread safe

Modified:
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java?view=diff&rev=513208&r1=513207&r2=513208
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java
(original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java
Wed Feb 28 23:28:44 2007
@@ -111,18 +111,21 @@
 			throw new IllegalArgumentException("you cant put a property under conversation control.
name: " + name);
 		}
 
-		if (beans.containsKey(name))
+		synchronized(beans)
 		{
-			// already there
-			return;
-		}
+			if (beans.containsKey(name))
+			{
+				// already there
+				return;
+			}
 
-		if (log.isDebugEnabled())
-		{
-			log.debug("put bean to conversation:" + name + "(bean=" + name + ")");
-		}
+			if (log.isDebugEnabled())
+			{
+				log.debug("put bean to conversation:" + name + "(bean=" + name + ")");
+			}
 
-		beans.put(name, bean);
+			beans.put(name, bean);
+		}
 
 		if (bean instanceof ConversationBindingListener)
 		{
@@ -217,21 +220,16 @@
 			log.debug("end conversation:" + name);
 		}
 
-		Iterator iterBeans = beans.entrySet().iterator();
-		while (iterBeans.hasNext())
+		synchronized(beans)
 		{
-			Map.Entry entry = (Map.Entry) iterBeans.next();
-
-			String name = (String) entry.getKey();
-			Object bean = entry.getValue();
-
-			if (bean instanceof ConversationBindingListener)
+			Iterator iterBeans = beans.keySet().iterator();
+			while (iterBeans.hasNext())
 			{
-				((ConversationBindingListener) bean).valueUnbound(
-					new ConversationBindingEvent(this, name));
+				String name = (String) iterBeans.next();
+				removeAttribute(name);
 			}
+			beans.clear();
 		}
-		beans.clear();
 
 		conversationContext.removeConversation(getName());
 	}
@@ -241,7 +239,10 @@
 	 */
 	public boolean hasAttribute(String name)
 	{
-		return beans.containsKey(name);
+		synchronized(beans)
+		{
+			return beans.containsKey(name);
+		}
 	}
 
 	/**
@@ -249,7 +250,10 @@
 	 */
 	public Object getAttribute(String name)
 	{
-		return beans.get(name);
+		synchronized(beans)
+		{
+			return beans.get(name);
+		}
 	}
 
 	/**
@@ -261,13 +265,16 @@
 	 */
 	public Object removeAttribute(String name)
 	{
-		Object bean = beans.remove(name);
-		if (bean instanceof ConversationBindingListener)
+		synchronized(beans)
 		{
-			((ConversationBindingListener) bean).valueUnbound(
-				new ConversationBindingEvent(this, name));
+			Object bean = beans.remove(name);
+			if (bean instanceof ConversationBindingListener)
+			{
+				((ConversationBindingListener) bean).valueUnbound(
+					new ConversationBindingEvent(this, name));
+			}
+			return bean;
 		}
-		return bean;
 	}
 
 	/**



Mime
View raw message