You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/02/21 17:35:08 UTC

svn commit: r629857 - in /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation: AccessScopeManager.java FlashScopeManager.java

Author: skitching
Date: Thu Feb 21 08:35:08 2008
New Revision: 629857

URL: http://svn.apache.org/viewvc?rev=629857&view=rev
Log:
Fix backward-compatibility issue with Orchestra Core 1.0 users who had a custom FlashScopeManagerConfiguration bean definition. Previously we were not detecting the ignoreViewIds specified there.

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/AccessScopeManager.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/FlashScopeManager.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/AccessScopeManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/AccessScopeManager.java?rev=629857&r1=629856&r2=629857&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/AccessScopeManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/AccessScopeManager.java Thu Feb 21 08:35:08 2008
@@ -18,11 +18,13 @@
  */
 package org.apache.myfaces.orchestra.conversation;
 
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
-
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
+
 /**
  * Manager to deal with page scoped beans.
  * <p>
@@ -32,8 +34,10 @@
  * 
  * @since 1.1
  */
-public final class AccessScopeManager
+public class AccessScopeManager
 {
+	private static final Log log = LogFactory.getLog(AccessScopeManager.class);
+	private static final String REQ_ATTR_KEY = AccessScopeManager.class.getName();
 	private AccessScopeManagerConfiguration accessScopeManagerConfiguration;
 
 	private boolean recordAccess;
@@ -49,24 +53,57 @@
 		//
 		// Using a lookup of a managed bean allows the user to set configuration properties on the
 		// manager class and its properties.
-		AccessScopeManager manager = (AccessScopeManager) FrameworkAdapter.getCurrentInstance().getBean(AccessScopeManager.class.getName());
-		if (manager == null)
+
+		FrameworkAdapter fa = FrameworkAdapter.getCurrentInstance();
+		AccessScopeManager manager = (AccessScopeManager) fa.getRequestAttribute(REQ_ATTR_KEY);
+		if (manager != null)
+		{
+			// already found and cached in request attributes
+			return manager;
+		}
+
+		// Backwards compatibility hack: look for FlashScopeManager. It is possible that
+		// a user of Orchestra 1.0 has copied the declaration from the original Orchestra
+		// config file into their own code to inject special settings.
+		manager = (AccessScopeManager) fa.getBean(FlashScopeManager.class.getName());
+		if (manager != null)
+		{
+			log.info("found FlashScopeManager object");
+			fa.setRequestAttribute(REQ_ATTR_KEY, manager);
+			return manager;
+		}
+		
+		// Backwards compatibility hack: look for FlashScopeManagerConfiguration. It is
+		// possible that a user of Orchestra 1.0 has overridden just the Configuration
+		// bit to set their own ignoredViewId values (as recommended!):
+		//
+		// This is a little dodgy as settings made through the new AccessScopeManage
+		// bean will will now be silently ignored.
+		FlashScopeManagerConfiguration cfg = (FlashScopeManagerConfiguration) fa.getBean(FlashScopeManagerConfiguration.class.getName());
+		if (cfg != null)
+		{
+			log.info("found FlashScopeManagerConfiguration object");
+			manager = new AccessScopeManager();
+			manager.setAccessScopeManagerConfiguration(cfg);
+			fa.setRequestAttribute(REQ_ATTR_KEY, manager);
+			return manager;
+		}
+		
+		// normal case
+		manager = (AccessScopeManager) fa.getBean(AccessScopeManager.class.getName());
+		if (manager != null)
 		{
-			// backwards compatibility hack
-			FlashScopeManager fm = (FlashScopeManager) FrameworkAdapter.getCurrentInstance().getBean(FlashScopeManager.class.getName());
-			if (fm != null)
-			{
-				manager = fm.getAccessScopeManager();
-			}
-			else
-			{
-				// TODO: Make this error message less spring-specific. Spring is not the only IOC container
-				// that Orchestra can be used with.
-				throw new IllegalArgumentException("no AccessScopeManager found. Propably you forgot to add <import resource=\"classpath*:/META-INF/spring-orchestra-init.xml\" /> to your spring configuration.");
-			}
+			log.info("found AccessScopeManager object");
+			fa.setRequestAttribute(REQ_ATTR_KEY, manager);
+			return manager;
 		}
 
-		return manager;
+		// TODO: Make this error message less spring-specific. Spring is not the only IOC container
+		// that Orchestra can be used with.
+		throw new IllegalArgumentException(
+				"No AccessScopeManager found. Probably you forgot to add " 
+				+ "<import resource=\"classpath*:/META-INF/spring-orchestra-init.xml\" />" 
+				+ " to your spring configuration.");
 	}
 
 	public AccessScopeManagerConfiguration getAccessScopeManagerConfiguration()

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/FlashScopeManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/FlashScopeManager.java?rev=629857&r1=629856&r2=629857&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/FlashScopeManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/FlashScopeManager.java Thu Feb 21 08:35:08 2008
@@ -18,37 +18,28 @@
  */
 package org.apache.myfaces.orchestra.conversation;
 
-
 /**
  * @deprecated Use AccessScopeManager instead.
  * 
  * This class provides backwards compatibility for configuration files designed
  * for Orchestra 1.0. 
  */
-public final class FlashScopeManager
+public final class FlashScopeManager extends AccessScopeManager
 {
-	private AccessScopeManager impl;
-	private FlashScopeManagerConfiguration flashScopeManagerConfiguration;
+	private FlashScopeManagerConfiguration configuration;
 
 	public FlashScopeManager()
 	{
-		impl = new AccessScopeManager();
-	}
-
-	AccessScopeManager getAccessScopeManager()
-	{
-		return impl;
 	}
 
 	public FlashScopeManagerConfiguration getFlashScopeManagerConfiguration()
 	{
-		return flashScopeManagerConfiguration;
+		return configuration;
 	}
 
-	public void setFlashScopeManagerConfiguration(FlashScopeManagerConfiguration flashScopeManagerConfiguration)
+	public void setFlashScopeManagerConfiguration(FlashScopeManagerConfiguration configuration)
 	{
-		this.flashScopeManagerConfiguration = flashScopeManagerConfiguration;
-		impl.setAccessScopeManagerConfiguration(flashScopeManagerConfiguration);
+		super.setAccessScopeManagerConfiguration(configuration);
+		this.configuration = configuration;
 	}
-
 }