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/09/07 16:56:11 UTC

svn commit: r573600 - in /myfaces/orchestra/trunk: core/src/main/java/org/apache/myfaces/orchestra/conversation/ core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/ core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/lib/ cor...

Author: imario
Date: Fri Sep  7 07:56:09 2007
New Revision: 573600

URL: http://svn.apache.org/viewvc?rev=573600&view=rev
Log:
renamed the DefaultConversatoinMessager, moved it around.
slightly changed its interface to get rid of the faces-context parameter
minor fixes regarding the drop of the policy stuff

Added:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/JsfConversationMessager.java   (contents, props changed)
      - copied, changed from r573561, myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/DefaultConversationMessager.java
Removed:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/DefaultConversationMessager.java
Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationMessager.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/FlashScopePhaseListener.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/lib/EndConversationMethodBindingFacade.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/spring/SpringViewControllerScope.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractAnnotationsViewControllerManager.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/PlainAnnotationsViewControllerManager.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java Fri Sep  7 07:56:09 2007
@@ -19,20 +19,21 @@
 
 package org.apache.myfaces.orchestra.conversation;
 
-import java.io.IOException;
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.orchestra.conversation.jsf.JsfConversationMessager;
 import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
 import org.apache.myfaces.orchestra.lib.OrchestraException;
 import org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterProviderManager;
 import org.apache.myfaces.shared_orchestra.util.ClassUtils;
 
+import java.io.IOException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 /**
  * The manager will deal with the various contexts in the current session.
  * A new context will be created if the current window has none associated.
@@ -208,7 +209,7 @@
 	/**
 	 * Start a conversation
 	 *
-	 * @see ConversationContext#startConversation(String, ConversationPolicy)
+	 * @see ConversationContext#startConversation(String, ConversationFactory)
 	 */
 	public Conversation startConversation(String name, ConversationFactory factory)
 	{
@@ -322,7 +323,7 @@
 		String conversationMessagerName = FrameworkAdapter.getInstance().getInitParameter(INIT_MESSAGER);
 		if (conversationMessagerName == null)
 		{
-			conversationMessager = new DefaultConversationMessager();
+			conversationMessager = new JsfConversationMessager();
 		}
 		else
 		{

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationMessager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationMessager.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationMessager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationMessager.java Fri Sep  7 07:56:09 2007
@@ -19,8 +19,6 @@
 
 package org.apache.myfaces.orchestra.conversation;
 
-import javax.faces.context.FacesContext;
-
 /**
  * Methods required to inform the user about some anomalies.
  * <p>
@@ -36,10 +34,10 @@
 	/**
 	 * An exception happened, for example during invalidate action.
 	 */
-	public void setConversationException(FacesContext context, Throwable t);
+	public void setConversationException(Throwable t);
 
 	/**
 	 * Display message about a not active conversation (close before the redirect).
 	 */
-	public void setConversationNotActive(FacesContext context, String name);
+	public void setConversationNotActive(String name);
 }

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/FlashScopePhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/FlashScopePhaseListener.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/FlashScopePhaseListener.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/FlashScopePhaseListener.java Fri Sep  7 07:56:09 2007
@@ -20,7 +20,7 @@
 package org.apache.myfaces.orchestra.conversation.jsf;
 
 import org.apache.myfaces.orchestra.conversation.Conversation;
-import org.apache.myfaces.orchestra.conversation.ConversationFlashScopeAspect;
+import org.apache.myfaces.orchestra.conversation.ConversationFlashLifetimeAspect;
 import org.apache.myfaces.orchestra.conversation.ConversationManager;
 import org.apache.myfaces.orchestra.conversation.FlashScopeManager;
 
@@ -53,7 +53,7 @@
 	}
 
 	/**
-	 * invalidates any conversation with policy {@link org.apache.myfaces.orchestra.conversation.spring.ConversationPolicy#FLASH}
+	 * invalidates any conversation with aspect {@link ConversationFlashLifetimeAspect}
 	 * not accessed during a http request
 	 * @param viewId
 	 */
@@ -89,9 +89,9 @@
 		while (iterConversations.hasNext())
 		{
 			Conversation conversation = (Conversation) iterConversations.next();
-			ConversationFlashScopeAspect aspect =
-				(ConversationFlashScopeAspect)
-					conversation.getAspect(ConversationFlashScopeAspect.class);
+			ConversationFlashLifetimeAspect aspect =
+				(ConversationFlashLifetimeAspect)
+					conversation.getAspect(ConversationFlashLifetimeAspect.class);
 
 			if (aspect != null && !aspect.isAccessed())
 			{

Copied: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/JsfConversationMessager.java (from r573561, myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/DefaultConversationMessager.java)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/JsfConversationMessager.java?p2=myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/JsfConversationMessager.java&p1=myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/DefaultConversationMessager.java&r1=573561&r2=573600&rev=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/DefaultConversationMessager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/JsfConversationMessager.java Fri Sep  7 07:56:09 2007
@@ -17,7 +17,9 @@
  * under the License.
  */
 
-package org.apache.myfaces.orchestra.conversation;
+package org.apache.myfaces.orchestra.conversation.jsf;
+
+import org.apache.myfaces.orchestra.conversation.ConversationMessager;
 
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
@@ -29,19 +31,19 @@
  * <p>
  * As required by the ConversationMessager interface, all methods on this class are thread-safe.
  */
-public class DefaultConversationMessager implements ConversationMessager
+public class JsfConversationMessager implements ConversationMessager
 {
-	public void setConversationException(FacesContext context, Throwable t)
+	public void setConversationException(Throwable t)
 	{
-		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, t.getLocalizedMessage(), getThrowableText(t)));
+		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, t.getLocalizedMessage(), getThrowableText(t)));
 	}
 
-	public void setConversationNotActive(FacesContext context, String name)
+	public void setConversationNotActive(String name)
 	{
 		String message = "Conversation not active";
 		String messageDtl = "Conversation not active. Please start over. (Conversation Name:" + name + ")";
 
-		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, messageDtl));
+		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, messageDtl));
 	}
 
 	protected String getThrowableText(Throwable t)

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/JsfConversationMessager.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/lib/EndConversationMethodBindingFacade.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/lib/EndConversationMethodBindingFacade.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/lib/EndConversationMethodBindingFacade.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/lib/EndConversationMethodBindingFacade.java Fri Sep  7 07:56:09 2007
@@ -36,7 +36,7 @@
  * <p>
  * This class implements MethodBinding, ie represents an EL expression string that specifies
  * a method to call. It is expected to be used when invoking action methods when the current
- * conversation should be closed upon success of the action. 
+ * conversation should be closed upon success of the action.
  * <p>
  * This facade also enhances error-handling for action methods. If the invoked method throws
  * an exception of any kind, and an errorOutcome value has been specified then the errorOutcome
@@ -63,23 +63,23 @@
 
 	/**
 	 * Constructor.
-	 * 
+	 *
 	 * @param conversation is the name of the conversation to conditionally be closed.
-	 * 
+	 *
 	 * @param onOutcomes is a collection of navigation strings that may be returned from the
 	 * invoked method. If the returned value <i>is</i> in this list then the named conversation
 	 * is ended (and possibly restarted), ie all beans currently in the conversation are discarded.
 	 * If the returned value is not in this list then the conversation is not affected.
-	 * 
+	 *
 	 * @param original is the EL expression to be invoked.
-	 * 
+	 *
 	 * @param errorOutcome is a JSF navigation string to be returned if the action method
 	 * throws an exception of any kind. Note that in this situation the conversation is
 	 * never ended.
-	 * 
+	 *
 	 * @param restart determines whether the conversation will be restarted when the value
 	 * returned matches an onOutcome. Null and false both mean "do not restart".
-	 * 
+	 *
 	 * @param restartAction is an optional EL expression string to be invoked when restarting
 	 * a conversation. This is ignored unless restart=true.
 	 */
@@ -137,7 +137,7 @@
 
 			if (errorOutcome != null)
 			{
-				conversationManager.getMessager().setConversationException(context, t);
+				conversationManager.getMessager().setConversationException(t);
 
 				returnValue = errorOutcome;
 			}

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/spring/SpringViewControllerScope.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/spring/SpringViewControllerScope.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/spring/SpringViewControllerScope.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/spring/SpringViewControllerScope.java Fri Sep  7 07:56:09 2007
@@ -19,15 +19,15 @@
 
 package org.apache.myfaces.orchestra.viewController.spring;
 
-import javax.faces.context.FacesContext;
-
 import org.apache.myfaces.orchestra.conversation.Conversation;
-import org.apache.myfaces.orchestra.conversation.ConversationManager;
+import org.apache.myfaces.orchestra.conversation.ConversationContext;
 import org.apache.myfaces.orchestra.conversation.spring.AbstractSpringOrchestraScope;
 import org.apache.myfaces.orchestra.lib.OrchestraException;
 import org.apache.myfaces.orchestra.viewController.ViewControllerManager;
 import org.apache.myfaces.orchestra.viewController._ViewControllerUtils;
 
+import javax.faces.context.FacesContext;
+
 /**
  * provides a dummy scope which will place a bean configured for into the same conversation as the
  * viewController.
@@ -38,7 +38,7 @@
 	{
 	}
 
-	protected Conversation startConversation(ConversationManager manager, String conversationName)
+	public Conversation createConversation(ConversationContext context, String conversationName)
 	{
 		throw new IllegalStateException("the viewController scope is not supposed to start a conversation on its own. conversation to start: " + conversationName);
 	}

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractAnnotationsViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractAnnotationsViewControllerManager.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractAnnotationsViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractAnnotationsViewControllerManager.java Fri Sep  7 07:56:09 2007
@@ -20,13 +20,13 @@
 
 package org.apache.myfaces.orchestra.viewController;
 
-import org.apache.myfaces.orchestra.annotation.AnnotationInfoManager;
+import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.orchestra.annotation.AnnotationInfo;
-import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfoManager;
 import org.apache.myfaces.orchestra.conversation.ConversationManager;
+import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
 import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
 import org.apache.myfaces.orchestra.lib.OrchestraException;
-import org.apache.commons.lang.StringUtils;
 
 import java.io.IOException;
 
@@ -108,6 +108,11 @@
 
 			if (!manager.hasConversation(conversationName))
 			{
+				if (manager.getMessager() != null)
+				{
+					manager.getMessager().setConversationNotActive(conversationName);
+				}
+
 				if (!StringUtils.isEmpty(conversationRequire.redirect()))
 				{
 					try

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/PlainAnnotationsViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/PlainAnnotationsViewControllerManager.java?rev=573600&r1=573599&r2=573600&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/PlainAnnotationsViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/PlainAnnotationsViewControllerManager.java Fri Sep  7 07:56:09 2007
@@ -20,16 +20,6 @@
 
 package org.apache.myfaces.orchestra.viewController;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.myfaces.orchestra.annotation.AnnotationInfo;
-import org.apache.myfaces.orchestra.conversation.ConversationManager;
-import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
-import org.apache.myfaces.orchestra.lib.OrchestraException;
-
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-
 /**
  * A {@link ViewControllerManager} implementation which uses
  * annotations on backing beans to determine the beans responsible for a given view and execute
@@ -66,76 +56,5 @@
 	protected ViewControllerExecutor getViewControllerExecutor()
 	{
 		return viewControllerExecutor;
-	}
-
-	public void assertConversationState(String viewId)
-	{
-		String beanName = getViewControllerNameMapper().mapViewId(viewId);
-		if (beanName == null)
-		{
-			return;
-		}
-
-		AnnotationInfo annotationInfo = getAnnotationInfoManager().getAnnotationInfoByBeanName(beanName);
-		if (annotationInfo == null || annotationInfo.getConversationRequire() == null)
-		{
-			return;
-		}
-
-		ConversationRequire conversationRequire = annotationInfo.getConversationRequire();
-
-		// check if we are on an entry-point-page
-		String[] entryPoints = conversationRequire.entryPointViewIds();
-		if (entryPoints != null && entryPoints.length > 0)
-		{
-			for (int i = 0; i < entryPoints.length; i++)
-			{
-				String entryPoint = entryPoints[i];
-				if (entryPoint.equals(viewId))
-				{
-					// yes ... no need to check
-					return;
-				}
-			}
-		}
-
-		String[] conversationNames = conversationRequire.conversationNames();
-		if (conversationNames == null || conversationNames.length < 1)
-		{
-			// wrong configuration?
-			return;
-		}
-
-		ConversationManager manager = ConversationManager.getInstance();
-		for (int i = 0; i < conversationNames.length; i++)
-		{
-			String conversationName = conversationNames[i];
-
-			if (!manager.hasConversation(conversationName))
-			{
-				if (manager.getMessager() != null)
-				{
-					manager.getMessager().setConversationNotActive(
-						FacesContext.getCurrentInstance(), // TODO: find a way to avoid the FacesContext here
-						conversationName);
-				}
-
-				if (!StringUtils.isEmpty(conversationRequire.redirect()))
-				{
-					try
-					{
-						FrameworkAdapter.getInstance().redirect(conversationRequire.redirect());
-					}
-					catch (IOException e)
-					{
-						throw new OrchestraException(e);
-					}
-				}
-				else if (!StringUtils.isEmpty(conversationRequire.navigationAction()))
-				{
-					FrameworkAdapter.getInstance().invokeNavigation(conversationRequire.navigationAction());
-				}
-			}
-		}
 	}
 }