Author: julien(a)jboss.com
Date: 2007-03-27 19:18:47 -0400 (Tue, 27 Mar 2007)
New Revision: 6854
Added:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServlet.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/ServletFilter.java
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml
Log:
- improved implementation of how a portlet request handle request attributes
- added test cases for servlet filter calls when a portlet request dispatches to a servlet
: only filters using the INCLUDE dispatcher should be called
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2007-03-27
17:58:02 UTC (rev 6853)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -25,8 +25,8 @@
import org.jboss.portal.common.http.QueryStringParser;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
-import javax.portlet.RenderRequest;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
@@ -42,7 +42,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.Set;
+import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -57,14 +57,14 @@
private static final String PATH_INFO = "javax.servlet.include.path_info";
private static final String QUERY_STRING =
"javax.servlet.include.query_string";
- private RenderRequest rreq;
+ private RenderRequestImpl rreq;
private HttpServletRequest dreq;
private final Map attrs;
private final Map parameters;
public DispatchedHttpServletRequest(
- RenderRequest rreq,
+ RenderRequestImpl rreq,
HttpServletRequest dreq,
String path)
{
@@ -116,12 +116,13 @@
String requestURI = rreq.getContextPath() + servletPath + pathInfo;
//
- this.attrs = new HashMap();
- this.attrs.put(CONTEXT_PATH, rreq.getContextPath());
- this.attrs.put(SERVLET_PATH, servletPath);
- this.attrs.put(PATH_INFO, pathInfo);
- this.attrs.put(QUERY_STRING, queryString);
- this.attrs.put(REQUEST_URI, requestURI);
+ Map attrs = new HashMap(5);
+ attrs.put(CONTEXT_PATH, rreq.getContextPath());
+ attrs.put(SERVLET_PATH, servletPath);
+ attrs.put(PATH_INFO, pathInfo);
+ attrs.put(QUERY_STRING, queryString);
+ attrs.put(REQUEST_URI, requestURI);
+ this.attrs = Collections.unmodifiableMap(attrs);
//
if (queryString.length() > 0)
@@ -214,16 +215,20 @@
public Object getAttribute(String s)
{
- if (attrs.containsKey(s))
+ // First try the special values
+ Object value = attrs.get(s);
+ if (value != null)
{
- return attrs.get(s);
+ return value;
}
- return rreq.getAttribute(s);
+
+ // Otherwise try the render request modified attributes
+ return rreq.getAttributes().getAttribute(s, (HttpServletRequest)getRequest());
}
public Enumeration getAttributeNames()
{
- final Enumeration e = rreq.getAttributeNames();
+ final Iterator i =
rreq.getAttributes().getAttributeNames((HttpServletRequest)getRequest());
return new Enumeration()
{
// The next element
@@ -250,9 +255,9 @@
next = null;
while (true)
{
- if (e.hasMoreElements())
+ if (i.hasNext())
{
- Object next = e.nextElement();
+ Object next = i.next();
if (attrs != null && !attrs.containsKey(next))
{
this.next = next;
@@ -270,12 +275,12 @@
public void setAttribute(String s, Object o)
{
- rreq.setAttribute(s, o);
+ rreq.getAttributes().setAttribute(s, o);
}
public void removeAttribute(String s)
{
- rreq.removeAttribute(s);
+ rreq.getAttributes().removeAttribute(s);
}
public Locale getLocale()
Added:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -0,0 +1,190 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.container.PortletContainer;
+
+import javax.portlet.PortletRequest;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * Hold the portlet request attributes and holds only the modified state. That is the
reason motivating the
+ * presence of an <code>HttpServletRequest</code> on the methods returning
data reading the state. The object
+ * can be used either during the render request where the dispatched request will be
used. It can also be used
+ * during a request dispatch made from the portlet to a servlet, in that situation the
request provided will
+ * be the one valid during the dispatching operation.
+ *
+ * The other motivation of this class is to hold the state of the attributes that have
been modified by the
+ * request to the portlet container, so it will not write in the portal request
attributes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletRequestAttributes
+{
+
+ /** Constant object to mark that a request attribute is removed. */
+ protected static final Object REMOVED_ATTRIBUTE = new Object();
+
+ private PortletContainer container;
+
+ private UserContext userContext;
+
+ /** The lazy request attributes map added or removed during the request of the
portlet. */
+ private Map attributes;
+
+ public PortletRequestAttributes(PortletContainer container, UserContext userContext)
+ {
+ this.container = container;
+ this.userContext = userContext;
+ }
+
+ public Object getAttribute(String name, HttpServletRequest req)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ if (PortletRequest.USER_INFO.equals(name))
+ {
+ Map infos = userContext.getInformations();
+
+ //
+ if (infos != null)
+ {
+ // Get portlet application metadata
+ PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
+ PortletApplicationMetaData pamd = portletApp.getMetaData();
+ Map uaMD = pamd.getUserAttributes();
+
+ // Clone the map
+ infos = new HashMap(infos);
+
+ // Keep only what is of interest with respect to what the portlet app
defines
+ infos.keySet().retainAll(uaMD.keySet());
+
+ // Make it immutable
+ infos = Collections.unmodifiableMap(infos);
+ }
+
+ //
+ return infos;
+ }
+ else
+ {
+ Object value = null;
+ if (attributes != null)
+ {
+ value = attributes.get(name);
+ }
+ if (value == null && req != null)
+ {
+ value = req.getAttribute(name);
+ }
+ else if (value == REMOVED_ATTRIBUTE)
+ {
+ value = null;
+ }
+ return value;
+ }
+ }
+
+ public Iterator getAttributeNames(HttpServletRequest req)
+ {
+ // Copy the attribute names to avoid ConcurrentModificationException
+ // one test in the TCK getPortalObjectContext the Enumeration then dispatch the
call to a
+ // servlet where it use the Enumeration and it throws a CME if we don't copy
+ Set names = new HashSet();
+
+ //
+ if (req != null)
+ {
+ for (Enumeration e = req.getAttributeNames();e.hasMoreElements();)
+ {
+ names.add(e.nextElement());
+ }
+ }
+
+ //
+ if (attributes != null)
+ {
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ Object value = entry.getValue();
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ names.remove(name);
+ }
+ else
+ {
+ names.add(name);
+ }
+ }
+ }
+ names.add(PortletRequest.USER_INFO);
+
+ //
+ return names.iterator();
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ if (!PortletRequest.USER_INFO.equals(name))
+ {
+ if (value == null)
+ {
+ value = REMOVED_ATTRIBUTE;
+ }
+ if (attributes == null)
+ {
+ attributes = new HashMap();
+ }
+ attributes.put(name, value);
+ }
+ }
+
+ public void removeAttribute(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ setAttribute(name, null);
+ }
+}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2007-03-27
17:58:02 UTC (rev 6853)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -79,7 +79,7 @@
RenderResponse rresp =
(RenderResponse)req.getAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
//
- DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest(rreq,
dreq, path);
+ DispatchedHttpServletRequest direq = new
DispatchedHttpServletRequest((RenderRequestImpl)rreq, dreq, path);
DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(rresp,
dresp);
//
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2007-03-27
17:58:02 UTC (rev 6853)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -30,10 +30,10 @@
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.portlet.impl.jsr168.PortletRequestAttributes;
import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.jsr168.info.ContentTypes;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.spi.InstanceContext;
import org.jboss.portal.portlet.spi.RequestContext;
@@ -54,7 +54,6 @@
import java.security.Principal;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
@@ -73,9 +72,6 @@
public abstract class PortletRequestImpl implements PortletRequest
{
- /** Constant object to mark that a request attribute is removed. */
- protected static final Object REMOVED_ATTRIBUTE = new Object();
-
protected static final Logger log = Logger.getLogger(PortletRequestImpl.class);
protected PortletInvocation invocation;
@@ -84,20 +80,18 @@
protected RequestContext requestContext;
protected InstanceContext instanceContext;
protected PortletPreferences preferences;
-
protected PortletContainerImpl container;
protected ContentTypes contentTypes;
protected HttpServletRequest dreq;
protected PortalContext portalContext;
protected PortletSessionImpl psession;
-
protected int sessionStatus;
/** . */
protected PortletParameters parameters;
- /** The lazy request attributes map added or removed during the request of the
portlet. */
- protected Map attributes;
+ /** . */
+ protected final PortletRequestAttributes attributes;
public PortletRequestImpl(PortletInvocation invocation)
{
@@ -112,6 +106,7 @@
this.dreq = invocation.getDispatchedRequest();
this.portalContext = new PortalContextImpl(invocation.getPortalContext());
this.parameters = null;
+ this.attributes = new PortletRequestAttributes(container, userContext);
//
int mode = this instanceof RenderRequest ? PortletPreferencesImpl.RENDER :
PortletPreferencesImpl.ACTION;
@@ -193,114 +188,25 @@
// PLT.11.1.3
- public Object getAttribute(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- if (PortletRequest.USER_INFO.equals(name))
- {
- Map infos = userContext.getInformations();
- //
- if (infos != null)
- {
- // Get portlet application metadata
- PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
- PortletApplicationMetaData pamd = portletApp.getMetaData();
- Map uaMD = pamd.getUserAttributes();
-
- // Clone the map
- infos = new HashMap(infos);
-
- // Keep only what is of interest with respect to what the portlet app
defines
- infos.keySet().retainAll(uaMD.keySet());
-
- // Make it immutable
- infos = Collections.unmodifiableMap(infos);
- }
-
- //
- return infos;
- }
- else
- {
- Object value = null;
- if (attributes != null)
- {
- value = attributes.get(name);
- }
- if (value == null)
- {
- value = requestContext.getAttribute(name);
- }
- else if (value == REMOVED_ATTRIBUTE)
- {
- value = null;
- }
- return value;
- }
+ public Object getAttribute(String name) throws IllegalArgumentException
+ {
+ return attributes.getAttribute(name, dreq);
}
public Enumeration getAttributeNames()
{
- // Copy the attribute names to avoid ConcurrentModificationException
- // one test in the TCK getPortalObjectContext the Enumeration then dispatch the
call to a
- // servlet where it use the Enumeration and it throws a CME if we don't copy
- Set names = new HashSet();
- for (Enumeration e = requestContext.getAttributeNames(); e.hasMoreElements();)
- {
- names.add(e.nextElement());
- }
- if (attributes != null)
- {
- for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = (String)entry.getKey();
- Object value = entry.getValue();
- if (value == REMOVED_ATTRIBUTE)
- {
- names.remove(name);
- }
- else
- {
- names.add(name);
- }
- }
- }
- names.add(PortletRequest.USER_INFO);
- return Tools.toEnumeration(names.iterator());
+ return Tools.toEnumeration(attributes.getAttributeNames(dreq));
}
public void setAttribute(String name, Object value)
{
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- if (!PortletRequest.USER_INFO.equals(name))
- {
- if (value == null)
- {
- value = REMOVED_ATTRIBUTE;
- }
- if (attributes == null)
- {
- attributes = new HashMap();
- }
- attributes.put(name, value);
- }
+ attributes.setAttribute(name, value);
}
public void removeAttribute(String name)
{
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- setAttribute(name, null);
+ attributes.removeAttribute(name);
}
// PLT.11.1.4
@@ -559,4 +465,11 @@
{
return preferences;
}
+
+ //
+
+ public PortletRequestAttributes getAttributes()
+ {
+ return attributes;
+ }
}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java 2007-03-27
17:58:02 UTC (rev 6853)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -24,12 +24,8 @@
import org.jboss.portal.portlet.spi.RequestContext;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Enumeration;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -65,16 +61,6 @@
return resp;
}
- public Object getAttribute(String name)
- {
- return req.getAttribute(name);
- }
-
- public Enumeration getAttributeNames()
- {
- return req.getAttributeNames();
- }
-
public String getScheme()
{
return getClientRequest().getScheme();
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java 2007-03-27
17:58:02 UTC (rev 6853)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -24,7 +24,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.Enumeration;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -35,16 +34,6 @@
/**
*
*/
- Object getAttribute(String name);
-
- /**
- *
- */
- Enumeration getAttributeNames();
-
- /**
- *
- */
String getScheme();
/**
Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServlet.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServlet.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServlet.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.framework;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoopServlet extends HttpServlet
+{
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ }
+}
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java 2007-03-27
17:58:02 UTC (rev 6853)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.portlet.jsr168.ext.dispatcher;
import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.common.test.driver.response.EndTestResponse;
import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
import org.jboss.portal.common.test.driver.DriverResponse;
@@ -35,6 +36,7 @@
import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.portal.test.portlet.framework.UTP2;
import javax.portlet.Portlet;
import javax.portlet.PortletException;
@@ -48,8 +50,11 @@
import java.io.IOException;
import java.util.Enumeration;
import java.util.Set;
+import java.util.Collections;
/**
+ * Tests for request dispatching from a portlet to a servlet.
+ *
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision$
*/
@@ -134,4 +139,31 @@
}
});
}
+
+ public void createBlah(PortletTestDriver registry)
+ {
+ PortletTest seq = new PortletTest();
+ registry.addSequence("Blah", seq);
+ seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ PortletRequestDispatcher prd =
request.getPortletSession().getPortletContext().getRequestDispatcher("/noop");
+ assertNotNull(prd);
+ ServletFilter.ids.clear();
+ prd.include(request, response);
+ assertEquals(new
CollectionBuilder().add("INCLUDE_URL_PATTERN_FILTER").add("INCLUDE_NAMED_FILTER").toHashSet(),
ServletFilter.ids);
+
+ //
+ prd =
request.getPortletSession().getPortletContext().getNamedDispatcher("NoopServlet");
+ assertNotNull(prd);
+ ServletFilter.ids.clear();
+ prd.include(request, response);
+ assertEquals(Collections.singleton("INCLUDE_NAMED_FILTER"),
ServletFilter.ids);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
}
Added:
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/ServletFilter.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/ServletFilter.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/ServletFilter.java 2007-03-27
23:18:47 UTC (rev 6854)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr168.ext.dispatcher;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import java.io.IOException;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServletFilter implements Filter
+{
+
+ public static final Set ids = new HashSet();
+
+ private String id;
+
+ public void init(FilterConfig cfg) throws ServletException
+ {
+ id = cfg.getInitParameter("id");
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException
+ {
+ if (id == null)
+ {
+ throw new ServletException("No id found in the servlet filter
config");
+ }
+
+ //
+ ids.add(id);
+
+ //
+ chain.doFilter(req, resp);
+ }
+
+ public void destroy()
+ {
+ id = null;
+ }
+}
Modified: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml
===================================================================
---
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml 2007-03-27
17:58:02 UTC (rev 6853)
+++
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml 2007-03-27
23:18:47 UTC (rev 6854)
@@ -39,5 +39,15 @@
</portlet-info>
</portlet>
-
+ <portlet>
+ <portlet-name>TestUniversalPortletB</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
</portlet-app>
Modified: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml 2007-03-27
17:58:02 UTC (rev 6853)
+++ trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml 2007-03-27
23:18:47 UTC (rev 6854)
@@ -22,11 +22,102 @@
~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
+<web-app
+
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <filter>
+ <filter-name>IncludeURLPatternFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>IncludeNamedFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>RequestURLPatternFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>REQUEST_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>RequestNamedFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>REQUEST_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>ForwardURLPatternFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>FORWARD_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>ForwardNamedFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>FORWARD_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>IncludeURLPatternFilter</filter-name>
+ <url-pattern>/noop</url-pattern>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>IncludeNamedFilter</filter-name>
+ <servlet-name>NoopServlet</servlet-name>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>ForwardURLPatternFilter</filter-name>
+ <url-pattern>/noop</url-pattern>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>ForwardNamedFilter</filter-name>
+ <servlet-name>NoopServlet</servlet-name>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>RequestURLPatternFilter</filter-name>
+ <url-pattern>/noop</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>RequestNamedFilter</filter-name>
+ <servlet-name>NoopServlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
<listener>
<listener-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatcherSequenceBuilder</listener-class>
</listener>
@@ -36,9 +127,19 @@
<servlet-class>org.jboss.portal.test.portlet.framework.UTS1</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>NoopServlet</servlet-name>
+
<servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
+ </servlet>
+
<servlet-mapping>
<servlet-name>UniversalServletA</servlet-name>
<url-pattern>/universalServletA</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>NoopServlet</servlet-name>
+ <url-pattern>/noop</url-pattern>
+ </servlet-mapping>
+
</web-app>