myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r511465 - in /myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation: ./ jsf/ jsf/components/ jsf/lib/ spring/
Date Sun, 25 Feb 2007 08:44:02 GMT
Author: imario
Date: Sun Feb 25 00:44:01 2007
New Revision: 511465

URL: http://svn.apache.org/viewvc?view=rev&rev=511465
Log:
polished api, added javadoc to the conversation framework

Added:
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingEvent.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java   (contents, props changed)
      - copied, changed from r510714, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationEndListener.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java   (contents, props changed)
      - copied, changed from r510714, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java   (contents, props changed)
      - copied, changed from r510714, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistentContextCloser.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/_SpringUtils.java
      - copied, changed from r511278, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringUtils.java
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/ConversationAware.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/ConversationManager.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationRequestParameterProvider.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/CurrentConversationAdvice.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/ConversationPhaseListener.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationActionListener.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationTag.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EndConversationTag.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EnsureConversationTag.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/SeparateConversationContextTag.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEndConversation.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEnsureConversation.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UISeparateConversationContext.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/lib/EndConversationMethodBindingFacade.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContext.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextConversationInterceptor.java
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextFactory.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=511465&r1=511464&r2=511465
==============================================================================
--- 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 Sun Feb 25 00:44:01 2007
@@ -27,7 +27,29 @@
 import java.util.TreeMap;
 
 /**
- * handle conversation related stuff like beans
+ * <p>
+ * The conversation object
+ * </p>
+ * <p>
+ * The container for all beans managed by this conversation.
+ * </p>
+ * <p>
+ * There is a (not yet configureable) timeout which is responsible to destory
+ * the conversation if it has not been accessed.
+ * </p>
+ * <p>
+ * Beans implementing the {@link ConversationBindingListener} will receive a message
+ * when removed from (e.g. during destroy) or added to the conversation
+ * </p>
+ * <p>
+ * There are various ways how to get access to the conversation:
+ * <ul>
+ * <li>{@link Conversation#getCurrentInstance} if you are within a conversation</li>
+ * <li>{@link ConversationManager#getConversation(String)}</li>
+ * <li>or by implementing the {@link ConversationAware} or {@link ConversationBindingListener}
+ * interface in your bean and get the {@link Conversation} from them.
+ * </ul>
+ * </p>
  *
  * @author imario@apache.org
  */
@@ -41,6 +63,8 @@
 
 	private final Map beans = new TreeMap();
 
+	private final ConversationManager manager;
+
 	private boolean invalid = false;
 	private boolean queueInvalid = false;
 
@@ -49,8 +73,9 @@
 	private Object activeCountMutex = new Object();
 	private int activeCount;
 
-	protected Conversation(String name)
+	protected Conversation(String name, ConversationManager manager)
 	{
+		this.manager = manager;
 		this.name = name;
 
 		if (log.isDebugEnabled())
@@ -66,15 +91,20 @@
 		lastAccess = System.currentTimeMillis();
 	}
 
+	/**
+	 * the system time in millis when this conversation has been accessed last
+	 */
 	public long getLastAccess()
 	{
 		return lastAccess;
 	}
 
 	/**
-	 * Add the given bean to the conversation scope
+	 * <p>Add the given bean to the conversation scope</p>
+	 * <p>This will fire a {@link ConversationBindingEvent} if the bean
+	 * implements the {@link ConversationBindingListener} interface</p> 
 	 */
-	public void setAttribute(String name, Object value)
+	public void setAttribute(String name, Object bean)
 	{
 		checkValid();
 
@@ -94,9 +124,18 @@
 			log.debug("put bean to conversation:" + name + "(bean=" + name + ")");
 		}
 
-		beans.put(name, value);
+		beans.put(name, bean);
+
+		if (bean instanceof ConversationBindingListener)
+		{
+			((ConversationBindingListener) bean).valueBound(
+				new ConversationBindingEvent(this, name));
+		}
 	}
 
+	/**
+	 * assert the conversation is valid
+	 */
 	protected void checkValid()
 	{
 		if (isInvalid())
@@ -113,6 +152,15 @@
 		return name;
 	}
 
+	/**
+	 * <p>Invalidate/End the conversation</p>
+	 * <p>
+	 * If you are within a conversation (the conversation is active) this
+	 * will just queue the destroy to the next possible time.
+	 * A conversation is active if you are within a method of one of the
+	 * beans within this scope.
+	 * </p>
+	 */
 	public void invalidate()
 	{
 		if (!isActive())
@@ -125,20 +173,26 @@
 		}
 	}
 
+	/**
+	 * return true if the conversation is invalid
+	 */
 	public boolean isInvalid()
 	{
 		return invalid;
 	}
 
+	/**
+	 * return true if the conversation has been queued to be invalidated
+	 */
 	boolean isQueueInvalid()
 	{
 		return queueInvalid;
 	}
 
 	/**
-	 * end this conversation <br />
+	 * destroy the conversation <br />
 	 * <ul>
-	 * <li>inform all beans implementing the {@link ConversationEndListener} about the conversation end</li>
+	 * <li>inform all beans implementing the {@link ConversationBindingListener} about the conversation end</li>
 	 * <li>free all beans</li>
 	 * </ul>
 	 */
@@ -151,33 +205,62 @@
 			log.debug("end conversation:" + name);
 		}
 
-		Iterator iterBeans = beans.values().iterator();
+		Iterator iterBeans = beans.entrySet().iterator();
 		while (iterBeans.hasNext())
 		{
-			Object bean = iterBeans.next();
-			if (bean instanceof ConversationEndListener)
+			Map.Entry entry = (Map.Entry) iterBeans.next();
+
+			String name = (String) entry.getKey();
+			Object bean = entry.getValue();
+
+			if (bean instanceof ConversationBindingListener)
 			{
-				((ConversationEndListener) bean).conversationEnded();
+				((ConversationBindingListener) bean).valueUnbound(
+					new ConversationBindingEvent(this, name));
 			}
 		}
 		beans.clear();
+
+		manager.removeConversation(getName());
 	}
 
+	/**
+	 * check if this conversation holds a specific attribute
+	 */
 	public boolean hasAttribute(String name)
 	{
 		return beans.containsKey(name);
 	}
 
+	/**
+	 * get a specific attribute
+	 */
 	public Object getAttribute(String name)
 	{
 		return beans.get(name);
 	}
 
-	public Object removeBean(String name)
+	/**
+	 * <p>remove a bean from the conversation.</p>
+	 * <p>
+	 * This will fire a {@link ConversationBindingEvent} if the bean implements the
+	 * {@link ConversationBindingListener} interface.
+	 * </p>
+	 */
+	public Object removeAttribute(String name)
 	{
-		return beans.remove(name);
+		Object bean = beans.remove(name);
+		if (bean instanceof ConversationBindingListener)
+		{
+			((ConversationBindingListener) bean).valueUnbound(
+				new ConversationBindingEvent(this, name));
+		}
+		return bean;
 	}
 
+	/**
+	 * get the current conversation
+	 */
 	public static Conversation getCurrentInstance()
 	{
 		Conversation conversation = (Conversation) CURRENT_CONVERSATION.get();
@@ -188,11 +271,17 @@
 		return conversation;
 	}
 
+	/**
+	 * sets the current conversation instance
+	 */
 	static void setCurrentInstance(Conversation conversation)
 	{
 		CURRENT_CONVERSATION.set(conversation);
 	}
 
+	/**
+	 * increase one to the "conversation active" counter
+	 */
 	void enterConversation()
 	{
 		synchronized (activeCountMutex)
@@ -201,6 +290,9 @@
 		}
 	}
 
+	/**
+	 * decrease one from the "conversation active" counter
+	 */
 	void leaveConversation()
 	{
 		synchronized (activeCountMutex)
@@ -209,6 +301,9 @@
 		}
 	}
 
+	/**
+	 * check if the conversation is active
+	 */
 	private boolean isActive()
 	{
 		synchronized (activeCountMutex)

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationAware.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationAware.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationAware.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationAware.java Sun Feb 25 00:44:01 2007
@@ -19,7 +19,15 @@
 
 package org.apache.myfaces.fusion.conversation;
 
+/**
+ * Beans implementing this interface will get the conversation object set
+ *
+ * @author imario@apache.org
+ */
 public interface ConversationAware
 {
+	/**
+	 * the conversation the bean implementing this interface belongs to
+	 */
 	public void setConversation(Conversation conversation);
 }

Added: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingEvent.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingEvent.java?view=auto&rev=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingEvent.java (added)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingEvent.java Sun Feb 25 00:44:01 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.fusion.conversation;
+
+/**
+ * Events of this type are sent to an object that implements the
+ * {@link org.apache.myfaces.fusion.conversation.ConversationBindingListener}
+ * interface
+ *
+ * @author imario@apache.org
+ */
+public class ConversationBindingEvent
+{
+	private final Conversation conversation;
+	private final String name;
+
+	protected ConversationBindingEvent(Conversation conversation, String name)
+	{
+		this.conversation = conversation;
+		this.name = name;
+	}
+
+	public Conversation getConversation()
+	{
+		return conversation;
+	}
+
+	public String getName()
+	{
+		return name;
+	}
+}

Copied: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java (from r510714, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationEndListener.java)
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java?view=diff&rev=511465&p1=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationEndListener.java&r1=510714&p2=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationEndListener.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java Sun Feb 25 00:44:01 2007
@@ -24,7 +24,15 @@
  *
  * @author imario@apache.org
  */
-public interface ConversationEndListener
+public interface ConversationBindingListener
 {
-	public void conversationEnded();
+	/**
+	 * the bean has been added to a conversation
+	 */
+	public void valueBound(ConversationBindingEvent event);
+	
+	/**
+	 * the bean has been removed from the conversation
+	 */
+	public void valueUnbound(ConversationBindingEvent event);
 }

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationBindingListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=511465&r1=511464&r2=511465
==============================================================================
--- 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 Sun Feb 25 00:44:01 2007
@@ -22,12 +22,15 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 
 /**
- * The ConversationContext handles all conversations within the current context
+ * <p>The ConversationContext handles all conversations within the current context</p>
+ * <p>
+ * Like the conversation this context has a timeout too which will end this context
+ * if not accessed within the given timeout.
+ * </p>
  *
  * @author imario@apache.org
  */
@@ -36,18 +39,23 @@
 	private final static Log log = LogFactory.getLog(ConversationContext.class);
 
 	private final long id;
+	private final ConversationManager manager;
 
 	private final Object mutex = new Object();
 	private final Map conversations = new TreeMap();
 
 	private long lastAccess;
 
-	protected ConversationContext(long id)
+	protected ConversationContext(ConversationManager manager, long id)
 	{
 		this.id = id;
+		this.manager = manager;
 		touch();
 	}
 
+	/**
+	 * the conversation context id
+	 */
 	public long getId()
 	{
 		return id;
@@ -58,19 +66,28 @@
 		lastAccess = System.currentTimeMillis();
 	}
 
+	/**
+	 * the system time in millis when this conversation has been accessed last
+	 */
 	public long getLastAccess()
 	{
 		return lastAccess;
 	}
 
+	/**
+	 * <p>shutdown the context</p>
+	 * <p>This will invalidate ALL conversations within this context</p>
+	 */
 	public void shutdownContext()
 	{
 		synchronized (mutex)
 		{
-			Iterator iterConversation = conversations.values().iterator();
-			while (iterConversation.hasNext())
+			Conversation[] convArray = new Conversation[conversations.size()];
+			conversations.values().toArray(convArray);
+
+			for (int i = 0 ; i<convArray.length; i++)
 			{
-				Conversation conversation = (Conversation) iterConversation.next();
+				Conversation conversation = convArray[i];
 				conversation.invalidate();
 			}
 
@@ -79,10 +96,7 @@
 	}
 
 	/**
-	 * Start a conversation if not already started.<br />
-	 * All nested conversations (if any) are closed if the conversation already existed.
-	 *
-	 * @param name
+	 * Start a conversation if not already started.
 	 */
 	public void startConversation(String name)
 	{
@@ -92,30 +106,30 @@
 			Conversation conversation = (Conversation) conversations.get(name);
 			if (conversation == null)
 			{
-				conversation = new Conversation(name);
+				conversation = new Conversation(name, manager);
 				conversations.put(name, conversation);
 			}
 		}
 	}
 
 	/**
-	 * End the given conversation
+	 * <p>remove the conversation from this context.</p>
+	 * <p>Notice: Its assumed that the conversation has already been invalidated</p>
 	 */
-	protected void endConversation(Conversation conversation)
+	protected void removeConversation(Conversation conversation)
 	{
 		synchronized (mutex)
 		{
 			touch();
-			conversation.invalidate();
 			conversations.remove(conversation.getName());
 		}
 	}
 
 	/**
-	 * End the conversation with given name.<br />
-	 * This also automatically closes all nested conversations.
+	 * <p>remove the conversation with the given name from this context.</p>
+	 * <p>Notice: Its assumed that the conversation has already been invalidated</p>
 	 */
-	public void endConversation(String name)
+	protected void removeConversation(String name)
 	{
 		synchronized (mutex)
 		{
@@ -123,7 +137,7 @@
 			Conversation conversation = (Conversation) conversations.get(name);
 			if (conversation != null)
 			{
-				endConversation(conversation);
+				removeConversation(conversation);
 			}
 		}
 	}
@@ -168,17 +182,22 @@
 		}
 	}
 
-	public void checkConversationTimeout()
+	/**
+	 * check the context and conversation timeouts
+	 */
+	protected void checkConversationTimeout()
 	{
 		synchronized (mutex)
 		{
 			long timeToLive = 30 * 60 * 1000;
 			long checkTime = System.currentTimeMillis();
 
-			Iterator iterConversations = conversations.values().iterator();
-			while (iterConversations.hasNext())
+			Conversation[] convArray = new Conversation[conversations.size()];
+			conversations.values().toArray(convArray);
+
+			for (int i = 0 ; i<convArray.length; i++)
 			{
-				Conversation conversation = (Conversation) iterConversations.next();
+				Conversation conversation = convArray[i];
 
 				if (conversation.getLastAccess() + timeToLive < checkTime)
 				{
@@ -188,7 +207,6 @@
 					}
 
 					conversation.invalidate();
-					iterConversations.remove();
 				}
 			}
 		}

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationManager.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationManager.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationManager.java Sun Feb 25 00:44:01 2007
@@ -21,7 +21,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.fusion.conversation.spring.SpringUtils;
+import org.apache.myfaces.fusion.conversation.spring._SpringUtils;
 import org.apache.myfaces.fusion.requestParameterProvider.RequestParameterProviderManager;
 import org.apache.myfaces.shared_fusion.util.ClassUtils;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -131,6 +131,9 @@
 		return conversationManager;
 	}
 
+	/**
+	 * create and initialize a new ConversationManager
+	 */
 	protected static ConversationManager createConversationManager()
 	{
 		ConversationManager conversationManager;
@@ -140,7 +143,7 @@
 
 		// initialize the messager
 		conversationManager.createMessager();
-		conversationManager.managedScopes = SpringUtils.getConversationManagedScopeNames();
+		conversationManager.managedScopes = _SpringUtils.getConversationManagedScopeNames();
 
 		return conversationManager;
 	}
@@ -223,7 +226,7 @@
 			ConversationContext conversationContext = (ConversationContext) conversationContexts.get(conversationContextId);
 			if (conversationContext == null)
 			{
-				conversationContext = new ConversationContext(conversationContextId.longValue());
+				conversationContext = new ConversationContext(this, conversationContextId.longValue());
 				conversationContexts.put(conversationContextId, conversationContext);
 			}
 
@@ -255,17 +258,19 @@
 	}
 
 	/**
-	 * End a conversation
+	 * Remove a conversation
+	 *
+	 * <p>Notice: Its assumed that the conversation has already been invalidated</p>
 	 *
-	 * @see ConversationContext#endConversation(String)
+	 * @see ConversationContext#removeConversation(String)
 	 */
-	public void endConversation(String name)
+	protected void removeConversation(String name)
 	{
 		Long conversationContextId = getConversationContextId();
 		ConversationContext conversationContext = getConversationContext(conversationContextId);
 		if (conversationContext != null)
 		{
-			conversationContext.endConversation(name);
+			conversationContext.removeConversation(name);
 		}
 	}
 
@@ -397,7 +402,7 @@
 	 */
 	public boolean isManagedBean(String beanName)
 	{
-		ConfigurableApplicationContext applicationContext = SpringUtils.getApplicationContext();
+		ConfigurableApplicationContext applicationContext = _SpringUtils.getApplicationContext();
 		ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
 
 		// XXX: Hack to get the real definition in case of scoped targets

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationRequestParameterProvider.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationRequestParameterProvider.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationRequestParameterProvider.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationRequestParameterProvider.java Sun Feb 25 00:44:01 2007
@@ -58,12 +58,12 @@
 
 	public String[] getFields()
 	{
-		/*
 		if (UISeparateConversationContext.isInSeparationMode())
 		{
 			return null;
 		}
 
+		/*
 		ConversationManager conversationManager = ConversationManager.getInstance();
 		if (conversationManager == null)
 		{

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/CurrentConversationAdvice.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/CurrentConversationAdvice.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/CurrentConversationAdvice.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/CurrentConversationAdvice.java Sun Feb 25 00:44:01 2007
@@ -22,6 +22,17 @@
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 
+/**
+ * <p>An advice which will be added to all conversation scoped beans.</p>
+ * <p>It will:
+ * <ul>
+ * <li>Maintain the {@link Conversation#getCurrentInstance()}</li>
+ * <li>End the conversation if it has been invalidated</li>
+ * </ul>
+ * </p>
+ *
+ * @author imario@apache.org
+ */
 public class CurrentConversationAdvice implements MethodInterceptor
 {
 	private final Conversation conversation;
@@ -48,7 +59,7 @@
 
 			if (conversation.isQueueInvalid())
 			{
-				ConversationManager.getInstance().endConversation(conversation.getName());
+				conversation.invalidate();
 			}
 
 			Conversation.setCurrentInstance(previous);

Copied: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java (from r510714, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java)
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java?view=diff&rev=511465&p1=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java&r1=510714&p2=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java Sun Feb 25 00:44:01 2007
@@ -26,12 +26,17 @@
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
 import java.util.Iterator;
 
-public class ConversationUtils
+/**
+ * <p>Various utilities used by the conversation framework</p>
+ * <p>Notice: this class is not meant to be used outside of this library</p>
+ *
+ * @author imario@apache.org
+ */
+public class _ConversationUtils
 {
-	private ConversationUtils()
+	private _ConversationUtils()
 	{
 	}
 
@@ -86,12 +91,6 @@
 		return null;
 	}
 
-	public static String extractBeanName(ValueBinding vb)
-	{
-		String valueBinding = vb.getExpressionString();
-		return valueBinding.substring(2, valueBinding.length() - 1);
-	}
-
 	/**
 	 * end and restart a conversation
 	 */
@@ -99,10 +98,12 @@
 	{
 		ConversationManager conversationManager = ConversationManager.getInstance(context);
 		Conversation conversation = conversationManager.getConversation(conversationName);
+		if (conversation != null)
+		{
+			conversation.invalidate();
+		}
 
-		conversationManager.endConversation(conversationName);
-
-		if (restart != null && restart.booleanValue() && conversation != null)
+		if (restart != null && restart.booleanValue())
 		{
 			conversationManager.startConversation(conversationName);
 

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/_ConversationUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/ConversationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/ConversationPhaseListener.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/ConversationPhaseListener.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/ConversationPhaseListener.java Sun Feb 25 00:44:01 2007
@@ -26,10 +26,18 @@
 import javax.faces.event.PhaseListener;
 import java.util.Map;
 
+/**
+ * <p>
+ * Initializes the Conversation system
+ * </p>
+ *
+ * @author imario@apache.org
+ */
 public class ConversationPhaseListener implements PhaseListener
 {
 	private final static String SYSTEM_INITIALIZED = ConversationPhaseListener.class.getName() + ".INITIALIZED";
 
+	/*
 	private final static ThreadLocal AUTOMATIC_CONVERSATION_CREATION = new ThreadLocal()
 	{
 		protected Object initialValue()
@@ -37,6 +45,7 @@
 			return Boolean.FALSE;
 		}
 	};
+	*/
 
 	public void afterPhase(PhaseEvent event)
 	{
@@ -48,11 +57,11 @@
 		{
 			initialize(event);
 
-			AUTOMATIC_CONVERSATION_CREATION.set(Boolean.FALSE);
+			// AUTOMATIC_CONVERSATION_CREATION.set(Boolean.FALSE);
 		}
 		else if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
 		{
-			AUTOMATIC_CONVERSATION_CREATION.set(Boolean.TRUE);
+			// AUTOMATIC_CONVERSATION_CREATION.set(Boolean.TRUE);
 		}
 	}
 
@@ -76,8 +85,10 @@
 		return PhaseId.ANY_PHASE;
 	}
 
+	/*
 	public static boolean isAutomaticConversationCreation()
 	{
 		return Boolean.TRUE.equals(AUTOMATIC_CONVERSATION_CREATION.get());
 	}
+	*/
 }

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationActionListener.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationActionListener.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationActionListener.java Sun Feb 25 00:44:01 2007
@@ -19,7 +19,7 @@
 
 package org.apache.myfaces.fusion.conversation.jsf.components;
 
-import org.apache.myfaces.fusion.conversation.ConversationUtils;
+import org.apache.myfaces.fusion.conversation._ConversationUtils;
 
 import javax.faces.component.StateHolder;
 import javax.faces.context.FacesContext;
@@ -28,7 +28,7 @@
 import javax.faces.event.ActionListener;
 
 /**
- * base class to handle actions events
+ * base class to handle action events
  *
  * @author imario@apache.org
  */
@@ -52,8 +52,6 @@
 
 	/**
 	 * set the conversation name this listener should be associated to
-	 *
-	 * @param conversationName
 	 */
 	public void setConversationName(String conversationName)
 	{
@@ -87,7 +85,7 @@
 
 	public void processAction(ActionEvent actionEvent) throws AbortProcessingException
 	{
-		AbstractConversationComponent startOrEndconversation = ConversationUtils.findEndConversationComponent(actionEvent.getComponent(), getConversationName());
+		AbstractConversationComponent startOrEndconversation = _ConversationUtils.findEndConversationComponent(actionEvent.getComponent(), getConversationName());
 
 		doConversationAction(startOrEndconversation);
 	}

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationTag.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationTag.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationTag.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/AbstractConversationTag.java Sun Feb 25 00:44:01 2007
@@ -26,7 +26,7 @@
 /**
  * base class for all conversation tags
  *
- * @author im
+ * @author imario@apache.org
  */
 public abstract class AbstractConversationTag extends UIComponentTagBase
 {

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EndConversationTag.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EndConversationTag.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EndConversationTag.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EndConversationTag.java Sun Feb 25 00:44:01 2007
@@ -23,8 +23,9 @@
 import javax.faces.el.MethodBinding;
 
 /**
- * Ends a conversation
+ * End a conversation.
  *
+ * @see org.apache.myfaces.fusion.conversation.jsf.components.UIEndConversation
  * @author imario@apache.org
  */
 public class EndConversationTag extends AbstractConversationTag

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EnsureConversationTag.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EnsureConversationTag.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EnsureConversationTag.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/EnsureConversationTag.java Sun Feb 25 00:44:01 2007
@@ -22,15 +22,14 @@
 import javax.faces.component.UIComponent;
 
 /**
- * Checks if a conversation is active, else redirects to another view
+ * Check if a conversation is active, else redirects issue a navigation
  *
+ * @see org.apache.myfaces.fusion.conversation.jsf.components.UIEnsureConversation
  * @author imario@apache.org
  */
 public class EnsureConversationTag extends AbstractConversationTag
 {
-	private String redirectTo;
 	private String action;
-	private String preCheck;
 
 	public String getComponentType()
 	{
@@ -41,19 +40,7 @@
 	{
 		super.setProperties(component);
 
-		setStringProperty(component, "redirectTo", getRedirectTo());
 		setActionProperty(component, getAction());
-		setBooleanProperty(component, "preCheck", getPreCheck());
-	}
-
-	public String getRedirectTo()
-	{
-		return redirectTo;
-	}
-
-	public void setRedirectTo(String redirectTo)
-	{
-		this.redirectTo = redirectTo;
 	}
 
 	public String getAction()
@@ -64,15 +51,5 @@
 	public void setAction(String action)
 	{
 		this.action = action;
-	}
-
-	public String getPreCheck()
-	{
-		return preCheck;
-	}
-
-	public void setPreCheck(String preCheck)
-	{
-		this.preCheck = preCheck;
 	}
 }

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/SeparateConversationContextTag.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/SeparateConversationContextTag.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/SeparateConversationContextTag.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/SeparateConversationContextTag.java Sun Feb 25 00:44:01 2007
@@ -22,8 +22,9 @@
 import org.apache.myfaces.shared_fusion.taglib.UIComponentTagBase;
 
 /**
- * Ends a conversation
+ * Embedded links will start a new conversation context
  *
+ * @see org.apache.myfaces.fusion.conversation.jsf.components.UISeparateConversationContext
  * @author imario@apache.org
  */
 public class SeparateConversationContextTag extends UIComponentTagBase

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEndConversation.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEndConversation.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEndConversation.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEndConversation.java Sun Feb 25 00:44:01 2007
@@ -19,7 +19,7 @@
 
 package org.apache.myfaces.fusion.conversation.jsf.components;
 
-import org.apache.myfaces.fusion.conversation.ConversationUtils;
+import org.apache.myfaces.fusion.conversation._ConversationUtils;
 import org.apache.myfaces.fusion.conversation.jsf.lib.EndConversationMethodBindingFacade;
 import org.apache.myfaces.shared_fusion.util.StringUtils;
 
@@ -32,7 +32,34 @@
 import java.util.Collection;
 
 /**
- * end a conversation
+ * <p>
+ * End a conversation
+ * </p>
+ *
+ * <p>
+ * This will end a conversation AFTER the method invoked by the parent component.<br />
+ * The common use for this tag is to be put as child into a commandLink or commandButton.
+ * <pre>
+ * &lt;h:commandLink action="#{backing.saveAction}"&gt;
+ *     &lt;n:endConversationTag onOutcome="success" /&gt;
+ * &lt;/h:commandLink&gt;
+ * </pre>
+ * </p>
+ *
+ * <p>
+ * The various parameter are:
+ * <ul>
+ * <li>onOutcome<br />
+ * end the conversation only if the method returns a specific outcome</li>
+ * <li>errorOutcome<br />
+ * in case of an exception, use the given outcome as new outcome so you can issue a navigation
+ * instead of the default errorPage</li>
+ * <li>restart<br />
+ * true|false - automatically restart the conversation</li>
+ * <li>restartAction<br />
+ * a restart action to issue after the conversation has been restarted</li>
+ * </ul>
+ * </p>
  *
  * @author imario@apache.org
  */
@@ -47,30 +74,15 @@
 
 	private boolean inited = false;
 
-	/*
-	public static class ConversationEndAction extends AbstractConversationActionListener
-	{
-		public void doConversationAction(AbstractConversationComponent abstractConversationComponent)
-		{
-			ConversationManager.getInstance().registerEndConversation(getConversationName());
-		}
-	}
-	*/
-
 	public void encodeBegin(FacesContext context) throws IOException
 	{
 		super.encodeBegin(context);
 
-		UICommand command = ConversationUtils.findParentCommand(this);
+		UICommand command = _ConversationUtils.findParentCommand(this);
 		if (command != null)
 		{
 			if (!inited)
 			{
-				/*
-				ConversationEndAction actionListener = new ConversationEndAction();
-				actionListener.setConversationName(getName());
-				command.addActionListener(actionListener);
-				*/
 				MethodBinding original = command.getAction();
 				command.setAction(new EndConversationMethodBindingFacade(
 					getName(),
@@ -84,7 +96,7 @@
 		}
 		else
 		{
-			ConversationUtils.endAndRestartConversation(context,
+			_ConversationUtils.endAndRestartConversation(context,
 				getName(),
 				getRestart(),
 				getRestartAction());

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEnsureConversation.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEnsureConversation.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEnsureConversation.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UIEnsureConversation.java Sun Feb 25 00:44:01 2007
@@ -22,7 +22,6 @@
 import org.apache.myfaces.fusion.conversation.ConversationManager;
 
 import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
 import java.io.IOException;
 
 /**
@@ -31,7 +30,20 @@
  * </p>
  * <p/>
  * The way this is done here is sub-optimal, once we are on jsf 1.2 it should be possible to
- * check this before ANY rendering - and maybe to invoke a navigation then
+ * check this before ANY rendering
+ * </p>
+ * <p>
+ * Notice: This will issue a navigation, so you have to ensure this tag is one of the first
+ * tags (if not the first) after <code>f:view</code> and that no html has been sent to the
+ * client already, else the redirect request cant be sent.
+ * </p>
+ *
+ * <p>
+ * The parameters are:
+ * <ul>
+ * <li>name<br>the conversation name</li>
+ * <li>action<br>the action or an method binding</li> 
+ * </ul>
  * </p>
  *
  * @author imario@apache.org
@@ -40,9 +52,6 @@
 {
 	public static final String COMPONENT_TYPE = "org.apache.myfaces.EnsureConversation";
 
-	private String redirectTo;
-	private Boolean preCheck;
-
 	public void encodeBegin(FacesContext context) throws IOException
 	{
 		super.encodeBegin(context);
@@ -64,30 +73,11 @@
 		}
 	}
 
-	public void restoreState(FacesContext context, Object state)
-	{
-		Object[] states = (Object[]) state;
-
-		super.restoreState(context, states[0]);
-		redirectTo = (String) states[1];
-		preCheck = (Boolean) states[2];
-	}
-
-	public Object saveState(FacesContext context)
-	{
-		return new Object[]
-			{
-				super.saveState(context),
-				redirectTo,
-				preCheck
-			};
-	}
-
 	protected void checkConversation(FacesContext context, String name) throws IOException
 	{
 		ConversationManager conversationManager = ConversationManager.getInstance();
 
-		if (Boolean.TRUE.equals(preCheck))
+		if (!conversationManager.hasConversation(name))
 		{
 			String actionResult = (String) getAction().invoke(context, null);
 			if (actionResult == null)
@@ -95,64 +85,10 @@
 				// no further action, maybe the user started a conversation
 				return;
 			}
-
 			conversationManager.getMessager().setConversationNotActive(context, getName());
-			return;
-		}
-		else if (!conversationManager.hasConversation(name))
-		{
-			if (getAction() != null)
-			{
-				String actionResult = (String) getAction().invoke(context, null);
-				if (actionResult == null)
-				{
-					// no further action, maybe the user started a conversation
-					return;
-				}
-				conversationManager.getMessager().setConversationNotActive(context, getName());
 
-				// hopefully the user configured the navigation as redirect ...
-				context.getApplication().getNavigationHandler().handleNavigation(context, null, actionResult);
-			}
-			else
-			{
-				conversationManager.getMessager().setConversationNotActive(context, getName());
-
-				String actionUrl = context.getApplication().getViewHandler().getActionURL(
-					context, getRedirectTo());
-				String encodedActionUrl = context.getExternalContext().encodeActionURL(actionUrl);
-
-				/* XXX: figure out a way to avoid this - or do this again
-				RedirectTrackerManager manager = RedirectTrackerManager.getInstance(context);
-				if (manager != null)
-				{
-					encodedActionUrl = manager.trackRedirect(context, encodedActionUrl);
-				}
-				*/
-
-				context.getExternalContext().redirect(encodedActionUrl);
-			}
-
-			return;
-		}
-	}
-
-	public String getRedirectTo()
-	{
-		if (redirectTo != null)
-		{
-			return redirectTo;
-		}
-		ValueBinding vb = getValueBinding("redirectTo");
-		if (vb == null)
-		{
-			return null;
+			// hopefully the user configured the navigation as redirect ...
+			context.getApplication().getNavigationHandler().handleNavigation(context, null, actionResult);
 		}
-		return (String) vb.getValue(getFacesContext());
-	}
-
-	public void setRedirectTo(String redirectTo)
-	{
-		this.redirectTo = redirectTo;
 	}
 }

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UISeparateConversationContext.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UISeparateConversationContext.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UISeparateConversationContext.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/components/UISeparateConversationContext.java Sun Feb 25 00:44:01 2007
@@ -26,8 +26,11 @@
 import java.io.IOException;
 
 /**
- * separate the current context from the to be rendered children.
- * E.g. when you render commandLinks they will start a new conversationContext
+ * <p>Embedded links will start a new conversation context</p>
+ * <p>
+ * This will allow you to start a completely new context for conversations which
+ * is the base for multi window awareness.
+ * </p>
  *
  * @author imario@apache.org
  */

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/lib/EndConversationMethodBindingFacade.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/lib/EndConversationMethodBindingFacade.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/lib/EndConversationMethodBindingFacade.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/jsf/lib/EndConversationMethodBindingFacade.java Sun Feb 25 00:44:01 2007
@@ -20,7 +20,7 @@
 package org.apache.myfaces.fusion.conversation.jsf.lib;
 
 import org.apache.myfaces.fusion.conversation.ConversationManager;
-import org.apache.myfaces.fusion.conversation.ConversationUtils;
+import org.apache.myfaces.fusion.conversation._ConversationUtils;
 
 import javax.faces.FacesException;
 import javax.faces.component.StateHolder;
@@ -126,7 +126,7 @@
 
 				if (end)
 				{
-					ConversationUtils.endAndRestartConversation(context, conversationName, restart, restartAction);
+					_ConversationUtils.endAndRestartConversation(context, conversationName, restart, restartAction);
 				}
 			}
 		}

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContext.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContext.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContext.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContext.java Sun Feb 25 00:44:01 2007
@@ -19,11 +19,26 @@
 
 package org.apache.myfaces.fusion.conversation.spring;
 
+/**
+ * Interface which will be used by the {@link PersistenceContextConversationInterceptor}
+ * to configure the spring persistence framework
+ *
+ * @author imario@apache.org
+ */
 public interface PersistenceContext
 {
+	/**
+	 * bind the persistence e.g. to the current thread
+	 */
 	public void bind();
 
+	/**
+	 * unbind the persistence
+	 */
 	public void unbind();
 
+	/**
+	 * close the persistence, e.g. a underlaying session will be closed
+	 */
 	public void close();
 }

Copied: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java (from r510714, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistentContextCloser.java)
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java?view=diff&rev=511465&p1=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistentContextCloser.java&r1=510714&p2=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistentContextCloser.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java Sun Feb 25 00:44:01 2007
@@ -19,13 +19,14 @@
 
 package org.apache.myfaces.fusion.conversation.spring;
 
-import org.apache.myfaces.fusion.conversation.ConversationEndListener;
+import org.apache.myfaces.fusion.conversation.ConversationBindingListener;
+import org.apache.myfaces.fusion.conversation.ConversationBindingEvent;
 
-public class PersistentContextCloser implements ConversationEndListener
+public class PersistenceContextCloser implements ConversationBindingListener
 {
 	private final PersistenceContext persistenceContext;
 
-	public PersistentContextCloser(PersistenceContext persistenceContext)
+	public PersistenceContextCloser(PersistenceContext persistenceContext)
 	{
 		this.persistenceContext = persistenceContext;
 	}
@@ -35,7 +36,11 @@
 		return persistenceContext;
 	}
 
-	public void conversationEnded()
+	public void valueBound(ConversationBindingEvent event)
+	{
+	}
+
+	public void valueUnbound(ConversationBindingEvent event)
 	{
 		persistenceContext.close();
 	}

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextCloser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextConversationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextConversationInterceptor.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextConversationInterceptor.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextConversationInterceptor.java Sun Feb 25 00:44:01 2007
@@ -23,6 +23,21 @@
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.myfaces.fusion.conversation.Conversation;
 
+/**
+ * <p>
+ * Maintain the persistence state
+ * </p>
+ *
+ * <p>
+ * The interceptor will create a new persistenceContext using the
+ * {@link PersistenceContextFactory} if none exists.<br />
+ * It will also bind/unbind it if required.<br />
+ * The {@link PersistenceContext} will be put into the conversation
+ * attribute map wrapped in an {@link PersistenceContextCloser} so that it will
+ * close the {@link PersistenceContext} on conversation end  
+ *
+ * @author imario@apache.org
+ */
 public class PersistenceContextConversationInterceptor implements MethodInterceptor
 {
 	private final static String SESSION_ATTRIBUTE = "SESSION_ATTRIBUTE";
@@ -45,7 +60,7 @@
 		Conversation conversation = Conversation.getCurrentInstance();
 		if (conversation != null)
 		{
-			PersistentContextCloser persistenceContextCloser = (PersistentContextCloser) conversation.getAttribute(SESSION_ATTRIBUTE);
+			PersistenceContextCloser persistenceContextCloser = (PersistenceContextCloser) conversation.getAttribute(SESSION_ATTRIBUTE);
 			if (persistenceContextCloser != null)
 			{
 				persistenceContext = persistenceContextCloser.getPersistenceContext();
@@ -55,7 +70,7 @@
 			{
 				persistenceContext = persistenceContextFactory.create();
 
-				conversation.setAttribute(SESSION_ATTRIBUTE, new PersistentContextCloser(persistenceContext));
+				conversation.setAttribute(SESSION_ATTRIBUTE, new PersistenceContextCloser(persistenceContext));
 			}
 		}
 

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextFactory.java?view=diff&rev=511465&r1=511464&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextFactory.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/PersistenceContextFactory.java Sun Feb 25 00:44:01 2007
@@ -19,6 +19,11 @@
 
 package org.apache.myfaces.fusion.conversation.spring;
 
+/**
+ * The factory is responsible for creating a {@link PersistenceContext}
+ *
+ * @author imario@apache.org
+ */
 public interface PersistenceContextFactory
 {
 	public PersistenceContext create();

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=511465&r1=511464&r2=511465
==============================================================================
--- 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 Sun Feb 25 00:44:01 2007
@@ -22,10 +22,10 @@
 import org.aopalliance.aop.Advice;
 import org.apache.myfaces.fusion.conversation.Conversation;
 import org.apache.myfaces.fusion.conversation.ConversationAware;
-import org.apache.myfaces.fusion.conversation.ConversationEndListener;
+import org.apache.myfaces.fusion.conversation.ConversationBindingListener;
 import org.apache.myfaces.fusion.conversation.ConversationManager;
 import org.apache.myfaces.fusion.conversation.CurrentConversationAdvice;
-import org.apache.myfaces.fusion.conversation.jsf.ConversationPhaseListener;
+import org.apache.myfaces.fusion.conversation.ConversationBindingEvent;
 import org.springframework.aop.framework.ProxyFactory;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
@@ -38,7 +38,37 @@
 import javax.faces.context.FacesContext;
 
 /**
- * adapts the conversation scope to a new spring scope
+ * <p>adapts the conversation scope to a new spring scope</p>
+ * <p>It will also apply any advice configured</p>
+ * <p>A sample configuration for a conversation scope with persistence
+ * <pre>
+ * 	&lt;bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"&gt;
+		&lt;property name="scopes"&gt;
+			&lt;map&gt;
+				&lt;entry key="conversation"&gt;
+					&lt;bean class="org.apache.myfaces.fusion.conversation.spring.SpringConversationScope"&gt;
+						&lt;property name="advices"&gt;
+							&lt;list&gt;
+								&lt;ref bean="persistentContextConversationInterceptor" /&gt;
+							&lt;/list&gt;
+						&lt;/property&gt;
+					&lt;/bean&gt;
+				&lt;/entry&gt;
+			&lt;/map&gt;
+		&lt;/property&gt;
+	&lt;/bean&gt;
+
+	&lt;bean id="persistentContextConversationInterceptor" class="org.apache.myfaces.fusion.conversation.spring.PersistenceContextConversationInterceptor"&gt;
+		&lt;property name="persistenceContextFactory" ref="yourPersistentContextFactory" /&gt;
+	&lt;/bean&gt;
+ * </pre>
+ * </p>
+ * <p>
+ * If no conversation exists for the given bean name a new one will be created.<br />
+ * The beanName will also be the conversation name.
+ * </p>
+ *
+ * @author imario@apache.org
  */
 public class SpringConversationScope implements Scope, BeanFactoryAware
 {
@@ -48,11 +78,17 @@
 	{
 	}
 
+	/**
+	 * the advices which will be applied to the conversation scoped bean 
+	 */
 	public void setAdvices(Advice[] advices)
 	{
 		this.advices = advices;
 	}
 
+	/**
+	 * return the conversation context id 
+	 */
 	public String getConversationId()
 	{
 		FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -81,10 +117,12 @@
 		// check if we have a conversation
 		if (!manager.hasConversation(name))
 		{
+			/*
 			if (!ConversationPhaseListener.isAutomaticConversationCreation())
 			{
 				return null;
 			}
+			*/
 
 			// start the conversation
 			manager.startConversation(name);
@@ -116,6 +154,10 @@
 		return conversation.getAttribute(name);
 	}
 
+	/**
+	 * set the {@link Conversation} object to the bean if it implements the
+	 * {@link ConversationAware} interface
+	 */
 	public void setBeanFactory(BeanFactory beanFactory) throws BeansException
 	{
 		((ConfigurableBeanFactory) beanFactory).addBeanPostProcessor(
@@ -141,6 +183,9 @@
 		);
 	}
 
+	/**
+	 * get the conversation for the given beanName  
+	 */
 	protected Conversation getConversationForBean(String beanName)
 	{
 		FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -150,7 +195,9 @@
 	}
 
 	/**
-	 * strip off any spring namespace.
+	 * strip off any spring namespace. (e.g. scopedTarget.)
+	 * This method will simply strip off anything before the first
+	 * dot.
 	 */
 	protected String buildBeanName(String name)
 	{
@@ -159,7 +206,7 @@
 			return null;
 		}
 
-		int pos = name.lastIndexOf('.');
+		int pos = name.indexOf('.');
 		if (pos < 0)
 		{
 			return name;
@@ -173,14 +220,23 @@
 		throw new UnsupportedOperationException();
 	}
 
+	/**
+	 * add the given runnable wrapped within an {@link ConversationBindingListener} to
+	 * the conversation map.
+	 * That way it will be called during conversation destroy. 
+	 */
 	public void registerDestructionCallback(String name, final Runnable runnable)
 	{
 		Conversation conversation = getConversationForBean(name);
 		conversation.setAttribute(
 			runnable.getClass().getName() + "@" + System.identityHashCode(runnable),
-			new ConversationEndListener()
+			new ConversationBindingListener()
 			{
-				public void conversationEnded()
+				public void valueBound(ConversationBindingEvent event)
+				{
+				}
+
+				public void valueUnbound(ConversationBindingEvent event)
 				{
 					runnable.run();
 				}

Copied: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/_SpringUtils.java (from r511278, myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringUtils.java)
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/_SpringUtils.java?view=diff&rev=511465&p1=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringUtils.java&r1=511278&p2=myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/_SpringUtils.java&r2=511465
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/SpringUtils.java (original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/spring/_SpringUtils.java Sun Feb 25 00:44:01 2007
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.myfaces.fusion.conversation.spring;
 
 import org.springframework.context.ConfigurableApplicationContext;
@@ -10,15 +28,21 @@
 import java.util.Set;
 import java.util.TreeSet;
 
-public final class SpringUtils
+/**
+ * <p>Various Spring utilities used by the conversation framework</p>
+ * <p>Notice: this class is not meant to be used outside of this library</p>
+ *
+ * @author imario@apache.org
+ */
+public final class _SpringUtils
 {
-	private SpringUtils()
+	private _SpringUtils()
 	{
 	}
 
 	public static ConfigurableApplicationContext getApplicationContext()
 	{
-		// TODO: How about portlets ?
+		// TODO: What about portlets ?
 		ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
 		
 		return (ConfigurableApplicationContext) WebApplicationContextUtils.getWebApplicationContext(servletContext);



Mime
View raw message