You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2009/05/11 20:32:46 UTC
svn commit: r773647 [1/2] - in /myfaces/trinidad/trunk: ./
trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/
trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/
trinidad-examples/ trinidad-examples/trinidad-demo/ trinidad-exampl...
Author: sobryan
Date: Mon May 11 18:32:44 2009
New Revision: 773647
URL: http://svn.apache.org/viewvc?rev=773647&view=rev
Log:
TRINIDAD-1471: Portlet 2.0 Support for Trinidad
* Extending ExternalContextUtils to support the RequestType Enumeration like in commons-utils as well as add support for Portlet 2.0 request types. I decided to add this code to the Trinidad specific API as opposed to using commons so that the upgrade will be easier. We should look into a project to start consuming commons.
* Updated pluto profile in demo to build a Pluto compatible war. This will now correctly build a Pluto compatible demo war for either Pluto 1.x or Pluto 2.x depending on the setting of the -Dportlet=2.0 flag. By default it will build a war compatible with Pluto 1.x. Invoking Portlet 2.0 will add a snapshot dependency as Pluto 2.0 is not yet released. Because this is governed by a property, this should not effect the ability to release Trinidad
* Added a pluto-embedded profile that will allow you to run the Trinidad Demo, in jetty, using Pluto 1.x.. This does not currently work with the -Dportlet=2.0 flag because the pluto-embedded plugin has some issues.
* Changed api and impl packages to compile against Portlet 2.0 objects instead of Portlet 1.0
* Updated Configurators to support both Portlet 1.0 and Portlet 2.0 so that either container can be used and capabilities are modified accordingly
* Legacy wrappers for Portlet 1.0 Request/Response objects were removed. Porltet 1.0 Request/Response wrapping is now handled using Java Proxy objects. Portlet 2.0 request/response wrapping uses and created new Portlet 2.0 wrapper objects where appropriate
* Updated XmlHttpConfigurator to be a proper Configurator and took out several hacks, also added support for ResourceRequest/Response to support AJAX in Portlet 2.0 containers
Added:
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestType.java
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/pluto/
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/pluto/index.jsp
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/ContentTypeAndCharacterSet.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResourceResponse.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadActionInvocationHandler.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadActionRequestWrapper.java
- copied, changed from r762834, myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/ActionUploadRequestWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadRequestManager.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadResourceRequest.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpPortletExternalContext.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpResourceResponse.java
Removed:
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/ActionUploadRequestWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionRequestWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionResponseWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletRequestDispatcherWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletRequestWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletResponseWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/RenderRequestWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/RenderResponseWrapper.java
Modified:
myfaces/trinidad/trunk/pom.xml
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestStateMap.java
myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
myfaces/trinidad/trunk/trinidad-examples/pom.xml
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/pom.xml
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/index.jspx
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchRenderResponse.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchServletResponse.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadRequestWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpConfigurator.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpServletResponse.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/TrinidadPhaseListener.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletContextWrapper.java
myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
myfaces/trinidad/trunk/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.Configurator
Modified: myfaces/trinidad/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/pom.xml?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/pom.xml (original)
+++ myfaces/trinidad/trunk/pom.xml Mon May 11 18:32:44 2009
@@ -40,7 +40,7 @@
<!-- Standards -->
<jdk.version>1.5</jdk.version>
<servlet.version>2.5</servlet.version>
- <portlet.version>1.0</portlet.version>
+ <portlet.version>2.0</portlet.version>
<jsp.version>2.1</jsp.version>
<jstl.version>1.2</jstl.version>
<jsf-spec.version>1.2</jsf-spec.version>
@@ -49,6 +49,7 @@
<jsf-facelets.version>1.1.14</jsf-facelets.version>
<portlet-bridge.version>1.0.0-beta</portlet-bridge.version>
<commons-lang.version>2.4</commons-lang.version>
+ <pluto-embedded.version>1.0.1</pluto-embedded.version>
<!-- Testing -->
<shale.version>1.0.4</shale.version>
@@ -58,7 +59,8 @@
<!-- Plugins -->
<trinidad-plugins.version>1.2.10-SNAPSHOT</trinidad-plugins.version>
<wagon-plugin.version>1.0.6</wagon-plugin.version>
- <jetty-plugin.version>6.1.7</jetty-plugin.version>
+ <jetty-plugin.version>6.1.16</jetty-plugin.version>
+ <pluto-plugin.version>1.1.6</pluto-plugin.version>
<!-- Other -->
<jdev.release>11.1.1.0.0</jdev.release>
@@ -313,7 +315,13 @@
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>com.bekk.boss</groupId>
+ <artifactId>maven-jetty-pluto-embedded</artifactId>
+ <version>${pluto-embedded.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -451,6 +459,20 @@
</plugin>
<plugin>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>maven-pluto-plugin</artifactId>
+ <version>${pluto-plugin.version}</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>assemble</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
<configuration>
@@ -712,7 +734,7 @@
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>jstl</groupId>
+ <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
<scope>compile</scope>
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java Mon May 11 18:32:44 2009
@@ -21,10 +21,10 @@
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
+
import javax.faces.context.ExternalContext;
-import javax.portlet.ActionRequest;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletRequest;
+
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
@@ -32,61 +32,165 @@
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
/**
- * This provides some functionality for determining some things about the
+ * This provides some functionality for determining some things about the
* native request object that is not provided by the base utils.
*
- * @version $Revision$ $Date$
+ * @version 2.0
*/
public final class ExternalContextUtils
{
+
+ /**
+ * Returns <code>true</code> if a particular class relating to the supplied
+ * request type is available on the current classpath or <code>false</code>
+ * if it is not. This class assumes that all containers have a servlet type
+ * request available, but the portlet request types are all dependant on the
+ * portlet container being used.
+ *
+ * @param type the RequestType to test
+ * @return a boolean value of <code>true</code> if the container contains the
+ * request type in the classpath
+ * @since 2.0
+ */
+ public static final boolean isRequestTypeAvailable(RequestType type)
+ {
+ switch (type)
+ {
+ case SERVLET:
+ return true;
+
+ case ACTION:
+ case RENDER:
+ return _PORTLET_CONTEXT_CLASS != null;
+
+ case RESOURCE:
+ case EVENT:
+ return _PORTLET_RENDER_REQUEST_CLASS != null;
+
+ default:
+ return false;
+ }
+ }
/**
- * Returns the session ID for the client, or null if there is none.
- *
- * @param externalContext
- * @return
- */
- public static String getRequestedSessionId(final ExternalContext externalContext)
- {
- if (isPortlet(externalContext))
- {
- return ((PortletRequest) externalContext.getRequest()).getRequestedSessionId();
+ * Returns <code>true</code> if a particular request type is supported by the
+ * container. For a request type to be supported, the required objects must
+ * be on the classpath AND and, in the case of Portlet RequestTypes, an
+ * appropriate bridge must be avaialble which supports those objects. This
+ * means that if the supplied RequestType is RESOURCE, the
+ * javax.portlet.ResourceRequest object must be available on the classpath AND
+ * a bridge which supports the Portlet 2.0 specification would also need to be
+ * available.
+ *
+ * @param type the RequestType to test
+ * @return a boolean value of <code>true</code> if the container supports the
+ * current request type
+ * @since 2.0
+ */
+ public static final boolean isRequestTypeSupported(RequestType type)
+ {
+ switch (type)
+ {
+ case SERVLET:
+ return true;
+
+ case ACTION:
+ case RENDER:
+ return _PORTLET_10_SUPPORTED;
+
+ case RESOURCE:
+ case EVENT:
+ return _PORTLET_20_SUPPORTED;
+
+ default:
+ return false;
}
- else
+ }
+
+ /**
+ * Returns the requestType of this ExternalContext.
+ *
+ * @param ec the current external context
+ * @return the appropriate RequestType for this external context
+ * @see RequestType
+ * @since 2.0
+ */
+ public static final RequestType getRequestType(ExternalContext ec)
+ {
+ // Stuff is laid out strangely in this class in order to optimize
+ // performance. We want to do as few instanceof's as possible so
+ // things are laid out according to the expected frequency of the
+ // various requests occurring.
+ if(_PORTLET_10_SUPPORTED)
{
- return ((HttpServletRequest) externalContext.getRequest()).getRequestedSessionId();
+ if (_PORTLET_CONTEXT_CLASS.isInstance(ec.getContext()))
+ {
+ //We are inside of a portlet container
+ Object request = ec.getRequest();
+
+ if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request))
+ {
+ return RequestType.RENDER;
+ }
+
+ if(_PORTLET_RESOURCE_REQUEST_CLASS != null)
+ {
+ if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request))
+ {
+ return RequestType.ACTION;
+ }
+
+ // We are in a JSR-286 container
+ if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request))
+ {
+ return RequestType.RESOURCE;
+ }
+
+ return RequestType.EVENT;
+ }
+
+ return RequestType.ACTION;
+ }
}
+
+ return RequestType.SERVLET;
}
+
/**
- * Checks if the requested session ID is still valid
+ * Returns the session ID for the client, or <code>null</code> if there is none.
*
- * @param externalContext
- * @return
+ * @param ec the current external context
+ * @return a string containing the requestedSessionId
*/
- public static boolean isRequestedSessionIdValid(final ExternalContext externalContext)
+ public static String getRequestedSessionId(ExternalContext ec)
{
- if (isPortlet(externalContext))
- {
- return ((PortletRequest) externalContext.getRequest()).isRequestedSessionIdValid();
- }
- else
- {
- return ((HttpServletRequest) externalContext.getRequest()).isRequestedSessionIdValid();
- }
+ return (String) _runMethod(ec.getRequest(), "getRequestedSessionId");
+ }
+
+ /**
+ * Checks if the requested session ID is still valid.
+ *
+ * @param ec the current external context
+ * @return a boolean containing <code>true</code> if the request session is
+ * valid or <code>false</code> if it is not
+ */
+ public static boolean isRequestedSessionIdValid(ExternalContext ec)
+ {
+ return (Boolean) _runMethod(ec.getRequest(), "isRequestedSessionIdValid");
}
/**
- * Returns the contextPath of the ServletContext or null for portlets
+ * Returns the contextPath of the ServletContext or <code>null</code> for portlets
*
- * @param externalContext
- * @return
+ * @param ec the current external context
+ * @return a String containing the servletContextPath
*/
- public static String getServletContextPath(final ExternalContext externalContext)
+ public static String getServletContextPath(ExternalContext ec)
{
- if(!isPortlet(externalContext))
+ if(!isPortlet(ec))
{
- return ((ServletContext) externalContext.getContext()).getContextPath();
+ return ((ServletContext) ec.getContext()).getContextPath();
}
else
{
@@ -95,16 +199,22 @@
}
/**
- * Returns the contextPath of the ServletRequest or null for portlet requests
+ * Returns the contextPath of the ServletRequest or <code>null</code> for portlet requests
*
- * @param externalContext
- * @return
- */
- public static String getRequestContextPath(final ExternalContext externalContext)
- {
- if(!isPortlet(externalContext))
+ * @param ec the current external context
+ * @return a String containing the request context path
+ * @see ExternalContext#getRequestContextPath()
+ *
+ * @deprecated use ExternalContext.getRequestContextPath() as of JSF 1.2. This method
+ * does not appropriately handle portlet environments, but the functionality
+ * is maintained to prevent needing to change the contract.
+ */
+ @Deprecated
+ public static String getRequestContextPath(ExternalContext ec)
+ {
+ if(!isPortlet(ec))
{
- return ((HttpServletRequest) externalContext.getRequest()).getContextPath();
+ return ec.getRequestContextPath();
}
else
{
@@ -113,16 +223,17 @@
}
/**
- * Returns the requestURI of the HttpServletRequest or null for portlet requests
+ * Returns the requestURI of the HttpServletRequest or <code>null</code> for
+ * portlet requests
*
- * @param externalContext
- * @return
+ * @param ec the current external context
+ * @return A string containing the current request uri
*/
- public static String getRequestURI(final ExternalContext externalContext)
- {
- if (!isPortlet(externalContext))
+ public static String getRequestURI(ExternalContext ec)
+ {
+ if (!isPortlet(ec))
{
- return ((HttpServletRequest) externalContext.getRequest()).getRequestURI();
+ return ((HttpServletRequest) ec.getRequest()).getRequestURI();
}
else
{
@@ -131,52 +242,38 @@
}
/**
- * Returns the character encoding or null if there isn't any
+ * Returns the character encoding or <code>null</code> if there isn't any
*
- * @param externalContext
- * @return
+ * @param ec the current external context
+ * @return a string containing the request's character encoding
+ * @see ExternalContext#getRequestCharacterEncoding()
+ *
+ * @deprecated replaced by an API in JSF. Use ExternalContext.getRequestCharacterEncoding()
*/
- public static String getCharacterEncoding(final ExternalContext externalContext)
+ @Deprecated
+ public static String getCharacterEncoding(ExternalContext ec)
{
- if (isAction(externalContext))
- {
- try
- {
- if (isPortlet(externalContext))
- {
- // Allows us to not have the portal api's in the classpath
- return _getPortletCharacterEncoding(externalContext.getRequest());
- }
- else
- {
- return ((ServletRequest) externalContext.getRequest()).getCharacterEncoding();
- }
- }
- catch (final ClassCastException e)
- {
- _LOG.severe(e);
- }
- }
-
- return null;
+ return ec.getRequestCharacterEncoding();
}
/**
- * Returns the name of the underlying context
- * @param externalContext the ExternalContex
- * @return the name or null
+ * Returns the name of the underlying context or <code>null</code> if something
+ * went wrong in trying to retrieve the context.
+ *
+ * @param ec the current external context
+ * @return a String containing the context name
*/
- public static String getContextName(final ExternalContext externalContext)
+ public static String getContextName(ExternalContext ec)
{
try
{
- if (isPortlet(externalContext))
+ if (isPortlet(ec))
{
- return ((PortletContext) externalContext.getContext()).getPortletContextName();
+ return (String) _runMethod(ec.getContext(), "getPortletContextName");
}
else
{
- return ((ServletContext) externalContext.getContext()).getServletContextName();
+ return ((ServletContext) ec.getContext()).getServletContextName();
}
}
catch (final ClassCastException e)
@@ -189,137 +286,136 @@
/**
* Returns the content length or -1 if the unknown.
*
- * @param externalContext
- * the ExternalContext
- * @return the length or -1
+ * @param ec the current external context
+ * @return the length or -1 if the length is unknown
*/
- public static int getContentLength(final ExternalContext externalContext)
+ public static int getContentLength(ExternalContext ec)
{
- if (isAction(externalContext))
+ if(isRequestFromClient(ec))
{
- try
- {
- if (isPortlet(externalContext))
- {
- // Allows us to not have the portal api's in the classpath
- _getPortletContentLength(externalContext.getRequest());
- }
- else
- {
- return ((ServletRequest) externalContext.getRequest()).getContentLength();
- }
- }
- catch (final ClassCastException e)
- {
- _LOG.severe(e);
- }
+ return (Integer) _runMethod(ec.getRequest(), "getContentLength");
}
+
return -1;
}
/**
- * Returns the content type from the current externalContext or <code>null</code> if unknown.
+ * Returns the content type from the current externalContext or
+ * <code>null</code> if unknown.
+ *
+ * @param ec the current external context
+ * @return a String contining the the content type or <code>null</code>
+ * @see ExternalContext#getRequestContentType()
*
- * @param externalContext
- * the ExternalContext
- * @return the content type or <code>null</code>
+ * @deprecated use ExternalContext.getRequestContentType()
*/
- public static String getContentType(final ExternalContext externalContext)
+ @Deprecated
+ public static String getContentType(ExternalContext ec)
{
- if (isAction(externalContext))
- {
- try
- {
- if (isPortlet(externalContext))
- {
- // Allows us to not have the portal api's in the classpath
- return _getPortletContentType(externalContext.getRequest());
- }
- else
- {
- return ((ServletRequest) externalContext.getRequest()).getContentType();
- }
- }
- catch (final ClassCastException e)
- {
- // probably won't happen, but it could if we don't have a portlet OR a servlet container.
- _LOG.severe(e);
- }
- }
- return null;
+ return ec.getRequestContentType();
}
/**
* Returns the request input stream if one is available
*
- * @param externalContext
- * @return
- * @throws IOException
+ * @param ec the current external context
+ * @return the request's input stream
+ * @throws IOException if there was a problem getting the input stream
*/
- public static InputStream getRequestInputStream(final ExternalContext externalContext)
+ public static InputStream getRequestInputStream(ExternalContext ec)
throws IOException
- {
- if (isAction(externalContext))
+ {
+ RequestType type = getRequestType(ec);
+ if(type.isRequestFromClient())
{
- try
+ Object req = ec.getRequest();
+ if(type.isPortlet())
{
- if (isPortlet(externalContext))
- {
- // Allows us to not have the portal api's in the classpath
- return _getPortletInputStream(externalContext.getRequest());
- }
- else
- {
- return ((ServletRequest) externalContext.getRequest()).getInputStream();
- }
+ return (InputStream)_runMethod(req, "getPortletInputStream");
}
- catch (final ClassCastException e)
+ else
{
- _LOG.severe(e);
+ return ((ServletRequest) ec.getRequest()).getInputStream();
}
}
+
return null;
}
/**
- * Returns <code>true</code> if this externalContext represents an "action". An action request
- * is any ServletRequest or a portlet ActionRequest. It is assumed that the ExternalContext
+ * Returns <code>true</code> if this externalContext represents an "action".
+ * An action request is any ServletRequest or a portlet ActionRequest or
+ * ResourceRequest.
*
- * @return a boolean of <code>true</code> if this is a Portlet ActionRequest or an non-portlet
+ * @param ec the current external context
+ * @return a boolean of <code>true</code> if this request is an action-type
* request.
+ * @see #isRequestFromClient(ExternalContext)
+ *
+ * @deprecated replaced with {@link #isRequestFromClient(ExternalContext)}
*/
- public static boolean isAction(final ExternalContext externalContext)
+ public static boolean isAction(ExternalContext ec)
{
- final Object request = externalContext.getRequest();
-
- if (_PORTLET_ACTION_REQUEST_CLASS == null)
- {
- _LOG
- .fine("Portlet API's are not on the classpath so isAction will only check for servlet request.");
- return request instanceof ServletRequest;
- }
+ return isRequestFromClient(ec);
+ }
- return (!isPortlet(externalContext) && request instanceof ServletRequest) || _PORTLET_ACTION_REQUEST_CLASS.isInstance(request);
+ /**
+ * Returns the value of {@link RequestType#isPortlet()} for the current
+ * RequestType. This is a convenience function designed to perform a quick
+ * check of the current request. If more capabilities need to be tested for
+ * the given request, then it is more efficient to pull this information from
+ * the RequestType itself.
+ *
+ * @param ec the current external context
+ * @return a boolean value of <code>true</code> if the current RequestType
+ * is a portlet request.
+ *
+ * @see RequestType#isPortlet()
+ * @see #getRequestType(ExternalContext)
+ */
+ public static final boolean isPortlet(ExternalContext ec)
+ {
+ return getRequestType(ec).isPortlet();
}
/**
- * Returns whether or not this external context is from a Portlet or a Servlet.
- *
- * @param externalContext
- * the ExternalContext to check
- *
- * @return <code>true</code> if this is a portlet RenderRequest or ActionRequest and
- * <code>false<code> if it is not.
+ * Returns the value of {@link RequestType#isResponseWritable()} for the
+ * current RequestType. This is a convenience function designed to perform a
+ * quick check of the current request. If more capabilities need to be tested
+ * for the given request, then it is more efficient to pull this information
+ * from the RequestType itself.
+ *
+ * @param ec the current external context
+ * @return a boolean value of <code>true</code> if the current RequestType
+ * is a "render" type response.
+ *
+ * @see RequestType#isResponseWritable()
+ * @see #getRequestType(ExternalContext)
+ * @since 2.0
*/
- public static boolean isPortlet(final ExternalContext externalContext)
+ public static final boolean isResponseWritable(ExternalContext ec)
{
- if (_PORTLET_CONTEXT_CLASS == null)
- {
- _LOG.fine("Portlet API's are not on the classpath therefore isPortlet is false.");
- return false;
- }
+ return getRequestType(ec).isResponseWritable();
+ }
- return _PORTLET_CONTEXT_CLASS.isInstance(externalContext.getContext());
+ /**
+ * Returns the value of {@link RequestType#isRequestFromClient()} for the
+ * current RequestType. This is a convenience function designed to perform a
+ * quick check of the current request. If more capabilities need to be tested
+ * for the given request, then it is more efficient to pull this information
+ * from the RequestType itself.
+ *
+ * @param ec the current external context
+ * @return a boolean value of <code>true</code> if the current RequestType
+ * represents a request from the client.
+ *
+ * @see RequestType#isResponseWritable()
+ * @see #getRequestType(ExternalContext)
+ * @since 2.0
+ */
+ public static final boolean isRequestFromClient(ExternalContext ec)
+ {
+ return getRequestType(ec).isRequestFromClient();
}
/**
@@ -330,43 +426,37 @@
* a portlet request and, if not, then tests to see if the request is an instanceof
* HttpServletRequest.
*
- * @param request
- * @return
+ * @param ec the current external context
+ * @return a boolean value of <code>true</code> if the current request is an
+ * HttpServletRequest
+ * @since 1.1
*/
- public static boolean isHttpServletRequest(final ExternalContext externalContext)
- {
- return (!isPortlet(externalContext) && (externalContext.getRequest() instanceof HttpServletRequest));
- }
-
- private static final String _getPortletCharacterEncoding(final Object request)
+ public static boolean isHttpServletRequest(ExternalContext ec)
{
- if (!(request instanceof ActionRequest))
- return null;
-
- return ((ActionRequest) request).getCharacterEncoding();
- }
-
- private static final int _getPortletContentLength(final Object request)
- {
- if (!(request instanceof ActionRequest))
- return -1;
-
- return ((ActionRequest) request).getContentLength();
+ return (!isPortlet(ec) && (ec.getRequest() instanceof HttpServletRequest));
}
-
- private static final String _getPortletContentType(final Object request)
+
+ /**
+ * Runs a method on an object and returns the result
+ *
+ * @param obj the object to run the method on
+ * @param methodName the name of the method
+ * @return the results of the method run
+ */
+ private static Object _runMethod(Object obj, String methodName)
{
- if (!(request instanceof ActionRequest))
+ try
+ {
+ Method sessionIdMethod = sessionIdMethod = obj.getClass().getMethod(methodName);
+ return sessionIdMethod.invoke(obj);
+ }
+ catch (Exception e)
+ {
return null;
+ }
- return ((ActionRequest) request).getContentType();
- }
-
- private static final InputStream _getPortletInputStream(final Object request) throws IOException
- {
- return ((ActionRequest) request).getPortletInputStream();
}
-
+
// prevent this from being instantiated
private ExternalContextUtils()
{}
@@ -376,17 +466,37 @@
// =-= Scott O'Bryan =-=
// Performance enhancement. These will be needed anyway, let's not get them every time.
- private static final Class<?> _PORTLET_ACTION_REQUEST_CLASS;
- private static final Class<?> _PORTLET_CONTEXT_CLASS;
+ private static final Class<?> _PORTLET_ACTION_REQUEST_CLASS;
+ private static final Class<?> _PORTLET_RENDER_REQUEST_CLASS;
+ private static final Class<?> _PORTLET_RESOURCE_REQUEST_CLASS;
+ private static final Class<?> _PORTLET_CONTEXT_CLASS;
+ private static final boolean _PORTLET_10_SUPPORTED;
+ private static final boolean _PORTLET_20_SUPPORTED;
static
{
Class<?> context;
Class<?> actionRequest;
+ Class<?> renderRequest;
+ Class<?> resourceRequest;
+ boolean portlet20Supported = false;
+ boolean portlet10Supported = false;
+
try
{
context = ClassLoaderUtils.loadClass("javax.portlet.PortletContext");
actionRequest = ClassLoaderUtils.loadClass("javax.portlet.ActionRequest");
+ renderRequest = ClassLoaderUtils.loadClass("javax.portlet.RenderRequest");
+
+ try
+ {
+ resourceRequest = ClassLoaderUtils.loadClass("javax.portlet.ResourceRequest");
+ }
+ catch (ClassNotFoundException e)
+ {
+ _LOG.fine("Portlet 2.0 API is not available on classpath. Portlet 2.0 functionality is disabled");
+ resourceRequest = null;
+ }
}
catch (final ClassNotFoundException e)
{
@@ -394,9 +504,48 @@
.fine("Portlet API is not available on the classpath. Portlet configurations are disabled.");
context = null;
actionRequest = null;
+ renderRequest = null;
+ resourceRequest = null;
+ }
+
+ //Find bridge to tell if portal is supported
+ if(context != null)
+ {
+ try
+ {
+ Class<?> bridge = ClassLoaderUtils.loadClass("javax.portlet.faces.Bridge");
+
+ if(bridge != null)
+ {
+ portlet10Supported = true;
+
+ //Standard bridge defines a spec name which can be used to
+ //determine Portlet 2.0 Support.
+ String specName = bridge.getPackage().getSpecificationTitle();
+ _LOG.fine("Found Bridge: " + specName);
+ if(specName != null && specName.startsWith("Portlet 2"))
+ {
+ portlet20Supported = true;
+ }
+
+ if(_LOG.isInfo())
+ {
+ String ver = (portlet20Supported)?"2.0":"1.0";
+ _LOG.info("Portlet Environment Detected: " + ver);
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ _LOG.fine("Portlet API is present but bridge is not. Portlet configurations are disabled.");
+ }
}
_PORTLET_CONTEXT_CLASS = context;
_PORTLET_ACTION_REQUEST_CLASS = actionRequest;
+ _PORTLET_RENDER_REQUEST_CLASS = renderRequest;
+ _PORTLET_RESOURCE_REQUEST_CLASS = resourceRequest;
+ _PORTLET_10_SUPPORTED = portlet10Supported;
+ _PORTLET_20_SUPPORTED = portlet20Supported;
}
}
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestStateMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestStateMap.java?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestStateMap.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestStateMap.java Mon May 11 18:32:44 2009
@@ -38,7 +38,7 @@
//For now, always check this on a render so it can be removed from the session.
//This can be optimized to only save the state when request attributes are NOT preserved
- if(!ExternalContextUtils.isAction(ec))
+ if(!ExternalContextUtils.isRequestFromClient(ec))
{
String uuid = ec.getRequestParameterMap().get(_STATE_MAP);
if(uuid!= null)
@@ -68,7 +68,8 @@
public void saveState(ExternalContext ec)
{
- if(ExternalContextUtils.isPortlet(ec) && ExternalContextUtils.isAction(ec))
+ RequestType type = ExternalContextUtils.getRequestType(ec);
+ if(type.isPortlet() && !type.isResponseWritable())
{
try
{
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestType.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestType.java?rev=773647&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestType.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/RequestType.java Mon May 11 18:32:44 2009
@@ -0,0 +1,126 @@
+/*
+ * 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.trinidad.util;
+
+/**
+ * Represents the type of request currently in the ExternalContext.
+ * All servlet requests will be of the SERVLET requestType whereas
+ * all of the other RequestTypes will be portlet type requests. There
+ * are a number of convenience methods on the RequestType enumeration
+ * which can be used to determine the capabilities of the current request.
+ */
+public enum RequestType
+{
+ /**
+ * The type for all servlet requests. SERVLET request types are
+ * both client requests and response writable.
+ */
+ SERVLET(true, true, false),
+
+ /**
+ * The type for a portlet RenderRequest. RENDER request types are
+ * for portlets and are response writable but are NOT client
+ * requests.
+ */
+ RENDER(false, true, true),
+
+ /**
+ * The type for a portlet ActionRequest. ACTION request types are
+ * for portlets and are client requests but are NOT response
+ * writable.
+ */
+ ACTION(true, false, true),
+
+ /**
+ * The type for a portlet ResourceRequest. RESOURCE request types
+ * are for portlets and are both client requests and response
+ * writable. RESOURCE request types will only be returned in a
+ * Portlet 2.0 portlet container.
+ */
+ RESOURCE(true, true, true),
+
+ /**
+ * The type for a portlet EventRequest. EVENT request types
+ * are for portlets and are neither client requests nor response
+ * writable. EVENT request types will only be returned in a
+ * Portlet 2.0 portlet container.
+ */
+ EVENT(false, false, true);
+
+ private boolean _client;
+ private boolean _writable;
+ private boolean _portlet;
+
+ RequestType(boolean client, boolean writable, boolean portlet)
+ {
+ _client = client;
+ _writable = writable;
+ _portlet = portlet;
+ }
+
+ /**
+ * Returns <code>true</code> if this request was a direct
+ * result of a call from the client. This implies that
+ * the current application is the "owner" of the current
+ * request and that it has access to the inputStream, can
+ * get and set character encodings, etc. Currently all
+ * SERVLET, ACTION, and RESOURCE RequestTypes are client
+ * requests.
+ *
+ * @return <code>true</code> if the current request is a
+ * client data type request and <code>false</code>
+ * if it is not.
+ */
+ public boolean isRequestFromClient()
+ {
+ return _client;
+ }
+
+ /**
+ * Returns <code>true</code> if the response for this
+ * RequestType is intended to produce output to the client.
+ * Currently the SERVLET, RENDER, and RESOURCE request are
+ * response writable.
+ *
+ * @return <code>true</code> if the current request is
+ * intended to produce output and <code>false</code>
+ * if it is not.
+ */
+ public boolean isResponseWritable()
+ {
+ return _writable;
+ }
+
+ /**
+ * Returns <code>true</code> if the response for this
+ * RequestType originated from a JSR-168 or JSR-286
+ * portlet container. Currently RENDER, ACTION,
+ * RESOURCE, and EVENT RequestTypes are all portlet
+ * requests.
+ *
+ * @return <code>true</code> if the current request
+ * originated inside of a JSR-168 or JSR-286
+ * Portlet Container or <code>false</code> if
+ * it did not.
+ */
+ public boolean isPortlet()
+ {
+ return _portlet;
+ }
+}
\ No newline at end of file
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts Mon May 11 18:32:44 2009
@@ -447,4 +447,7 @@
<!-- COMPONENT_TREE_SERIALIZATION_FAILED -->
<resource key="COMPONENT_TREE_SERIALIZATION_FAILED">Failed to serialize component tree state</resource>
+<!-- UNABLE_TO_SET_RENDER_PARAMETERS -->
+<resource key="UNABLE_TO_SET_RENDER_PARAMETERS">Unable ro set portlet render parameters due to failed reflection</resource>
+
</resources>
Modified: myfaces/trinidad/trunk/trinidad-examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/pom.xml?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/pom.xml (original)
+++ myfaces/trinidad/trunk/trinidad-examples/pom.xml Mon May 11 18:32:44 2009
@@ -46,6 +46,11 @@
</repository>
</repositories>
+ <properties>
+ <portlet.version>1.0</portlet.version>
+ </properties>
+
+
<!-- Project dependencies -->
<dependencies>
<!-- Apache Trinidad -->
@@ -78,6 +83,11 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ </dependency>
</dependencies>
<modules>
@@ -110,34 +120,29 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>${jsf-ri.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>${jsf-ri.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
- <version>${jsf-myfaces.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
- <version>${jsf-myfaces.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
-
<!--
This profile activates MyFaces as the release to use for these demos. By default
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/pom.xml?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/pom.xml (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/pom.xml Mon May 11 18:32:44 2009
@@ -12,6 +12,8 @@
<artifactId>trinidad-demo</artifactId>
<packaging>war</packaging>
+
+
<dependencies>
@@ -43,6 +45,11 @@
<artifactId>jsp-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ </dependency>
+
<!-- For SourceCodeServlet -->
<dependency>
<groupId>commons-lang</groupId>
@@ -65,20 +72,204 @@
</build>
<profiles>
- <profile>
- <id>jettyConfig</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.11</version>
- <configuration>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- </configuration>
- </plugin>
+ <profile>
+ <id>jettyConfig</id>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>${jsf-ri.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>${jsf-ri.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>${jsf-myfaces.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>${jsf-myfaces.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- sets up the webapp for deployment to pluto "mvn clean install -Ppluto" -->
+ <profile>
+ <id>pluto</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge-api</artifactId>
+ <version>${portlet-bridge.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge-impl</artifactId>
+ <version>${portlet-bridge.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto-util</artifactId>
+ <version>${pluto-plugin.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- configure maven-war-plugin to use updated web.xml -->
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>maven-pluto-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</profile>
+
+ <!-- To run jetty, issue "mvn clean -PjettyConfig jetty:run" -->
+ <profile>
+ <id>pluto-embedded</id>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>${jsf-ri.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>${jsf-ri.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>${jsf-myfaces.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <scope>runtime</scope>
+ <version>${jsf-myfaces.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>${portlet.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.bekk.boss</groupId>
+ <artifactId>maven-jetty-pluto-embedded</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+ <webDefaultXml>src/main/webapp/WEB-INF/jetty-pluto-web-default.xml</webDefaultXml>
+ <systemProperties>
+ <systemProperty>
+ <name>org.apache.pluto.embedded.portletIds</name>
+ <value>trinidad_demo</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>maven-pluto-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- Runs the portal testcases in Pluto 2.0 -->
+ <profile>
+ <id>portlet20</id>
+ <activation>
+ <property>
+ <name>portlet</name>
+ <value>2.0</value>
+ </property>
+ </activation>
+ <repositories>
+ <repository>
+ <id>BOSS inhouse private</id>
+ <url>http://boss.bekk.no/proximity/repository/private</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <properties>
+ <portlet-bridge.version>2.0.0-SNAPSHOT</portlet-bridge.version>
+ <pluto-embedded.version>2.0-SNAPSHOT</pluto-embedded.version>
+ <portlet.version>2.0</portlet.version>
+ <pluto-plugin.version>2.0.0-SNAPSHOT</pluto-plugin.version>
+ </properties>
+ </profile>
</profiles>
</project>
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/index.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/index.jspx?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/index.jspx (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/index.jspx Mon May 11 18:32:44 2009
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/pluto/index.jsp
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/pluto/index.jsp?rev=773647&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/pluto/index.jsp (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/pluto/index.jsp Mon May 11 18:32:44 2009
@@ -0,0 +1,105 @@
+<!--
+ 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.
+
+-->
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://portals.apache.org/pluto" prefix="pluto" %>
+
+<html>
+<head>
+ <title>Pluto Portal</title>
+ <style type="text/css" title="currentStyle" media="screen">
+ @import "<c:out value="${pageContext.request.contextPath}"/>/pluto.css";
+ @import "<c:out value="${pageContext.request.contextPath}"/>/portlet-spec-1.0.css";
+ <c:forEach items="${org_apache_pluto_embedded_extraStyles}" var="style">
+ @import "<c:out value="${pageContext.request.contextPath}"/><c:out value="${style}"/>";
+ </c:forEach>
+ </style>
+ <script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/pluto.js">
+ </script>
+</head>
+
+<body>
+
+<div id="portal">
+
+ <!-- Header block: the Apache Pluto banner image and description -->
+ <div id="header">
+ <h1>Apache Pluto</h1>
+
+ <p>An Apache Portals Project</p>
+ </div>
+
+ <!-- Logout link -->
+ <c:if test="${pageContext.request.remoteUser != null}">
+ <div id="logout">
+ <a href="<c:url value='/Logout'/>">Logout</a>
+ </div>
+ </c:if>
+
+ <!-- Content block: portlets are divided into two columns/groups -->
+ <div id="content">
+ <pluto:isMaximized var="isMax"/>
+
+ <!-- Left column -->
+ <c:choose>
+ <c:when test="${isMax}">
+ <c:forEach var="portlet" varStatus="status"
+ items="${org_apache_pluto_embedded_portletIds}">
+ <c:set var="portlet" value="${portlet}" scope="request"/>
+ <jsp:include page="/WEB-INF/themes/portlet-skin.jsp"/>
+ </c:forEach>
+ </c:when>
+
+ <c:otherwise>
+ <div id="portlets-left-column">
+ <c:forEach var="portlet" varStatus="status"
+ items="${org_apache_pluto_embedded_portletIds}" step="2">
+ <c:set var="portlet" value="${portlet}" scope="request"/>
+ <jsp:include page="/WEB-INF/themes/portlet-skin.jsp"/>
+ </c:forEach>
+ </div>
+
+ <!-- Right column -->
+ <div id="portlets-right-column">
+ <c:forEach var="portlet" varStatus="status"
+ items="${org_apache_pluto_embedded_portletIds}" begin="1" step="2">
+ <c:set var="portlet" value="${portlet}" scope="request"/>
+ <jsp:include page="/WEB-INF/themes/portlet-skin.jsp"/>
+ </c:forEach>
+ </div>
+
+ </c:otherwise>
+ </c:choose>
+
+ </div>
+
+
+
+ <!-- Footer block: copyright -->
+ <div id="footer">
+ © 2003-2005 Apache Software Foundation
+ </div>
+
+</div>
+
+</body>
+
+</html>
+
+
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java Mon May 11 18:32:44 2009
@@ -51,6 +51,7 @@
import org.apache.myfaces.trinidadinternal.skin.SkinUtils;
import org.apache.myfaces.trinidad.util.ExternalContextUtils;
import org.apache.myfaces.trinidad.util.RequestStateMap;
+import org.apache.myfaces.trinidad.util.RequestType;
/**
* This is the implementation of the Trinidad's Global configurator. It provides the entry point for
@@ -63,7 +64,8 @@
* @see org.apache.myfaces.trinidad.config.Configurator
* @version $Revision$ $Date$
*/
-public final class GlobalConfiguratorImpl extends Configurator
+public final class GlobalConfiguratorImpl
+ extends Configurator
{
/**
* Returns a GlobalConfigurator instance for the current context's class loader. The
@@ -122,9 +124,9 @@
* @param ec
* @return
*/
- static public boolean isRequestStarted(final ExternalContext ec)
+ static public boolean isRequestStarted(ExternalContext ec)
{
- return (RequestType.getType(ec) != null);
+ return (RequestStateMap.getInstance(ec).get(_REQUEST_TYPE) != null);
}
/**
@@ -146,8 +148,7 @@
final boolean disabled = inRequest.booleanValue();
if (disabled != isConfiguratorServiceDisabled(ec))
{
- _LOG
- .warning("Configurator services were disabled after beginRequest was executed. Cannot disable configurator services");
+ _LOG.warning("Configurator services were disabled after beginRequest was executed. Cannot disable configurator services");
}
return disabled;
@@ -159,7 +160,8 @@
* required, we may wish to make this public. We really don't want people using this though.
*/
private GlobalConfiguratorImpl()
- {}
+ {
+ }
/**
* Executes the beginRequest methods of all of the configurator services. This method will also
@@ -172,41 +174,43 @@
* render request so that the requestContext may be properly initialized even though the
* underlying services will be called only once per physical request.
*
- * @param externalContext
- * the externalContext to use to begin the request.
+ * @param ec the externalContext to use to begin the request.
*
- * @see org.apache.myfaces.trinidad.config.Configurator#beginRequest(javax.faces.context.ExternalContext)
+ * @see Configurator#beginRequest(javax.faces.context.ExternalContext)
*/
@SuppressWarnings("unchecked") // TODO: remove this for Faces 1.2
@Override
- public void beginRequest(final ExternalContext externalContext)
+ public void beginRequest(ExternalContext ec)
{
// asserts for debug which disappear in production
- assert externalContext != null;
+ assert ec != null;
+ RequestStateMap state = RequestStateMap.getInstance(ec);
+ RequestType requestType = (RequestType) state.get(_REQUEST_TYPE);
// Do per-virtual request stuff
- if (RequestType.getType(externalContext) == null)
+ if (requestType == null)
{
// RequestType may change in a portal environment. Make sure it's set up to enforce the
// contracts
- RequestType.setType(externalContext);
+ requestType = ExternalContextUtils.getRequestType(ec);
+ RequestStateMap.getInstance(ec).put(_REQUEST_TYPE, requestType);
// By contract, Configurators beginRequest is only called once per physical request.
// The globalConfigurator may be called multiple times, however, so we need to enforce
// the contract.
- if (!_isDisabled(externalContext))
+ if (!_isDisabled(ec))
{
// If this hasn't been initialized then please initialize
if (!_initialized)
{
- init(externalContext);
+ init(ec);
}
- _attachRequestContext(externalContext);
+ _attachRequestContext(ec);
- if (RequestStateMap.getInstance(externalContext).get(_IN_REQUEST) == null)
+ if (state.get(_IN_REQUEST) == null)
{
- _startConfiguratorServiceRequest(externalContext);
+ _startConfiguratorServiceRequest(ec);
}
}
else
@@ -214,7 +218,7 @@
_LOG.fine("GlobalConfigurator: Configurators have been disabled for this request.");
}
}
- else if (!RequestType.isCorrectType(externalContext))
+ else if (!requestType.equals(ExternalContextUtils.getRequestType(ec)))
{
// This will happen if the actionRequest was not ended before dispatching to the render
// request
@@ -244,7 +248,7 @@
{
try
{
- for (final Configurator config : _services)
+ for (final Configurator config: _services)
{
try
{
@@ -274,31 +278,31 @@
* @see org.apache.myfaces.trinidad.config.Configurator#endRequest(javax.faces.context.ExternalContext)
*/
@Override
- public void endRequest(final ExternalContext externalContext)
+ public void endRequest(ExternalContext ec)
{
+ RequestStateMap state = RequestStateMap.getInstance(ec);
+
// do per virtual-request stuff
- if (RequestType.getType(externalContext) != null)
+ if (state.get(_REQUEST_TYPE) != null)
{
- if (!_isDisabled(externalContext))
+ if (!_isDisabled(ec))
{
try
{
- final RequestType type = RequestType.getType(externalContext);
-
- // Do not end services at the end of a portal action request
- if (type != RequestType.PORTAL_ACTION)
+ //Only end services at the end of a writable response. This will
+ //generally be RENDER, RESOURCE, and SERVLET.
+ if (ExternalContextUtils.isResponseWritable(ec))
{
- _endConfiguratorServiceRequest(externalContext);
+ _endConfiguratorServiceRequest(ec);
}
}
finally
{
- RequestStateMap.getInstance(externalContext).saveState(externalContext);
- _releaseRequestContext(externalContext);
- _releaseManagedThreadLocals();
+ state.saveState(ec);
+ _releaseRequestContext(ec);
}
}
- RequestType.clearType(externalContext);
+ state.remove(_REQUEST_TYPE);
}
}
@@ -309,22 +313,30 @@
* to be explicitly called, {{@link #endRequest(ExternalContext)} does need to be called when the
* request has completed or the contract to the configurators will be broken.
*
- * @param externalContext
+ * @param ec
* the ExternalContext object that should be wrapped.
*
* @return a decorated ExternalContext object
*/
@Override
- public ExternalContext getExternalContext(ExternalContext externalContext)
+ public ExternalContext getExternalContext(ExternalContext ec)
{
- if (RequestType.getType(externalContext) == null)
+ RequestStateMap state = RequestStateMap.getInstance(ec);
+ RequestType type = (RequestType) state.get(_REQUEST_TYPE);
+
+ if (type == null)
{
- beginRequest(externalContext);
+ beginRequest(ec);
+ type = (RequestType) state.get(_REQUEST_TYPE);
+ }
+ else if (!ExternalContextUtils.getRequestType(ec).equals(type))
+ {
+ throw new IllegalStateException("The expected request type is not the same as the current request type.");
}
- if (!_isDisabled(externalContext))
+ if (!_isDisabled(ec))
{
- if(!ExternalContextUtils.isPortlet(externalContext) && _isSetRequestBugPresent(externalContext))
+ if (!type.isPortlet() && _isSetRequestBugPresent(ec))
{
//This handles bug 493 against the JSF-RI 1.2_03 and earlier. If the bug
//is present in the current system, add a wrapper to fix it
@@ -332,17 +344,17 @@
//TODO sobryan this is somewhat inefficient so should be removed when we
//are no longer dependant on JSF1.2_03 or earlier. Still, we only wrap
//when we have to so it should be no biggy under normal circumstances.
- externalContext = new ClearRequestExternalContext(externalContext);
+ ec = new ClearRequestExternalContext(ec);
}
// Wrap ExternalContexts
- for (final Configurator config : _services)
+ for (Configurator config: _services)
{
- externalContext = config.getExternalContext(externalContext);
+ ec = config.getExternalContext(ec);
}
}
- return externalContext;
+ return ec;
}
/**
@@ -352,52 +364,52 @@
* happened then a call to this method will not do anything. To re-initialize this class, call
* {@link #destroy()} first and then call this method.
*
- * @param externalContext
+ * @param ec
* the externalContext needed to initialize this class
*
* @see org.apache.myfaces.trinidad.config.Configurator#init(javax.faces.context.ExternalContext)
*/
@Override
- public void init(final ExternalContext externalContext)
+ public void init(ExternalContext ec)
{
- assert externalContext != null;
+ assert ec != null;
if (!_initialized)
{
try
{
_services = ClassLoaderUtils.getServices(Configurator.class.getName());
-
+
// Create a new RequestContextFactory is needed
if (RequestContextFactory.getFactory() == null)
{
RequestContextFactory.setFactory(new RequestContextFactoryImpl());
}
-
+
// Create a new SkinFactory if needed.
if (SkinFactory.getFactory() == null)
{
SkinFactory.setFactory(new SkinFactoryImpl());
}
-
+
// register the base skins
SkinUtils.registerBaseSkins();
-
- for (final Configurator config : _services)
+
+ for (final Configurator config: _services)
{
- config.init(externalContext);
+ config.init(ec);
}
-
+
// after the 'services' filters are initialized, then register
// the skin extensions found in trinidad-skins.xml. This
// gives a chance to the 'services' filters to create more base
// skins that the skins in trinidad-skins.xml can extend.
- SkinUtils.registerSkinExtensions(externalContext);
+ SkinUtils.registerSkinExtensions(ec);
_initialized = true;
}
finally
{
-
+
//Do cleanup of anything which may have use the thread local manager durring
//init.
_releaseManagedThreadLocals();
@@ -418,16 +430,16 @@
{
if (resetter == null)
throw new NullPointerException();
-
+
_threadResetter.set(resetter);
}
-
+
/**
- * @param externalContext
+ * @param ec
* @return
*/
@SuppressWarnings("unchecked")
- private void _attachRequestContext(final ExternalContext externalContext)
+ private void _attachRequestContext(ExternalContext ec)
{
// If someone didn't release the RequestContext on an earlier request,
// then it'd still be around, and trying to create a new one
@@ -440,70 +452,67 @@
{
_LOG.warning("REQUESTCONTEXT_NOT_PROPERLY_RELEASED");
}
- context.release();
- _releaseManagedThreadLocals();
+ _releaseRequestContext(ec);
}
-
+
// See if we've got a cached RequestContext instance; if so,
// reattach it
- final Object cachedRequestContext = RequestStateMap.getInstance(externalContext).get(
- _REQUEST_CONTEXT);
+ Object cachedRequestContext = RequestStateMap.getInstance(ec).get(_REQUEST_CONTEXT);
// Catch both the null scenario and the
// RequestContext-from-a-different-classloader scenario
if (cachedRequestContext instanceof RequestContext)
{
context = (RequestContext) cachedRequestContext;
- context.attach();
}
else
{
- final RequestContextFactory factory = RequestContextFactory.getFactory();
+ RequestContextFactory factory = RequestContextFactory.getFactory();
assert factory != null;
- context = factory.createContext(externalContext);
- RequestStateMap.getInstance(externalContext).put(_REQUEST_CONTEXT, context);
+ context = factory.createContext(ec);
+ RequestStateMap.getInstance(ec).put(_REQUEST_CONTEXT, context);
}
-
assert RequestContext.getCurrentInstance() == context;
}
- private void _releaseRequestContext(final ExternalContext ec)
+ private void _releaseRequestContext(ExternalContext ec)
{
- //If it's not a portal action, we should remove the cached request because
- //well want to create a new one next request
- if(RequestType.getType(ec) != RequestType.PORTAL_ACTION)
- {
- RequestStateMap.getInstance(ec).remove(_REQUEST_CONTEXT);
- }
-
- final RequestContext context = RequestContext.getCurrentInstance();
+ RequestContext context = RequestContext.getCurrentInstance();
if (context != null)
{
context.release();
+ _releaseManagedThreadLocals();
assert RequestContext.getCurrentInstance() == null;
}
}
- private void _releaseManagedThreadLocals()
+ private void _releaseManagedThreadLocals()
{
ThreadLocalResetter resetter = _threadResetter.get();
-
+
if (resetter != null)
{
resetter.__removeThreadLocals();
}
}
-
+
private void _endConfiguratorServiceRequest(final ExternalContext ec)
{
// Physical request has now ended
// Clear the in-request flag
RequestStateMap.getInstance(ec).remove(_IN_REQUEST);
- if(_services != null)
+ if (_services != null)
{
- for (final Configurator config : _services)
+ for (Configurator config: _services)
{
- config.endRequest(ec);
+ try
+ {
+ config.endRequest(ec);
+ }
+ catch (Throwable t)
+ {
+ _LOG.severe(t);
+ }
}
}
}
@@ -518,9 +527,16 @@
RequestStateMap.getInstance(ec).put(_IN_REQUEST, disabled);
// If this hasn't been initialized then please initialize
- for (final Configurator config : _services)
+ for (Configurator config: _services)
{
- config.beginRequest(ec);
+ try
+ {
+ config.beginRequest(ec);
+ }
+ catch (Throwable t)
+ {
+ _LOG.severe(t);
+ }
}
}
@@ -528,16 +544,16 @@
{
// This first check is here in order to skip synchronization until
// absolutely necessary.
- if(!_sSetRequestBugTested)
+ if (!_sSetRequestBugTested)
{
- synchronized(GlobalConfiguratorImpl.class)
+ synchronized (GlobalConfiguratorImpl.class)
{
//This second check is here in case a couple of things enter before the
//boolean is set. This is only an exception case and will make it so
//the initialization code runs only once.
- if(!_sSetRequestBugTested)
+ if (!_sSetRequestBugTested)
{
- ServletRequest orig = (ServletRequest)ec.getRequest();
+ ServletRequest orig = (ServletRequest) ec.getRequest();
// Call getInitParameterMap() up front
ec.getInitParameterMap();
@@ -556,15 +572,17 @@
// This handles an issue with the ExternalContext object prior to
// JSF1.2_04.
- static private class ClearRequestExternalContext extends ExternalContextDecorator
+
+ static private class ClearRequestExternalContext
+ extends ExternalContextDecorator
{
private ExternalContext _ec;
- private Map<String, Object> _requestCookieMap;
- private Map<String, String> _requestHeaderMap;
- private Map<String, String[]> _requestHeaderValuesMap;
- private Map<String, Object> _requestMap;
- private Map<String, String> _requestParameterMap;
- private Map<String, String[]> _requestParameterValuesMap;
+ private Map<String, Object> _requestCookieMap;
+ private Map<String, String> _requestHeaderMap;
+ private Map<String, String[]> _requestHeaderValuesMap;
+ private Map<String, Object> _requestMap;
+ private Map<String, String> _requestParameterMap;
+ private Map<String, String[]> _requestParameterValuesMap;
public ClearRequestExternalContext(ExternalContext ec)
{
@@ -630,7 +648,7 @@
_checkRequest();
if (_requestMap == null)
{
- _requestMap = new ServletRequestMap((ServletRequest)getRequest());
+ _requestMap = new ServletRequestMap((ServletRequest) getRequest());
}
return _requestMap;
}
@@ -641,7 +659,7 @@
_checkRequest();
if (_requestParameterMap == null)
{
- _requestParameterMap = new ServletRequestParameterMap((ServletRequest)getRequest());
+ _requestParameterMap = new ServletRequestParameterMap((ServletRequest) getRequest());
}
return _requestParameterMap;
}
@@ -652,14 +670,15 @@
_checkRequest();
if (_requestParameterValuesMap == null)
{
- _requestParameterValuesMap = new ServletRequestParameterValuesMap((ServletRequest)getRequest());
+ _requestParameterValuesMap =
+ new ServletRequestParameterValuesMap((ServletRequest) getRequest());
}
return _requestParameterValuesMap;
}
private void _checkRequest()
{
- if(super.getRequest() == null)
+ if (super.getRequest() == null)
{
throw new UnsupportedOperationException("Request is null on this context.");
}
@@ -668,12 +687,12 @@
private HttpServletRequest _getHttpServletRequest()
{
_checkRequest();
- if ( !(getRequest() instanceof HttpServletRequest))
+ if (!(getRequest() instanceof HttpServletRequest))
{
- throw new IllegalArgumentException("Only HttpServletRequest supported");
+ throw new IllegalArgumentException("Only HttpServletRequest supported");
}
- return (HttpServletRequest)getRequest();
+ return (HttpServletRequest) getRequest();
}
}
@@ -681,69 +700,19 @@
private static volatile boolean _sSetRequestBugTested = false;
private static boolean _sHasSetRequestBug = false;
- private boolean _initialized;
- private List<Configurator> _services;
+ private boolean _initialized;
+ private List<Configurator> _services;
static private final Map<ClassLoader, GlobalConfiguratorImpl> _CONFIGURATORS =
- new HashMap<ClassLoader, GlobalConfiguratorImpl>();
- static private final String _IN_REQUEST =
- GlobalConfiguratorImpl.class.getName()
- + ".IN_REQUEST";
+ new HashMap<ClassLoader, GlobalConfiguratorImpl>();
+ static private final String _IN_REQUEST =
+ GlobalConfiguratorImpl.class.getName() + ".IN_REQUEST";
static private final String _REQUEST_CONTEXT =
- GlobalConfiguratorImpl.class.getName()
- + ".REQUEST_CONTEXT";
-
-
- private enum RequestType
- {
- PORTAL_ACTION,
- PORTAL_RENDER,
- SERVLET;
-
- public static void clearType(final ExternalContext ec)
- {
- RequestStateMap.getInstance(ec).remove(_REQUEST_TYPE);
- }
-
- public static RequestType getType(final ExternalContext ec)
- {
- return (RequestType) RequestStateMap.getInstance(ec).get(_REQUEST_TYPE);
- }
-
- public static boolean isCorrectType(final ExternalContext ec)
- {
- return _findType(ec) == getType(ec);
- }
-
- @SuppressWarnings("unchecked")
- public static void setType(final ExternalContext ec)
- {
- RequestStateMap.getInstance(ec).put(_REQUEST_TYPE, _findType(ec));
- }
-
- private static final RequestType _findType(final ExternalContext ec)
- {
- if (ExternalContextUtils.isPortlet(ec))
- {
- if (ExternalContextUtils.isAction(ec))
- {
- return PORTAL_ACTION;
- }
- else
- {
- return PORTAL_RENDER;
- }
- }
- else
- {
- return SERVLET;
- }
- }
-
- static private final String _REQUEST_TYPE = GlobalConfiguratorImpl.class.getName()
- + ".REQUEST_TYPE";
- }
+ GlobalConfiguratorImpl.class.getName() + ".REQUEST_CONTEXT";
+ static private final String _REQUEST_TYPE =
+ GlobalConfiguratorImpl.class.getName() + ".REQUEST_TYPE";
- static private class TestRequest extends ServletRequestWrapper
+ static private class TestRequest
+ extends ServletRequestWrapper
{
public TestRequest(ServletRequest request)
{
@@ -753,7 +722,7 @@
@Override
public String getParameter(String string)
{
- if(_TEST_PARAM.equals(string))
+ if (_TEST_PARAM.equals(string))
{
return "passed";
}
@@ -766,14 +735,13 @@
return RequestStateMap.getInstance(ec).get(_TEST_PARAM) != null;
}
- static private String _TEST_PARAM = TestRequest.class.getName()+
- ".TEST_PARAM";
+ static private String _TEST_PARAM = TestRequest.class.getName() + ".TEST_PARAM";
}
// hacky reference to the ThreadLocalResetter used to clean up request-scoped
// ThreadLocals
- private AtomicReference<ThreadLocalResetter> _threadResetter =
- new AtomicReference<ThreadLocalResetter>();
+ private AtomicReference<ThreadLocalResetter> _threadResetter =
+ new AtomicReference<ThreadLocalResetter>();
static private final TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(GlobalConfiguratorImpl.class);
Added: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/ContentTypeAndCharacterSet.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/ContentTypeAndCharacterSet.java?rev=773647&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/ContentTypeAndCharacterSet.java (added)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/ContentTypeAndCharacterSet.java Mon May 11 18:32:44 2009
@@ -0,0 +1,80 @@
+/*
+ * 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.trinidadinternal.config.dispatch;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.myfaces.trinidad.context.Agent;
+import org.apache.myfaces.trinidad.context.RenderingContext;
+
+class ContentTypeAndCharacterSet
+{
+ ContentTypeAndCharacterSet(String contentTypeAndCharset)
+ {
+ if(contentTypeAndCharset != null)
+ {
+ Matcher matcher = _CONTENT_TYPE_PATTERN.matcher(contentTypeAndCharset);
+ if (matcher.matches())
+ {
+ _contentType = matcher.group(1);
+ _characterSet = (matcher.groupCount() > 1) ? matcher.group(2) : null;
+
+ if ("application/xhtml+xml".equals(_contentType))
+ {
+ //TODO: Is this still needed in IE7??
+ Agent agent = RenderingContext.getCurrentInstance().getAgent();
+ if (agent != null && Agent.AGENT_IE.equals(agent.getAgentName()))
+ {
+ // IE must serve XHTML as text/html
+ contentTypeAndCharset = "text/html";
+
+ if (_characterSet != null)
+ contentTypeAndCharset += ";charset=" + _characterSet;
+ }
+ }
+ }
+ }
+ _contentTypeAndCharset = contentTypeAndCharset;
+ }
+
+ public String getContentType()
+ {
+ return _contentType;
+ }
+
+ public String getCharacterSet()
+ {
+ return _characterSet;
+ }
+
+ @Override
+ public String toString()
+ {
+ return _contentTypeAndCharset;
+ }
+
+ private String _contentType;
+ private String _characterSet;
+ private String _contentTypeAndCharset;
+
+ static private final Pattern _CONTENT_TYPE_PATTERN =
+ Pattern.compile("([^;]+)(?:;charset=(.*))?");
+
+}
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchRenderResponse.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchRenderResponse.java?rev=773647&r1=773646&r2=773647&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchRenderResponse.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchRenderResponse.java Mon May 11 18:32:44 2009
@@ -18,15 +18,14 @@
*/
package org.apache.myfaces.trinidadinternal.config.dispatch;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import javax.faces.context.ExternalContext;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.filter.RenderResponseWrapper;
-import org.apache.myfaces.trinidadinternal.webapp.wrappers.RenderResponseWrapper;
-
+/**
+ * This class is for Portlet 2.0 compatibility and it uses the real RenderResponseWrapper
+ */
@SuppressWarnings("deprecation")
class DispatchRenderResponse extends RenderResponseWrapper
{
@@ -35,43 +34,18 @@
super((RenderResponse)ec.getResponse());
_request = (RenderRequest)ec.getRequest();
}
-
+
@Override
- public void setContentType(
- String contentTypeAndCharset)
+ public void setContentType(String contentTypeAndCharset)
{
- if(contentTypeAndCharset != null)
+ ContentTypeAndCharacterSet ct = new ContentTypeAndCharacterSet(contentTypeAndCharset);
+
+ if(ct.getContentType() != null)
{
- Matcher matcher = _CONTENT_TYPE_PATTERN.matcher(contentTypeAndCharset);
- if (matcher.matches())
- {
- String contentType = matcher.group(1);
- String charset = (matcher.groupCount() > 1) ? matcher.group(2) : null;
-
- // capture the content type on the request
- _request.setAttribute(DispatchResponseConfiguratorImpl.__CONTENT_TYPE_KEY, contentType);
-
- // TODO: use Agent APIs when available
- if ("application/xhtml+xml".equals(contentType))
- {
- //TODO: Is this still needed in IE7??
- String userAgent = _request.getProperty("User-agent");
- if (userAgent != null && userAgent.indexOf("compatible; MSIE") != -1)
- {
- // IE must serve XHTML as text/html
- contentTypeAndCharset = "text/html";
-
- if (charset != null)
- contentTypeAndCharset += ";charset=" + charset;
- }
- }
- }
+ _request.setAttribute(DispatchResponseConfiguratorImpl.__CONTENT_TYPE_KEY, ct.getContentType());
}
- super.setContentType(contentTypeAndCharset);
+ super.setContentType(ct.toString());
}
private final RenderRequest _request;
-
- static private final Pattern _CONTENT_TYPE_PATTERN =
- Pattern.compile("([^;]+)(?:;charset=(.*))?");
}
Added: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResourceResponse.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResourceResponse.java?rev=773647&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResourceResponse.java (added)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResourceResponse.java Mon May 11 18:32:44 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.trinidadinternal.config.dispatch;
+
+import javax.faces.context.ExternalContext;
+
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.filter.ResourceResponseWrapper;
+
+/**
+ * This class is for Portlet 2.0 compatibility and it uses the real RenderResponseWrapper
+ */
+@SuppressWarnings("deprecation")
+class DispatchResourceResponse extends ResourceResponseWrapper
+{
+ public DispatchResourceResponse(ExternalContext ec)
+ {
+ super((ResourceResponse)ec.getResponse());
+ _request = (ResourceRequest)ec.getRequest();
+ }
+
+ @Override
+ public void setContentType(String contentTypeAndCharset)
+ {
+ ContentTypeAndCharacterSet ct = new ContentTypeAndCharacterSet(contentTypeAndCharset);
+
+ if(ct.getContentType() != null)
+ {
+ _request.setAttribute(DispatchResponseConfiguratorImpl.__CONTENT_TYPE_KEY, ct.getContentType());
+ }
+ super.setContentType(ct.toString());
+ }
+
+ private final ResourceRequest _request;
+}