You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/03/01 08:41:06 UTC

svn commit: r513214 - in /myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation: Conversation.java ConversationContext.java spring/SpringConversationScope.java

Author: imario
Date: Wed Feb 28 23:41:06 2007
New Revision: 513214

URL: http://svn.apache.org/viewvc?view=rev&rev=513214
Log:
recheck thread safety

Modified:
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/Conversation.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationContext.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringConversationScope.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=513214&r1=513213&r2=513214
==============================================================================
--- 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:41:06 2007
@@ -111,7 +111,7 @@
 			throw new IllegalArgumentException("you cant put a property under conversation control. name: " + name);
 		}
 
-		synchronized(beans)
+		synchronized(this)
 		{
 			if (beans.containsKey(name))
 			{
@@ -220,7 +220,7 @@
 			log.debug("end conversation:" + name);
 		}
 
-		synchronized(beans)
+		synchronized(this)
 		{
 			Iterator iterBeans = beans.keySet().iterator();
 			while (iterBeans.hasNext())
@@ -239,7 +239,7 @@
 	 */
 	public boolean hasAttribute(String name)
 	{
-		synchronized(beans)
+		synchronized(this)
 		{
 			return beans.containsKey(name);
 		}
@@ -250,7 +250,7 @@
 	 */
 	public Object getAttribute(String name)
 	{
-		synchronized(beans)
+		synchronized(this)
 		{
 			return beans.get(name);
 		}
@@ -265,7 +265,7 @@
 	 */
 	public Object removeAttribute(String name)
 	{
-		synchronized(beans)
+		synchronized(this)
 		{
 			Object bean = beans.remove(name);
 			if (bean instanceof ConversationBindingListener)

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationContext.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationContext.java?view=diff&rev=513214&r1=513213&r2=513214
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationContext.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationContext.java Wed Feb 28 23:41:06 2007
@@ -39,7 +39,6 @@
 	private final long id;
 	private final ConversationManager manager;
 
-	private final Object mutex = new Object();
 	private final Map conversations = new TreeMap();
 
 	private long lastAccess;
@@ -77,7 +76,7 @@
 	 */
 	protected void clear()
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			Conversation[] convArray = new Conversation[conversations.size()];
 			conversations.values().toArray(convArray);
@@ -97,7 +96,7 @@
 	 */
 	protected Conversation startConversation(String name)
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			touch();
 			Conversation conversation = (Conversation) conversations.get(name);
@@ -116,7 +115,7 @@
 	 */
 	protected void removeConversation(Conversation conversation)
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			touch();
 			conversations.remove(conversation.getName());
@@ -129,7 +128,7 @@
 	 */
 	protected void removeConversation(String name)
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			touch();
 			Conversation conversation = (Conversation) conversations.get(name);
@@ -145,7 +144,7 @@
 	 */
 	protected boolean hasConversations()
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			touch();
 			return conversations.size() > 0;
@@ -157,7 +156,7 @@
 	 */
 	protected boolean hasConversation(String name)
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			touch();
 			return conversations.get(name) != null;
@@ -169,7 +168,7 @@
 	 */
 	protected Conversation getConversation(String name)
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			touch();
 
@@ -185,7 +184,7 @@
 	 */
 	protected void checkConversationTimeout()
 	{
-		synchronized (mutex)
+		synchronized (this)
 		{
 			long timeToLive = 30 * 60 * 1000;
 			long checkTime = System.currentTimeMillis();

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringConversationScope.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringConversationScope.java?view=diff&rev=513214&r1=513213&r2=513214
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringConversationScope.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringConversationScope.java Wed Feb 28 23:41:06 2007
@@ -108,39 +108,40 @@
 		ConversationManager manager = ConversationManager.getInstance();
 
 		// check if we have a conversation
-		if (!manager.hasConversation(name))
+		synchronized(manager)
 		{
-			/*
-			if (!ConversationPhaseListener.isAutomaticConversationCreation())
+			if (!manager.hasConversation(name))
 			{
-				return null;
+				// start the conversation
+				manager.startConversation(name);
 			}
-			*/
-
-			// start the conversation
-			manager.startConversation(name);
 		}
 
 		// get the conversation
 		Conversation conversation = getConversationForBean(name);
-		if (!conversation.hasAttribute(name))
+		synchronized(conversation)
 		{
-			// create the bean (if not already done)
-			Object value = objectFactory.getObject();
-
-			if (advices != null && advices.length > 0)
+			if (!conversation.hasAttribute(name))
 			{
+				// create the bean (if not already done)
+				Object value = objectFactory.getObject();
+
 				ProxyFactory factory = new ProxyFactory(value);
 				factory.setProxyTargetClass(true);
 				factory.addAdvice(new CurrentConversationAdvice(conversation));
-				for (int i = 0; i < advices.length; i++)
+
+				if (advices != null && advices.length > 0)
 				{
-					factory.addAdvice(advices[i]);
+					for (int i = 0; i < advices.length; i++)
+					{
+						factory.addAdvice(advices[i]);
+					}
 				}
+
 				value = factory.getProxy();
-			}
 
-			conversation.setAttribute(name, value);
+				conversation.setAttribute(name, value);
+			}
 		}
 
 		// get the bean