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 2007/10/05 11:04:45 UTC

svn commit: r582143 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java

Author: skitching
Date: Fri Oct  5 02:04:45 2007
New Revision: 582143

URL: http://svn.apache.org/viewvc?rev=582143&view=rev
Log:
Fix some accidental dependencies on JSF classes.

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java?rev=582143&r1=582142&r2=582143&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java Fri Oct  5 02:04:45 2007
@@ -20,7 +20,6 @@
 
 import java.io.IOException;
 
-import javax.faces.context.FacesContext;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -31,8 +30,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
 import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapterInterface;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * An implementation of the FrameworkAdapter for plain servlet environments.
@@ -194,15 +191,6 @@
 		throw new IllegalStateException(ISE_MESSAGE);
 	}
 
-	// TODO: this is spring-specific. And exposed via the protected API. Neither is good.
-	private ConfigurableApplicationContext getApplicationContext()
-	{
-		// TODO: What about portlets ?
-		ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
-
-		return (ConfigurableApplicationContext) WebApplicationContextUtils.getWebApplicationContext(servletContext);
-	}
-
 	public void redirect(String url) throws IOException
 	{
 		StringBuffer redir = new StringBuffer();
@@ -217,13 +205,33 @@
 		rsp.sendRedirect(dstUrl);
 	}
 
+	/**
+	 * Look in the request and session scopes for an entry
+	 * with the specified name.
+	 * <p>
+	 * This basic adapter class does not support invoking the JSP expression
+	 * evaluator; no "variable resolver" will ever be used to look up the
+	 * specified name.
+	 * <p>
+	 * TODO: also look in the application scope.
+	 * <p>
+	 * TODO: investigate invoking the jsp.ExpressionFactory class to look up
+	 * the variable. Possibly that could be done in a different JspFrameworkAdapter
+	 * class.
+	 */
 	public Object getBean(String name)
 	{
-		if (!getApplicationContext().containsBean(name))
-		{
-			return null;
-		}
-		return getApplicationContext().getBean(name);
+		Object obj;
+
+		obj = getRequestAttribute(name);
+		if (obj != null) return obj;
+
+		obj = getSessionAttribute(name);
+		if (obj != null) return obj;
+		
+		// TODO: look up application-scoped objects.
+		
+		return null;
 	}
 
 	/**