From portal-commits at lists.jboss.org Tue Mar 27 19:18:47 2007 Content-Type: multipart/mixed; boundary="===============1708061096549211019==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6854 - in trunk/portlet/src: main/org/jboss/portal/portlet/impl/jsr168/api and 5 other directories. Date: Tue, 27 Mar 2007 19:18:47 -0400 Message-ID: --===============1708061096549211019== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/PortletReque= stAttributes.java trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServl= et.java trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatch= er/ServletFilter.java Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHt= tpServletRequest.java trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletR= equestDispatcherImpl.java trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletR= equestImpl.java trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequest= Context.java trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatch= er/DispatcherSequenceBuilder.java trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portl= et.xml trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.x= ml Log: - improved implementation of how a portlet request handle request attributes - added test cases for servlet filter calls when a portlet request dispatch= es to a servlet : only filters using the INCLUDE dispatcher should be called Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/Dispa= tchedHttpServletRequest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedH= ttpServletRequest.java 2007-03-27 17:58:02 UTC (rev 6853) +++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedH= ttpServletRequest.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 Julien Viet @@ -57,14 +57,14 @@ private static final String PATH_INFO =3D "javax.servlet.include.path_i= nfo"; private static final String QUERY_STRING =3D "javax.servlet.include.que= ry_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 =3D rreq.getContextPath() + servletPath + pathI= nfo; = // - this.attrs =3D 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 =3D 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 =3D 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 =3D attrs.get(s); + if (value !=3D null) { - return attrs.get(s); + return value; } - return rreq.getAttribute(s); + + // Otherwise try the render request modified attributes + return rreq.getAttributes().getAttribute(s, (HttpServletRequest)getR= equest()); } = public Enumeration getAttributeNames() { - final Enumeration e =3D rreq.getAttributeNames(); + final Iterator i =3D rreq.getAttributes().getAttributeNames((HttpSer= vletRequest)getRequest()); return new Enumeration() { // The next element @@ -250,9 +255,9 @@ next =3D null; while (true) { - if (e.hasMoreElements()) + if (i.hasNext()) { - Object next =3D e.nextElement(); + Object next =3D i.next(); if (attrs !=3D null && !attrs.containsKey(next)) { this.next =3D 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/PortletR= equestAttributes.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequ= estAttributes.java (rev 0) +++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequ= estAttributes.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.PortletApplicationMet= aData; +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 HttpServletRequest on the methods returning= data reading the state. The object + * can be used either during the render request where the dispatched reque= st will be used. It can also be used + * during a request dispatch made from the portlet to a servlet, in that s= ituation 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 attribut= es that have been modified by the + * request to the portlet container, so it will not write in the portal re= quest attributes. + * + * @author Julien Viet + * @version $Revision: 1.1 $ + */ +public class PortletRequestAttributes +{ + + /** Constant object to mark that a request attribute is removed. */ + protected static final Object REMOVED_ATTRIBUTE =3D 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 =3D container; + this.userContext =3D userContext; + } + + public Object getAttribute(String name, HttpServletRequest req) + { + if (name =3D=3D null) + { + throw new IllegalArgumentException("name must not be null"); + } + if (PortletRequest.USER_INFO.equals(name)) + { + Map infos =3D userContext.getInformations(); + + // + if (infos !=3D null) + { + // Get portlet application metadata + PortletApplicationImpl portletApp =3D (PortletApplicationImpl)= container.getApplication(); + PortletApplicationMetaData pamd =3D portletApp.getMetaData(); + Map uaMD =3D pamd.getUserAttributes(); + + // Clone the map + infos =3D new HashMap(infos); + + // Keep only what is of interest with respect to what the port= let app defines + infos.keySet().retainAll(uaMD.keySet()); + + // Make it immutable + infos =3D Collections.unmodifiableMap(infos); + } + + // + return infos; + } + else + { + Object value =3D null; + if (attributes !=3D null) + { + value =3D attributes.get(name); + } + if (value =3D=3D null && req !=3D null) + { + value =3D req.getAttribute(name); + } + else if (value =3D=3D REMOVED_ATTRIBUTE) + { + value =3D null; + } + return value; + } + } + + public Iterator getAttributeNames(HttpServletRequest req) + { + // Copy the attribute names to avoid ConcurrentModificationException + // one test in the TCK getPortalObjectContext the Enumeration then d= ispatch the call to a + // servlet where it use the Enumeration and it throws a CME if we do= n't copy + Set names =3D new HashSet(); + + // + if (req !=3D null) + { + for (Enumeration e =3D req.getAttributeNames();e.hasMoreElements(= );) + { + names.add(e.nextElement()); + } + } + + // + if (attributes !=3D null) + { + for (Iterator i =3D attributes.entrySet().iterator(); i.hasNext()= ;) + { + Map.Entry entry =3D (Map.Entry)i.next(); + String name =3D (String)entry.getKey(); + Object value =3D entry.getValue(); + if (value =3D=3D 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 =3D=3D null) + { + throw new IllegalArgumentException("name must not be null"); + } + if (!PortletRequest.USER_INFO.equals(name)) + { + if (value =3D=3D null) + { + value =3D REMOVED_ATTRIBUTE; + } + if (attributes =3D=3D null) + { + attributes =3D new HashMap(); + } + attributes.put(name, value); + } + } + + public void removeAttribute(String name) + { + if (name =3D=3D null) + { + throw new IllegalArgumentException("name must not be null"); + } + setAttribute(name, null); + } +} Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/P= ortletRequestDispatcherImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/Portlet= RequestDispatcherImpl.java 2007-03-27 17:58:02 UTC (rev 6853) +++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/Portlet= RequestDispatcherImpl.java 2007-03-27 23:18:47 UTC (rev 6854) @@ -79,7 +79,7 @@ RenderResponse rresp =3D (RenderResponse)req.getAttribute(APICons= tants.JAVAX_PORTLET_RESPONSE); = // - DispatchedHttpServletRequest direq =3D new DispatchedHttpServletR= equest(rreq, dreq, path); + DispatchedHttpServletRequest direq =3D new DispatchedHttpServletR= equest((RenderRequestImpl)rreq, dreq, path); DispatchedHttpServletResponse diresp =3D new DispatchedHttpServle= tResponse(rresp, dresp); = // Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/P= ortletRequestImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/Portlet= RequestImpl.java 2007-03-27 17:58:02 UTC (rev 6853) +++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/Portlet= RequestImpl.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.PortletApplicationMet= aData; 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 =3D new Object(); - protected static final Logger log =3D Logger.getLogger(PortletRequestIm= pl.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 =3D invocation.getDispatchedRequest(); this.portalContext =3D new PortalContextImpl(invocation.getPortalCon= text()); this.parameters =3D null; + this.attributes =3D new PortletRequestAttributes(container, userCont= ext); = // int mode =3D this instanceof RenderRequest ? PortletPreferencesImpl.= RENDER : PortletPreferencesImpl.ACTION; @@ -193,114 +188,25 @@ = // PLT.11.1.3 = - public Object getAttribute(String name) - { - if (name =3D=3D null) - { - throw new IllegalArgumentException("name must not be null"); - } - if (PortletRequest.USER_INFO.equals(name)) - { - Map infos =3D userContext.getInformations(); = - // - if (infos !=3D null) - { - // Get portlet application metadata - PortletApplicationImpl portletApp =3D (PortletApplicationImpl)= container.getApplication(); - PortletApplicationMetaData pamd =3D portletApp.getMetaData(); - Map uaMD =3D pamd.getUserAttributes(); - - // Clone the map - infos =3D new HashMap(infos); - - // Keep only what is of interest with respect to what the port= let app defines - infos.keySet().retainAll(uaMD.keySet()); - - // Make it immutable - infos =3D Collections.unmodifiableMap(infos); - } - - // - return infos; - } - else - { - Object value =3D null; - if (attributes !=3D null) - { - value =3D attributes.get(name); - } - if (value =3D=3D null) - { - value =3D requestContext.getAttribute(name); - } - else if (value =3D=3D REMOVED_ATTRIBUTE) - { - value =3D 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 d= ispatch the call to a - // servlet where it use the Enumeration and it throws a CME if we do= n't copy - Set names =3D new HashSet(); - for (Enumeration e =3D requestContext.getAttributeNames(); e.hasMore= Elements();) - { - names.add(e.nextElement()); - } - if (attributes !=3D null) - { - for (Iterator i =3D attributes.entrySet().iterator(); i.hasNext()= ;) - { - Map.Entry entry =3D (Map.Entry)i.next(); - String name =3D (String)entry.getKey(); - Object value =3D entry.getValue(); - if (value =3D=3D 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 =3D=3D null) - { - throw new IllegalArgumentException("name must not be null"); - } - if (!PortletRequest.USER_INFO.equals(name)) - { - if (value =3D=3D null) - { - value =3D REMOVED_ATTRIBUTE; - } - if (attributes =3D=3D null) - { - attributes =3D new HashMap(); - } - attributes.put(name, value); - } + attributes.setAttribute(name, value); } = public void removeAttribute(String name) { - if (name =3D=3D 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/Abstract= RequestContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractReques= tContext.java 2007-03-27 17:58:02 UTC (rev 6853) +++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractReques= tContext.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 Julien Viet @@ -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/RequestContex= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 Julien Viet @@ -35,16 +34,6 @@ /** * */ - Object getAttribute(String name); - - /** - * - */ - Enumeration getAttributeNames(); - - /** - * - */ String getScheme(); = /** Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopS= ervlet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServ= let.java (rev 0) +++ trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/NoopServ= let.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 Julien Viet + * @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/d= ispatcher/DispatcherSequenceBuilder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatc= her/DispatcherSequenceBuilder.java 2007-03-27 17:58:02 UTC (rev 6853) +++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatc= her/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.InvokeGetRespo= nse; import org.jboss.portal.common.test.driver.DriverResponse; @@ -35,6 +36,7 @@ import org.jboss.portal.test.framework.portlet.components.AbstractUniversa= lTestPortlet; 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 Boleslaw Daw= idowicz * @version $Revision$ */ @@ -134,4 +139,31 @@ } }); } + + public void createBlah(PortletTestDriver registry) + { + PortletTest seq =3D new PortletTest(); + registry.addSequence("Blah", seq); + seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction() + { + protected DriverResponse run(Portlet portlet, RenderRequest reque= st, RenderResponse response, PortletTestContext context) throws IOException= , PortletException + { + PortletRequestDispatcher prd =3D request.getPortletSession().g= etPortletContext().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 =3D request.getPortletSession().getPortletContext().getNam= edDispatcher("NoopServlet"); + assertNotNull(prd); + ServletFilter.ids.clear(); + prd.include(request, response); + assertEquals(Collections.singleton("INCLUDE_NAMED_FILTER"), Se= rvletFilter.ids); + + // + return new EndTestResponse(); + } + }); + } } Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/disp= atcher/ServletFilter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatc= her/ServletFilter.java (rev 0) +++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatc= her/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 Julien Viet + * @version $Revision: 1.1 $ + */ +public class ServletFilter implements Filter +{ + + public static final Set ids =3D new HashSet(); + + private String id; + + public void init(FilterConfig cfg) throws ServletException + { + id =3D cfg.getInitParameter("id"); + } + + public void doFilter(ServletRequest req, ServletResponse resp, FilterCh= ain chain) throws IOException, ServletException + { + if (id =3D=3D null) + { + throw new ServletException("No id found in the servlet filter con= fig"); + } + + // + ids.add(id); + + // + chain.doFilter(req, resp); + } + + public void destroy() + { + id =3D null; + } +} Modified: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-IN= F/portlet.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/port= let.xml 2007-03-27 17:58:02 UTC (rev 6853) +++ trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/port= let.xml 2007-03-27 23:18:47 UTC (rev 6854) @@ -39,5 +39,15 @@ = - = + + TestUniversalPortletB + org.jboss.portal.test.portlet.framework.UTP2 + + text/html + + + + + + Modified: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-IN= F/web.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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. = ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~--> = - - + = + + IncludeURLPatternFilter + org.jboss.portal.test.portlet.jsr168.ext.dispatcher.Se= rvletFilter + + id + INCLUDE_URL_PATTERN_FILTER + + + + + IncludeNamedFilter + org.jboss.portal.test.portlet.jsr168.ext.dispatcher.Se= rvletFilter + + id + INCLUDE_NAMED_FILTER + + + + + RequestURLPatternFilter + org.jboss.portal.test.portlet.jsr168.ext.dispatcher.Se= rvletFilter + + id + REQUEST_URL_PATTERN_FILTER + + + + + RequestNamedFilter + org.jboss.portal.test.portlet.jsr168.ext.dispatcher.Se= rvletFilter + + id + REQUEST_NAMED_FILTER + + + + + ForwardURLPatternFilter + org.jboss.portal.test.portlet.jsr168.ext.dispatcher.Se= rvletFilter + + id + FORWARD_URL_PATTERN_FILTER + + + + + ForwardNamedFilter + org.jboss.portal.test.portlet.jsr168.ext.dispatcher.Se= rvletFilter + + id + FORWARD_NAMED_FILTER + + + + + IncludeURLPatternFilter + /noop + INCLUDE + + + + IncludeNamedFilter + NoopServlet + INCLUDE + + + + ForwardURLPatternFilter + /noop + FORWARD + + + + ForwardNamedFilter + NoopServlet + FORWARD + + + + RequestURLPatternFilter + /noop + REQUEST + + + + RequestNamedFilter + NoopServlet + REQUEST + + org.jboss.portal.test.portlet.jsr168.ext.dispatch= er.DispatcherSequenceBuilder @@ -36,9 +127,19 @@ org.jboss.portal.test.portlet.framework.UTS1 = + + NoopServlet + org.jboss.portal.test.portlet.framework.NoopServlet + + UniversalServletA /universalServletA = + + NoopServlet + /noop + + --===============1708061096549211019==--