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/08/12 10:10:25 UTC

svn commit: r565017 - in /myfaces/orchestra/trunk: core/src/main/java/org/apache/myfaces/orchestra/conversation/ core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/ core/src/main/java/org/apache/myfaces/orchestra/lib/ core/src/main/java/o...

Author: imario
Date: Sun Aug 12 01:10:22 2007
New Revision: 565017

URL: http://svn.apache.org/viewvc?view=rev&rev=565017
Log:
added runtime exception: OrchestraException
refactored AnnotationInitializer, now we have an independent AnnotationInfoManager which can hold the various annotation settings about a bean
added handling for @ConversationRequire (not tested yet)
refactored ViewControllerManager

Added:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
      - copied, changed from r564968, myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerPhaseListener.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfo.java
      - copied, changed from r564968, myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationInfo.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfoManager.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/spring/
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/spring/AnnotationsInfoInitializer.java
      - copied, changed from r564968, myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationsInitializer.java
Removed:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerPhaseListener.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/frameworkAdapter/FrameworkAdapterInterface.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerManager.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java
    myfaces/orchestra/trunk/core/src/main/resources/META-INF/faces-config.xml
    myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderFactory.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerExecutor.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerNameMapper.java
    myfaces/orchestra/trunk/core15/src/main/resources/META-INF/spring-orchestra-init.xml
    myfaces/orchestra/trunk/core15/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.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?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- 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 Sun Aug 12 01:10:22 2007
@@ -23,10 +23,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.orchestra.conversation.spring.ConversationPolicy;
 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 javax.faces.FacesException;
 import java.io.IOException;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
@@ -364,15 +364,15 @@
 			}
 			catch (InstantiationException e)
 			{
-				throw new FacesException("error creating messager: " + conversationMessagerName, e);
+				throw new OrchestraException("error creating messager: " + conversationMessagerName, e);
 			}
 			catch (IllegalAccessException e)
 			{
-				throw new FacesException("error creating messager: " + conversationMessagerName, e);
+				throw new OrchestraException("error creating messager: " + conversationMessagerName, e);
 			}
 			catch (ClassNotFoundException e)
 			{
-				throw new FacesException("error creating messager: " + conversationMessagerName, e);
+				throw new OrchestraException("error creating messager: " + conversationMessagerName, e);
 			}
 		}
 	}

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapterInterface.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapterInterface.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapterInterface.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapterInterface.java Sun Aug 12 01:10:22 2007
@@ -52,4 +52,6 @@
 	public void redirect(String url) throws IOException;
 
 	public Object getBean(String name);
+
+	public void invokeNavigation(String navigationName);
 }

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java Sun Aug 12 01:10:22 2007
@@ -224,6 +224,17 @@
 
 	public Object getBean(String name)
 	{
+		if (!getApplicationContext().containsBean(name))
+		{
+			return null;
+		}
 		return getApplicationContext().getBean(name);
+	}
+
+	public void invokeNavigation(String navigationName)
+	{
+		FacesContext context = getFacesContext();
+
+		context.getApplication().getNavigationHandler().handleNavigation(context, null, navigationName);
 	}
 }

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java?view=auto&rev=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java Sun Aug 12 01:10:22 2007
@@ -0,0 +1,47 @@
+/*
+ * 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.orchestra.lib;
+
+/**
+ * A generic orchestra exception 
+ */
+public class OrchestraException extends RuntimeException
+{
+	private static final long serialVersionUID = -282458546217595126L;
+
+	public OrchestraException()
+	{
+	}
+
+	public OrchestraException(String message)
+	{
+		super(message);
+	}
+
+	public OrchestraException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+	public OrchestraException(Throwable cause)
+	{
+		super(cause);
+	}
+}

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java Sun Aug 12 01:10:22 2007
@@ -20,17 +20,17 @@
 
 package org.apache.myfaces.orchestra.viewController;
 
-import javax.faces.context.FacesContext;
+import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
 
 /**
  * @see org.apache.myfaces.orchestra.viewController.ViewControllerManager
  */
 public abstract class AbstractViewControllerManager implements ViewControllerManager
 {
-	public abstract ViewControllerNameMapper getViewControllerNameMapper();
-	public abstract AbstractViewControllerExecutor getViewControllerExecutor();
+	protected abstract ViewControllerNameMapper getViewControllerNameMapper();
+	protected abstract AbstractViewControllerExecutor getViewControllerExecutor();
 
-	public Object getViewController(FacesContext facesContext, String viewId)
+	public Object getViewController(String viewId)
 	{
 		ViewControllerNameMapper nameMapper = getViewControllerNameMapper();
 
@@ -40,6 +40,40 @@
 			return null;
 		}
 
-		return facesContext.getApplication().getVariableResolver().resolveVariable(facesContext, beanName);
+		return FrameworkAdapter.getInstance().getBean(beanName);
+	}
+
+	public void assertConversationState(String viewId)
+	{
+	}
+
+	public void executeInitView(String viewId)
+	{
+		String beanName = getViewControllerNameMapper().mapViewId(viewId);
+		Object viewController = getViewController(viewId);
+		if (viewController != null)
+		{
+			getViewControllerExecutor().invokeInitView(beanName, viewController);
+		}
+	}
+
+	public void executePreProcess(String viewId)
+	{
+		String beanName = getViewControllerNameMapper().mapViewId(viewId);
+		Object viewController = getViewController(viewId);
+		if (viewController != null)
+		{
+			getViewControllerExecutor().invokePreProcess(beanName, viewController);
+		}
+	}
+
+	public void executePreRenderView(String viewId)
+	{
+		String beanName = getViewControllerNameMapper().mapViewId(viewId);
+		Object viewController = getViewController(viewId);
+		if (viewController != null)
+		{
+			getViewControllerExecutor().invokePreRenderView(beanName, viewController);
+		}
 	}
 }

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerManager.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerManager.java Sun Aug 12 01:10:22 2007
@@ -38,12 +38,12 @@
 	{
 	}
 
-	public ViewControllerNameMapper getViewControllerNameMapper()
+	protected ViewControllerNameMapper getViewControllerNameMapper()
 	{
 		return viewControllerNameMapper;
 	}
 
-	public AbstractViewControllerExecutor getViewControllerExecutor()
+	protected AbstractViewControllerExecutor getViewControllerExecutor()
 	{
 		return abstractViewControllerExecutor;
 	}

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java Sun Aug 12 01:10:22 2007
@@ -20,7 +20,8 @@
 
 package org.apache.myfaces.orchestra.viewController;
 
-import javax.faces.FacesException;
+import org.apache.myfaces.orchestra.lib.OrchestraException;
+
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -57,11 +58,11 @@
 		}
 		catch (IllegalAccessException e)
 		{
-			throw new FacesException(e);
+			throw new OrchestraException(e);
 		}
 		catch (InvocationTargetException e)
 		{
-			throw new FacesException(e);
+			throw new OrchestraException(e);
 		}
 	}
 

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java Sun Aug 12 01:10:22 2007
@@ -20,15 +20,13 @@
 
 package org.apache.myfaces.orchestra.viewController;
 
-import javax.faces.context.FacesContext;
-
 /**
  * <p>The view controller manager is basically a configuration class, you have to create your own if
  * you would like to use a different configuration</p>
  * <p/>
  * If you would like to use your own naming scheme or executor just implement your own {@link ViewControllerManager} or
- * derive from {@link DefaultViewControllerManager} (the prefered way) and overload {@link #getViewControllerNameMapper()} or
- * {@link #getViewControllerExecutor()} }.<br />
+ * derive from {@link DefaultViewControllerManager} (the prefered way) and overload {@link AbstractViewControllerManager#getViewControllerNameMapper()} or
+ * {@link AbstractViewControllerManager#getViewControllerExecutor()} }.<br />
  * To activate your manager just configure it as managed bean in your faces-config.xml or your spring configuration,
  * preferably in application scope or as singleton.<br />
  * The managed-bean-name has to be "<code>orchestra_ViewControllerManager</code>" (see constanst {@link ViewControllerManager#VIEW_CONTROLLER_MANAGER_NAME})
@@ -36,11 +34,12 @@
  */
 public interface ViewControllerManager
 {
-	public final static String VIEW_CONTROLLER_MANAGER_NAME = "orchestra_ViewControllerManager";
-
-	public ViewControllerNameMapper getViewControllerNameMapper();
+	public final static String VIEW_CONTROLLER_MANAGER_NAME = ViewControllerManager.class.getName(); 
 
-	public AbstractViewControllerExecutor getViewControllerExecutor();
+	public Object getViewController(String viewId);
 
-	public Object getViewController(FacesContext facesContext, String viewId);
+	public void assertConversationState(String viewId);
+	public void executeInitView(String viewId);
+	public void executePreProcess(String viewId);
+	public void executePreRenderView(String viewId);
 }

Copied: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java (from r564968, myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerPhaseListener.java)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java?view=diff&rev=565017&p1=myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerPhaseListener.java&r1=564968&p2=myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerPhaseListener.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java Sun Aug 12 01:10:22 2007
@@ -18,7 +18,10 @@
  *
  */
 
-package org.apache.myfaces.orchestra.viewController;
+package org.apache.myfaces.orchestra.viewController.jsf;
+
+import org.apache.myfaces.orchestra.viewController.ViewControllerManager;
+import org.apache.myfaces.orchestra.viewController._ViewControllerUtils;
 
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
@@ -31,8 +34,16 @@
  */
 public class ViewControllerPhaseListener implements PhaseListener
 {
+	private static final long serialVersionUID = -3975277433747722402L;
+
 	public void beforePhase(PhaseEvent event)
 	{
+		if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()) ||
+			PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
+		{
+			assertConversationState(event.getFacesContext());
+		}
+
 		if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
 		{
 			preRenderResponse(event.getFacesContext());
@@ -48,6 +59,11 @@
 	{
 		if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()))
 		{
+			assertConversationState(event.getFacesContext());
+		}
+
+		if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()))
+		{
 			postRestoreView(event.getFacesContext());
 		}
 	}
@@ -68,9 +84,12 @@
 	}
 
 	/**
-	 * invokes the preRenderView method on your view controller
+	 * invoked multiple times during the lifecycle to ensure the conversation(s)
+	 * to the associated viewController are running.
+	 *
+	 * @param facesContext
 	 */
-	protected void preRenderResponse(FacesContext facesContext)
+	protected void assertConversationState(FacesContext facesContext)
 	{
 		ViewControllerManager manager = _ViewControllerUtils.getViewControllerManager(facesContext);
 		if (manager == null)
@@ -84,12 +103,27 @@
 			return;
 		}
 
-		String beanName = manager.getViewControllerNameMapper().mapViewId(viewId);
-		Object viewController = manager.getViewController(facesContext, viewId);
-		if (viewController != null)
+		manager.assertConversationState(viewId);
+	}
+
+	/**
+	 * invokes the preRenderView method on your view controller
+	 */
+	protected void preRenderResponse(FacesContext facesContext)
+	{
+		ViewControllerManager manager = _ViewControllerUtils.getViewControllerManager(facesContext);
+		if (manager == null)
+		{
+			return;
+		}
+
+		String viewId = getViewId(facesContext);
+		if (viewId == null)
 		{
-			manager.getViewControllerExecutor().invokePreRenderView(beanName, viewController);
+			return;
 		}
+
+		manager.executePreRenderView(viewId);
 	}
 
 	/**
@@ -109,12 +143,7 @@
 			return;
 		}
 
-		String beanName = manager.getViewControllerNameMapper().mapViewId(viewId);
-		Object viewController = manager.getViewController(facesContext, viewId);
-		if (viewController != null)
-		{
-			manager.getViewControllerExecutor().invokeInitView(beanName, viewController);
-		}
+		manager.executeInitView(viewId);
 	}
 
 	/**
@@ -134,12 +163,6 @@
 			return;
 		}
 
-		String beanName = manager.getViewControllerNameMapper().mapViewId(viewId);
-		Object viewController = manager.getViewController(facesContext, viewId);
-		if (viewController != null)
-		{
-			manager.getViewControllerExecutor().invokePreProcess(beanName, viewController);
-		}
-
+		manager.executePreProcess(viewId);
 	}
 }

Modified: myfaces/orchestra/trunk/core/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/resources/META-INF/faces-config.xml?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/resources/META-INF/faces-config.xml (original)
+++ myfaces/orchestra/trunk/core/src/main/resources/META-INF/faces-config.xml Sun Aug 12 01:10:22 2007
@@ -36,7 +36,7 @@
 
 	<lifecycle>
 		<phase-listener>org.apache.myfaces.orchestra.conversation.jsf.ConversationPhaseListener</phase-listener>
-		<phase-listener>org.apache.myfaces.orchestra.viewController.ViewControllerPhaseListener</phase-listener>
+		<phase-listener>org.apache.myfaces.orchestra.viewController.jsf.ViewControllerPhaseListener</phase-listener>
 	</lifecycle>
 
 </faces-config>

Modified: myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java Sun Aug 12 01:10:22 2007
@@ -125,4 +125,8 @@
 	{
 		return getApplicationContext().getBean(name);
 	}
+
+	public void invokeNavigation(String navigationName)
+	{
+	}
 }

Copied: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfo.java (from r564968, myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationInfo.java)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfo.java?view=diff&rev=565017&p1=myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationInfo.java&r1=564968&p2=myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfo.java&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationInfo.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfo.java Sun Aug 12 01:10:22 2007
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.orchestra.conversation.spring;
+package org.apache.myfaces.orchestra.annotation;
 
 import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
 import org.apache.myfaces.orchestra.viewController.annotations.ViewController;
@@ -24,6 +24,7 @@
 import java.lang.reflect.Method;
 
 /**
+ * Informations extracted out of the beans using its annotations.
  */
 public class AnnotationInfo
 {

Added: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfoManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfoManager.java?view=auto&rev=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfoManager.java (added)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/AnnotationInfoManager.java Sun Aug 12 01:10:22 2007
@@ -0,0 +1,113 @@
+/*
+ * 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.orchestra.annotation;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
+import org.apache.myfaces.orchestra.viewController.annotations.InitView;
+import org.apache.myfaces.orchestra.viewController.annotations.PreProcess;
+import org.apache.myfaces.orchestra.viewController.annotations.PreRenderView;
+import org.apache.myfaces.orchestra.viewController.annotations.ViewController;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This manager provides access to the parsed annotations.
+ */
+public class AnnotationInfoManager
+{
+	private final Log log = LogFactory.getLog(AnnotationInfoManager.class);
+
+	private Map<String, AnnotationInfo> annotationsInfoByName = new HashMap<String, AnnotationInfo>();
+	private Map<String, AnnotationInfo> annotationsInfoByViewId = new HashMap<String, AnnotationInfo>();
+
+	protected void addAnnotationsInfo(AnnotationInfo annotationInfo)
+	{
+		if (annotationsInfoByName.containsKey(annotationInfo.getBeanName()))
+		{
+			log.info("duplicate bean definition: " + annotationInfo.getBeanName());
+		}
+
+		annotationsInfoByName.put(annotationInfo.getBeanName(), annotationInfo);
+
+		ViewController viewController = annotationInfo.getViewController();
+		if (viewController != null)
+		{
+			String[] viewIds = viewController.viewIds();
+			for (int i = 0; i<viewIds.length; i++)
+			{
+				String viewId = viewIds[i];
+
+				if (annotationsInfoByViewId.containsKey(annotationInfo.getBeanName()))
+				{
+					log.info("duplicate viewId definition: " + annotationInfo.getBeanName());
+				}
+
+				annotationsInfoByViewId.put(viewId, annotationInfo);
+			}
+		}
+	}
+
+	public AnnotationInfo getAnnotationInfoByBeanName(String beanName)
+	{
+		return annotationsInfoByName.get(beanName);
+	}
+
+	public AnnotationInfo getAnnotationInfoByViewId(String viewId)
+	{
+		return annotationsInfoByViewId.get(viewId);
+	}
+
+	public void processBeanAnnotations(String beanName, Class clazz)
+	{
+		ViewController viewController = (ViewController) clazz.getAnnotation(ViewController.class);
+		ConversationRequire conversationRequire = (ConversationRequire) clazz.getAnnotation(ConversationRequire.class);
+		if (viewController == null && conversationRequire == null)
+		{
+			return;
+		}
+
+		AnnotationInfo annotationInfo = new AnnotationInfo(beanName, clazz);
+		annotationInfo.setViewController(viewController);
+		annotationInfo.setConversationRequire(conversationRequire);
+
+		Method[] methods = clazz.getMethods();
+		for (int i = 0; i<methods.length; i++)
+		{
+			Method method = methods[i];
+			if (method.isAnnotationPresent(InitView.class))
+			{
+				annotationInfo.setInitViewMethod(method);
+			}
+			if (method.isAnnotationPresent(PreProcess.class))
+			{
+				annotationInfo.setPreProcessMethod(method);
+			}
+			if (method.isAnnotationPresent(PreRenderView.class))
+			{
+				annotationInfo.setPreRenderViewMethod(method);
+			}
+		}
+
+		addAnnotationsInfo(annotationInfo);
+	}
+}

Copied: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/spring/AnnotationsInfoInitializer.java (from r564968, myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationsInitializer.java)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/spring/AnnotationsInfoInitializer.java?view=diff&rev=565017&p1=myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationsInitializer.java&r1=564968&p2=myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/spring/AnnotationsInfoInitializer.java&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AnnotationsInitializer.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/annotation/spring/AnnotationsInfoInitializer.java Sun Aug 12 01:10:22 2007
@@ -16,16 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.orchestra.conversation.spring;
+package org.apache.myfaces.orchestra.annotation.spring;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
-import org.apache.myfaces.orchestra.viewController.annotations.InitView;
-import org.apache.myfaces.orchestra.viewController.annotations.PreProcess;
-import org.apache.myfaces.orchestra.viewController.annotations.PreRenderView;
-import org.apache.myfaces.orchestra.viewController.annotations.ViewController;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfoManager;
+import org.apache.myfaces.orchestra.conversation.spring._SpringUtils;
 import org.apache.myfaces.shared_orchestra.util.ClassUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -33,21 +29,16 @@
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.core.Ordered;
 
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-public class AnnotationsInitializer implements BeanFactoryPostProcessor, Ordered
+/**
+ * Parse all configured spring beans and extract Orchestra annotations out of them.
+ */
+public class AnnotationsInfoInitializer implements BeanFactoryPostProcessor, Ordered
 {
-	private Log log = LogFactory.getLog(AnnotationsInitializer.class);
+	private Log log = LogFactory.getLog(AnnotationsInfoInitializer.class);
 
-	private final static String MY_BEAN_NAME = AnnotationsInitializer.class.getName();
-	
 	private int order = Ordered.LOWEST_PRECEDENCE;  // default: same as non-Ordered
 
-	private Map<String, AnnotationInfo> annotationsInfoByName = new HashMap<String, AnnotationInfo>();
-	private Map<String, AnnotationInfo> annotationsInfoByViewId = new HashMap<String, AnnotationInfo>();
-	private Map<Class, AnnotationInfo> annotationsInfoByClass= new HashMap<Class, AnnotationInfo>();
+	private AnnotationInfoManager annotationInfoManager;
 
 	public int getOrder()
 	{
@@ -59,6 +50,11 @@
 		this.order = order;
 	}
 
+	public void setAnnotationInfoManager(AnnotationInfoManager annotationInfoManager)
+	{
+		this.annotationInfoManager = annotationInfoManager;
+	}
+
 	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
 	{
 		String[] beanNames = beanFactory.getBeanDefinitionNames();
@@ -82,6 +78,7 @@
 
 				if (beanClass != null)
 				{
+					// XXX: Hack to deal with aop:scope-proxy (scopedTarget.) beans
 					if (!_SpringUtils.isAlternateBeanName(beanName))
 					{
 						// we are not on a scopedTarget ... check if there is one
@@ -94,81 +91,9 @@
 					}
 
 					String realBeanName = _SpringUtils.getRealBeanName(beanName);
-					processOrchestraAnnotations(realBeanName, beanClass);
+					annotationInfoManager.processBeanAnnotations(realBeanName, beanClass);
 				}
 			}
 		}
-	}
-
-	public static AnnotationsInitializer getInstance()
-	{
-		return (AnnotationsInitializer) FrameworkAdapter.getInstance().getBean(MY_BEAN_NAME);
-	}
-	
-	protected void addAnnotationsInfo(AnnotationInfo annotationInfo)
-	{
-		annotationsInfoByName.put(annotationInfo.getBeanName(), annotationInfo);
-		annotationsInfoByClass.put(annotationInfo.getBeanClass(), annotationInfo);
-
-		ViewController viewController = annotationInfo.getViewController();
-		if (viewController != null)
-		{
-			String[] viewIds = viewController.viewIds();
-			for (int i = 0; i<viewIds.length; i++)
-			{
-				String viewId = viewIds[i];
-
-				annotationsInfoByViewId.put(viewId, annotationInfo);
-			}
-		}
-	}
-
-	public AnnotationInfo getAnnotationInfoByBeanName(String beanName)
-	{
-		return annotationsInfoByName.get(beanName);
-	}
-
-	public AnnotationInfo getAnnotationInfoByBeanClass(Class beanClass)
-	{
-		return annotationsInfoByClass.get(beanClass);
-	}
-
-	public AnnotationInfo getAnnotationInfoByViewId(String viewId)
-	{
-		return annotationsInfoByViewId.get(viewId);
-	}
-
-	protected void processOrchestraAnnotations(String beanName, Class clazz)
-	{
-		ViewController viewController = (ViewController) clazz.getAnnotation(ViewController.class);
-		ConversationRequire conversationRequire = (ConversationRequire) clazz.getAnnotation(ConversationRequire.class);
-		if (viewController == null && conversationRequire == null)
-		{
-			return;
-		}
-
-		AnnotationInfo annotationInfo = new AnnotationInfo(beanName, clazz);
-		annotationInfo.setViewController(viewController);
-		annotationInfo.setConversationRequire(conversationRequire);
-
-		Method[] methods = clazz.getMethods();
-		for (int i = 0; i<methods.length; i++)
-		{
-			Method method = methods[i];
-			if (method.isAnnotationPresent(InitView.class))
-			{
-				annotationInfo.setInitViewMethod(method);
-			}
-			if (method.isAnnotationPresent(PreProcess.class))
-			{
-				annotationInfo.setPreProcessMethod(method);
-			}
-			if (method.isAnnotationPresent(PreRenderView.class))
-			{
-				annotationInfo.setPreRenderViewMethod(method);
-			}
-		}
-
-		addAnnotationsInfo(annotationInfo);
 	}
 }

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java Sun Aug 12 01:10:22 2007
@@ -37,7 +37,7 @@
 	 * If one of the configured conversations is not active a redirect or
 	 * navigationAction will be issued.
 	 */
-	String[] conversationNames() default {};
+	String[] conversationNames();
 
 	/**
 	 * The servlet url to redirect to if one of the conversations is not running.

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java Sun Aug 12 01:10:22 2007
@@ -23,6 +23,7 @@
 import org.apache.myfaces.orchestra.dynaForm.metadata.FieldInterface;
 import org.apache.myfaces.orchestra.dynaForm.metadata.Selection;
 import org.apache.myfaces.orchestra.dynaForm.metadata.utils.TypeInfos;
+import org.apache.myfaces.orchestra.lib.OrchestraException;
 
 import javax.faces.FacesException;
 import javax.faces.component.UICommand;
@@ -283,11 +284,11 @@
 		}
 		catch (InstantiationException e)
 		{
-			throw new FacesException(e);
+			throw new OrchestraException(e);
 		}
 		catch (IllegalAccessException e)
 		{
-			throw new FacesException(e);
+			throw new OrchestraException(e);
 		}
 		uinew.restoreState(FacesContext.getCurrentInstance(), uicomponent.saveState(FacesContext.getCurrentInstance()));
 		return uinew;

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderFactory.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderFactory.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderFactory.java Sun Aug 12 01:10:22 2007
@@ -20,6 +20,7 @@
 
 import org.apache.myfaces.orchestra.dynaForm.guiBuilder.impl.myfaces.MyFacesCheck;
 import org.apache.myfaces.orchestra.dynaForm.guiBuilder.impl.myfaces.MyFacesGuiBuilder;
+import org.apache.myfaces.orchestra.lib.OrchestraException;
 
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
@@ -64,27 +65,27 @@
 			}
 			catch (IllegalArgumentException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 			catch (InvocationTargetException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 			catch (SecurityException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 			catch (InstantiationException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 			catch (IllegalAccessException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 			catch (ClassNotFoundException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 		}
 		return guiBuilder;

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerExecutor.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerExecutor.java Sun Aug 12 01:10:22 2007
@@ -19,21 +19,28 @@
  */
 package org.apache.myfaces.orchestra.viewController;
 
-import org.apache.myfaces.orchestra.conversation.spring.AnnotationsInitializer;
-import org.apache.myfaces.orchestra.conversation.spring.AnnotationInfo;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfo;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfoManager;
+import org.apache.myfaces.orchestra.lib.OrchestraException;
 
-import javax.faces.FacesException;
-import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 /**
+ * Execute the various viewController events on the viewController by calling
+ * the corresponding annotated method.
  */
 public class AnnotationsViewControllerExecutor extends AbstractViewControllerExecutor
 {
-	public void invokeInitView(String beanName, Object bean)
+	private final AnnotationInfoManager annotationInfoManager;
+
+	public AnnotationsViewControllerExecutor(AnnotationInfoManager annotationInfoManager)
+	{
+		this.annotationInfoManager = annotationInfoManager;
+	}
+
+	protected void invokeMethod(Object bean, Method method)
 	{
-		AnnotationInfo annotationsInfo = AnnotationsInitializer.getInstance().getAnnotationInfoByBeanName(beanName);
-		Method method = annotationsInfo.getInitViewMethod();
 		if (method != null)
 		{
 			try
@@ -42,54 +49,51 @@
 			}
 			catch (IllegalAccessException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 			catch (InvocationTargetException e)
 			{
-				throw new FacesException(e);
+				throw new OrchestraException(e);
 			}
 		}
 	}
 
-	public void invokePreRenderView(String beanName, Object bean)
+	public void invokeInitView(String beanName, Object bean)
 	{
-		AnnotationInfo annotationsInfo = AnnotationsInitializer.getInstance().getAnnotationInfoByBeanName(beanName);
-		Method method = annotationsInfo.getPreRenderViewMethod();
-		if (method != null)
+		AnnotationInfo annotationsInfo = annotationInfoManager.getAnnotationInfoByBeanName(beanName);
+		if (annotationsInfo != null)
 		{
-			try
-			{
-				method.invoke(bean, (Object[]) null);
-			}
-			catch (IllegalAccessException e)
+			Method method = annotationsInfo.getInitViewMethod();
+			if (method != null)
 			{
-				throw new FacesException(e);
+				invokeMethod(bean, method);
 			}
-			catch (InvocationTargetException e)
+		}
+	}
+
+	public void invokePreRenderView(String beanName, Object bean)
+	{
+		AnnotationInfo annotationsInfo = annotationInfoManager.getAnnotationInfoByBeanName(beanName);
+		if (annotationsInfo != null)
+		{
+			Method method = annotationsInfo.getPreRenderViewMethod();
+			if (method != null)
 			{
-				throw new FacesException(e);
+				invokeMethod(bean, method);
 			}
 		}
 	}
 
     public void invokePreProcess(String beanName, Object bean)
     {
-		AnnotationInfo annotationsInfo = AnnotationsInitializer.getInstance().getAnnotationInfoByBeanName(beanName);
-		Method method = annotationsInfo.getPreProcessMethod();
-		if (method != null)
+		AnnotationInfo annotationsInfo = annotationInfoManager.getAnnotationInfoByBeanName(beanName);
+		if (annotationsInfo != null)
 		{
-			try
+			Method method = annotationsInfo.getPreProcessMethod();
+			if (method != null)
 			{
-				method.invoke(bean, (Object[]) null);
-			}
-			catch (IllegalAccessException e)
-			{
-				throw new FacesException(e);
-			}
-			catch (InvocationTargetException e)
-			{
-				throw new FacesException(e);
+				invokeMethod(bean, method);
 			}
 		}
-    }
+	}
 }

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java Sun Aug 12 01:10:22 2007
@@ -20,6 +20,16 @@
 
 package org.apache.myfaces.orchestra.viewController;
 
+import org.apache.myfaces.orchestra.annotation.AnnotationInfoManager;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfo;
+import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
+import org.apache.myfaces.orchestra.conversation.ConversationManager;
+import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
+import org.apache.myfaces.orchestra.lib.OrchestraException;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.IOException;
+
 /**
  * <p/>
  * A {@link org.apache.myfaces.orchestra.viewController.ViewControllerManager} implementation which uses
@@ -31,27 +41,88 @@
  */
 public class AnnotationsViewControllerManager extends AbstractViewControllerManager
 {
-	private ViewControllerNameMapper viewControllerNameMapper =
-		new CompositeViewControllerNameMapper(
-			new ViewControllerNameMapper[]
-				{
-					new AnnotationsViewControllerNameMapper(),
-					new DefaultViewControllerNameMapper()
-				});
+	private AnnotationInfoManager annotationInfoManager;
 
-	private AbstractViewControllerExecutor abstractViewControllerExecutor = new AnnotationsViewControllerExecutor();
+	private ViewControllerNameMapper viewControllerNameMapper;
+	private AbstractViewControllerExecutor abstractViewControllerExecutor;
 
 	public AnnotationsViewControllerManager()
 	{
 	}
 
-	public ViewControllerNameMapper getViewControllerNameMapper()
+	public void initManager()
+	{
+		viewControllerNameMapper =
+			new CompositeViewControllerNameMapper(
+				new ViewControllerNameMapper[]
+					{
+						new AnnotationsViewControllerNameMapper(annotationInfoManager),
+						new DefaultViewControllerNameMapper()
+					});
+
+		abstractViewControllerExecutor = new AnnotationsViewControllerExecutor(annotationInfoManager);
+	}
+
+	public void setAnnotationInfoManager(AnnotationInfoManager annotationInfoManager)
+	{
+		this.annotationInfoManager = annotationInfoManager;
+	}
+
+	protected ViewControllerNameMapper getViewControllerNameMapper()
 	{
 		return viewControllerNameMapper;
 	}
 
-	public AbstractViewControllerExecutor getViewControllerExecutor()
+	protected AbstractViewControllerExecutor getViewControllerExecutor()
 	{
 		return abstractViewControllerExecutor;
+	}
+
+	public void assertConversationState(String viewId)
+	{
+		String beanName = getViewControllerNameMapper().mapViewId(viewId);
+		if (beanName == null)
+		{
+			return;
+		}
+
+		AnnotationInfo annotationInfo = annotationInfoManager.getAnnotationInfoByBeanName(beanName);
+		if (annotationInfo == null || annotationInfo.getConversationRequire() == null)
+		{
+			return;
+		}
+
+		ConversationRequire conversationRequire = annotationInfo.getConversationRequire();
+		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 (!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());
+				}
+			}
+		}
 	}
 }

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerNameMapper.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerNameMapper.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerNameMapper.java Sun Aug 12 01:10:22 2007
@@ -19,16 +19,25 @@
  */
 package org.apache.myfaces.orchestra.viewController;
 
-import org.apache.myfaces.orchestra.conversation.spring.AnnotationInfo;
-import org.apache.myfaces.orchestra.conversation.spring.AnnotationsInitializer;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfo;
+import org.apache.myfaces.orchestra.annotation.AnnotationInfoManager;
 
 /**
+ * Lookup a bean configured using the {@see ViewController} annotation which is responsible
+ * for the given <code>viewId</code>
  */
 public class AnnotationsViewControllerNameMapper implements ViewControllerNameMapper
 {
+	private final AnnotationInfoManager annotationInfoManager;
+	
+	public AnnotationsViewControllerNameMapper(AnnotationInfoManager annotationInfoManager)
+	{
+		this.annotationInfoManager = annotationInfoManager;
+	}
+
 	public String mapViewId(String viewId)
 	{
-		AnnotationInfo annotationsInfo = AnnotationsInitializer.getInstance().getAnnotationInfoByViewId(viewId);
+		AnnotationInfo annotationsInfo = annotationInfoManager.getAnnotationInfoByViewId(viewId);
 		if (annotationsInfo != null)
 		{
 			return annotationsInfo.getBeanName();

Modified: myfaces/orchestra/trunk/core15/src/main/resources/META-INF/spring-orchestra-init.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/resources/META-INF/spring-orchestra-init.xml?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/resources/META-INF/spring-orchestra-init.xml (original)
+++ myfaces/orchestra/trunk/core15/src/main/resources/META-INF/spring-orchestra-init.xml Sun Aug 12 01:10:22 2007
@@ -26,12 +26,30 @@
 			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
 
 	<bean
-		class="org.apache.myfaces.orchestra.conversation.spring.AnnotationsInitializer"
+		name="org.apache.myfaces.orchestra.annotation.AnnotationInfoManager"
+		class="org.apache.myfaces.orchestra.annotation.AnnotationInfoManager"
 		scope="singleton" />
 
 	<bean
-		id="orchestra_ViewControllerManager"
+		class="org.apache.myfaces.orchestra.annotation.spring.AnnotationsInfoInitializer"
+		scope="singleton">
+
+		<property
+			name="annotationInfoManager"
+			ref="org.apache.myfaces.orchestra.annotation.AnnotationInfoManager"/>
+
+	</bean>
+
+	<bean
+		name="org.apache.myfaces.orchestra.viewController.ViewControllerManager"
 		class="org.apache.myfaces.orchestra.viewController.AnnotationsViewControllerManager"
-		scope="singleton" />
+		init-method="initManager"
+		scope="singleton">
+		
+		<property
+			name="annotationInfoManager"
+			ref="org.apache.myfaces.orchestra.annotation.AnnotationInfoManager"/>
+
+	</bean>
 
 </beans>

Modified: myfaces/orchestra/trunk/core15/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java?view=diff&rev=565017&r1=565016&r2=565017
==============================================================================
--- myfaces/orchestra/trunk/core15/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core15/src/test/java/org/apache/myfaces/orchestra/frameworkAdapter/MockFrameworkAdapter.java Sun Aug 12 01:10:22 2007
@@ -125,4 +125,8 @@
 	{
 		return getApplicationContext().getBean(name);
 	}
+
+	public void invokeNavigation(String navigationName)
+	{
+	}
 }