You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/10/19 03:50:14 UTC
svn commit: r826577 - in
/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra:
conversation/ConversationManager.java
conversation/spring/AbstractSpringOrchestraScope.java
lib/jsf/PortletOrchestraFacesContextFactory.java
Author: lu4242
Date: Mon Oct 19 01:50:13 2009
New Revision: 826577
URL: http://svn.apache.org/viewvc?rev=826577&view=rev
Log:
ORCHESTRA-15 Orchestra in Portal Environment (fix liferay serialize request attribute map and AbstractSpringOrchestraScope add proxy beans to this map and fix the case when a filter is used to define a FrameworkAdapter)
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/spring/AbstractSpringOrchestraScope.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/PortletOrchestraFacesContextFactory.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=826577&r1=826576&r2=826577&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 Mon Oct 19 01:50:13 2009
@@ -138,6 +138,9 @@
if (conversationManager == null && create)
{
+ Log log = LogFactory.getLog(ConversationManager.class);
+ log.debug("Register ConversationRequestParameterProvider");
+
conversationManager = FactoryFinder.getConversationManagerFactory().createConversationManager();
// initialize environmental systems
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java?rev=826577&r1=826576&r2=826577&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java Mon Oct 19 01:50:13 2009
@@ -34,6 +34,7 @@
import org.apache.myfaces.orchestra.conversation.ConversationManager;
import org.apache.myfaces.orchestra.conversation.CurrentConversationAdvice;
import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
+import org.apache.myfaces.orchestra.lib.jsf.PortletOrchestraFacesContextFactory;
import org.springframework.aop.Advisor;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.ProxyFactory;
@@ -293,7 +294,20 @@
FrameworkAdapter fa = FrameworkAdapter.getCurrentInstance();
if (fa != null)
{
- fa.setRequestAttribute(beanName, proxy);
+ // ORCHESTRA-15 -= Leonardo Uribe =-
+ // If it is inside a portlet using JSR-301 bridge do not add it
+ // because there are portlet containers like liferay that
+ // could scan request attribute map to put in xml form. In that
+ // case, FrameworkAdapter will not be found and an exception is
+ // thrown when resolving its proxy.
+ // It is possible we could have this case too with other portlet
+ // bridge implementation (myfaces 1.1 and so) but since from this
+ // point we should not call for jsf specific code, we only can
+ // check if the current request contains the key "javax.portlet.faces.phase"
+ if (fa.containsRequestAttribute(PortletOrchestraFacesContextFactory.PORTLET_LIFECYCLE_PHASE))
+ {
+ fa.setRequestAttribute(beanName, proxy);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/PortletOrchestraFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/PortletOrchestraFacesContextFactory.java?rev=826577&r1=826576&r2=826577&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/PortletOrchestraFacesContextFactory.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/PortletOrchestraFacesContextFactory.java Mon Oct 19 01:50:13 2009
@@ -31,11 +31,20 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
import org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterServletFilter;
/**
* Class used by OrchestraFacesContextFactory to allow orchestra work in portlets
*
+ * In portlet world we have the following differences against servlets:
+ *
+ * 1. In servlet, the same thread is responsible from execute action and render. But
+ * in portlets we could have separate threads that execute action and render.
+ * 2. The request attribute values between portlet action and render could be lost, so
+ * if we need some param to be passed between action and render phase.
+ *
+ *
* @author Leonardo Uribe(latest modification by $Author$)
* @version $Revision$ $Date$
*/
@@ -50,6 +59,11 @@
private final static String CONVERSATION_CONTEXT_PARAM = "conversationContext";
public final static String REQUEST_HANDLERS = "org.apache.myfaces.orchestra.REQUEST_HANDLERS";
+
+ /**
+ * Constant used by orchestra to check if we are on a portlet request or not.
+ */
+ public final static String PORTLET_LIFECYCLE_PHASE = "javax.portlet.orchestra.phase";
public PortletOrchestraFacesContextFactory()
@@ -78,7 +92,12 @@
List handlers = null;
boolean init = false;
String nextToken = null;
- if (RequestType.RENDER.equals(ExternalContextUtils.getRequestType(context, request)))
+
+ Map requestMap = externalContext.getRequestMap();
+
+ RequestType type = ExternalContextUtils.getRequestType(context, request);
+
+ if (RequestType.RENDER.equals(type))
{
PortletRequest portletRequest = (PortletRequest) request;
nextToken = portletRequest.getParameter(CONVERSATION_CONTEXT_PARAM);
@@ -93,6 +112,31 @@
handlers = (List) externalContext.getApplicationMap().remove(REQUEST_HANDLERS+nextToken);
}
}
+
+ // AbstractSpringOrchestraScope add retrieved values to request scope, but in portlet
+ // containers later this map could be serialized. This cause orchestra try to resolve
+ // its proxy, but since FrameworkAdapter instance is only available after this point.
+ // it causes an Exception.
+ // Since from AbstractSpringOrchestraScope we can't have access to ExternalContext, we should put
+ // a param to identify if we are or not in portlet request and which phase we are, in a similar
+ // way as JSR-301 does
+ if (RequestType.RENDER.equals(type))
+ {
+ requestMap.put(PORTLET_LIFECYCLE_PHASE, "RENDER_PHASE");
+ }
+ else if (RequestType.ACTION.equals(type))
+ {
+ requestMap.put(PORTLET_LIFECYCLE_PHASE, "ACTION_PHASE");
+ }
+ else if (RequestType.EVENT.equals(type))
+ {
+ requestMap.put(PORTLET_LIFECYCLE_PHASE, "EVENT_PHASE");
+ }
+ else if (RequestType.RESOURCE.equals(type))
+ {
+ requestMap.put(PORTLET_LIFECYCLE_PHASE, "RESOURCE_PHASE");
+ }
+
if (handlers == null)
{
//Init
@@ -141,7 +185,17 @@
private void setRequestParameterResponseWrappedMode(Object context, Object request)
{
- if (!getBooleanRequestValue(request,
+ FrameworkAdapter nonJsfFrameworkAdapter = FrameworkAdapter.getCurrentInstance();
+ if (nonJsfFrameworkAdapter != null)
+ {
+ if (!Boolean.TRUE.equals(nonJsfFrameworkAdapter.getRequestAttribute(
+ RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED)))
+ {
+ nonJsfFrameworkAdapter.setRequestAttribute(
+ RequestParameterServletFilter.REQUEST_PARAM_RESPONSE_WRAPPED, Boolean.TRUE);
+ }
+ }
+ else if (!getBooleanRequestValue(request,
RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED))
{
setBooleanRequestValue(request,