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 2006/10/11 08:40:35 UTC

svn commit: r462713 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java

Author: imario
Date: Tue Oct 10 23:40:35 2006
New Revision: 462713

URL: http://svn.apache.org/viewvc?view=rev&rev=462713
Log:
switched from "nested conversations" to "parallel conversations", its not easily possible to deal with nested conversations without a clear external configuration and workflow. At least for 95% of all use-cases this should be good enough.

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java?view=diff&rev=462713&r1=462712&r2=462713
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java Tue Oct 10 23:40:35 2006
@@ -15,9 +15,7 @@
  */
 package org.apache.myfaces.custom.conversation;
 
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -32,7 +30,7 @@
 
 	private final Object mutex = new Object();
 	private final Map conversations = new TreeMap();
-	private final List conversationStack = new ArrayList(10);
+	// private final List conversationStack = new ArrayList(10);
 	private Conversation currentConversation;
 
 	private long lastAccess;
@@ -65,7 +63,7 @@
 			}
 
 			conversations.clear();
-			conversationStack.clear();
+			// conversationStack.clear();
 		}
 	}
 
@@ -84,19 +82,21 @@
 			{
 				conversation = new Conversation(name, persistence);
 				conversations.put(name, conversation);
-				conversationStack.add(conversation);
+				// conversationStack.add(conversation);
 			}
+			/*
 			else
 			{
 				endNestedConversations(conversation, false);
 			}
+			*/
 			currentConversation = conversation;
 		}
 	}
 
-	/**
+	/*
 	 * Ends all conversations nested under conversation
-	 */
+	 *
 	protected void endNestedConversations(Conversation conversation, boolean regularEnd)
 	{
 		synchronized (mutex)
@@ -115,6 +115,7 @@
 			}
 		}
 	}
+	*/
 
 	/**
 	 * End the given conversation
@@ -141,6 +142,7 @@
 			Conversation conversation = (Conversation) conversations.get(name);
 			if (conversation != null)
 			{
+				/*
 				while (conversationStack.size()>1)
 				{
 					Conversation dependingConversation = (Conversation) conversationStack.get(conversationStack.size()-1);
@@ -154,6 +156,7 @@
 						return;
 					}
 				}
+				*/
 				endConversation(conversation, regularEnd);
 			}
 		}
@@ -234,6 +237,7 @@
 		synchronized (mutex)
 		{
 			touch();
+			/*
 			for (int i = conversationStack.size(); i>0; i--)
 			{
 				Conversation conversation = (Conversation) conversationStack.get(i-1);
@@ -242,6 +246,16 @@
 					return conversation.getBean(name);
 				}
 			}
+			*/
+			Iterator iterConversations = conversations.values().iterator();
+			while (iterConversations.hasNext())
+			{
+				Conversation conversation = (Conversation) iterConversations.next();
+				if (conversation.hasBean(name))
+				{
+					return conversation.getBean(name);
+				}
+			}
 
 			return null;
 		}
@@ -255,6 +269,7 @@
 		synchronized (mutex)
 		{
 			touch();
+			/*
 			for (int i = conversationStack.size(); i>0; i--)
 			{
 				Conversation conversation = (Conversation) conversationStack.get(i-1);
@@ -263,6 +278,16 @@
 					return conversation.getPersistenceManager();
 				}
 			}
+			*/
+			Iterator iterConversations = conversations.values().iterator();
+			while (iterConversations.hasNext())
+			{
+				Conversation conversation = (Conversation) iterConversations.next();
+				if (conversation.isPersistence())
+				{
+					return conversation.getPersistenceManager();
+				}
+			}
 
 			return null;
 		}
@@ -276,6 +301,7 @@
 		synchronized (mutex)
 		{
 			touch();
+			/*
 			for (int i = conversationStack.size(); i>0; i--)
 			{
 				Conversation conversation = (Conversation) conversationStack.get(i-1);
@@ -284,6 +310,16 @@
 					conversation.getPersistenceManager().detach();
 				}
 			}
+			*/
+			Iterator iterConversations = conversations.values().iterator();
+			while (iterConversations.hasNext())
+			{
+				Conversation conversation = (Conversation) iterConversations.next();
+				if (conversation.isPersistence())
+				{
+					conversation.getPersistenceManager().detach();
+				}
+			}
 		}
 	}
 
@@ -295,6 +331,7 @@
 		synchronized (mutex)
 		{
 			touch();
+			/*
 			for (int i = conversationStack.size(); i>0; i--)
 			{
 				Conversation conversation = (Conversation) conversationStack.get(i-1);
@@ -303,6 +340,16 @@
 					conversation.getPersistenceManager().purge();
 				}
 			}
+			*/
+			Iterator iterConversations = conversations.values().iterator();
+			while (iterConversations.hasNext())
+			{
+				Conversation conversation = (Conversation) iterConversations.next();
+				if (conversation.isPersistence())
+				{
+					conversation.getPersistenceManager().purge();
+				}
+			}
 		}
 	}
 
@@ -314,9 +361,20 @@
 		synchronized (mutex)
 		{
 			touch();
+			/*
 			for (int i = conversationStack.size(); i>0; i--)
 			{
 				Conversation conversation = (Conversation) conversationStack.get(i-1);
+				if (conversation.isPersistence())
+				{
+					conversation.getPersistenceManager().attach();
+				}
+			}
+			*/
+			Iterator iterConversations = conversations.values().iterator();
+			while (iterConversations.hasNext())
+			{
+				Conversation conversation = (Conversation) iterConversations.next();
 				if (conversation.isPersistence())
 				{
 					conversation.getPersistenceManager().attach();