Author: julien(a)jboss.com
Date: 2007-03-12 10:50:21 -0400 (Mon, 12 Mar 2007)
New Revision: 6639
Added:
trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebTomcat6App.java
Modified:
trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java
trunk/common/src/main/org/jboss/portal/common/util/TypedMap.java
trunk/common/src/main/org/jboss/portal/test/common/TypedMapTestCase.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/PortalJsp.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorTag.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorsTag.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IfTag.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IncludeTag.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IterateTag.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/PortalLib.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/SuccessTag.java
trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletcontext/PortletContextSequenceBuilder.java
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebAppFactory.java
trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
- improved and simplified request dispatching from a portlet to a servlet
- added PortalWebTomcat6App to correctly deploy with TC6
- fixed a couple of things to make portal core work with 4.2 CR1
Added: trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java
(rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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.common.http;
+
+import org.jboss.portal.common.util.URLTools;
+
+import java.util.Map;
+import java.util.Collections;
+import java.util.StringTokenizer;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class QueryStringParser
+{
+
+ /**
+ * Parse the query string and build an unmodifiable parameter map of it.
+ *
+ * @param queryString the non null query string
+ * @return a <String,String[]> map
+ * @throws IllegalArgumentException if the query string is null
+ */
+ public static Map parseQueryString(String queryString) throws
IllegalArgumentException
+ {
+ if (queryString == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Map result = Collections.EMPTY_MAP;
+
+ //
+ for (StringTokenizer tokenizer = new StringTokenizer(queryString,
"&"); tokenizer.hasMoreTokens();)
+ {
+ String token = tokenizer.nextToken();
+ int pos = token.indexOf('=');
+ if (pos > 0)
+ {
+ // Get name and value
+ String encodedName = token.substring(0, pos);
+ String encodedValue = token.substring(pos + 1, token.length());
+
+ // Decode properly
+ String name = URLTools.decodeXWWWFormURL(encodedName);
+ String value = URLTools.decodeXWWWFormURL(encodedValue);
+
+ // Put the values in the result map
+ String[] values = (String[])result.get(name);
+ if (values == null)
+ {
+ values = new String[1];
+ }
+ else
+ {
+ String[] tmp = new String[values.length + 1];
+ System.arraycopy(values, 0, tmp, 0, values.length);
+ values = tmp;
+ }
+ values[values.length - 1] = value;
+
+ // Replace the empty map if necessary with a real hashmap
+ if (result.isEmpty())
+ {
+ result = new HashMap();
+ }
+ result.put(name, values);
+ }
+ else
+ {
+ // Not well formed
+ // -1 mean we have just a parameter name
+ // 0 means we have an empty name
+ }
+ }
+
+ //
+ return result.isEmpty() ? result : Collections.unmodifiableMap(result);
+ }
+}
Modified: trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -33,7 +33,34 @@
public abstract class ParameterMap extends TypedMap
{
+ /** If true returned values will be cloned when returned to the client. */
+ private boolean cloneInternalValue;
+
+ /** If true returned values will be cloned when provided by the client. */
+ private boolean cloneExternalValue;
+
+ protected ParameterMap(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ protected ParameterMap()
+ {
+ this(false, false);
+ }
+
/**
+ * Return true if values returned by the map are cloned.
+ *
+ * @return true if returned values are cloned
+ */
+ public boolean isCloneInternalValue()
+ {
+ return cloneInternalValue;
+ }
+
+ /**
* Only accept non null string objects.
*
* @throws ClassCastException if the value is not an instance of string
@@ -66,6 +93,8 @@
{
throw new IllegalArgumentException("Array must not be zero length");
}
+
+ //
for (int i = strings.length - 1;i >= 0;i--)
{
if (strings[i] == null)
@@ -73,9 +102,30 @@
throw new IllegalArgumentException("No null entries allowed in
String[]");
}
}
+
+ //
+ if (cloneExternalValue)
+ {
+ strings = (String[])strings.clone();
+ }
+
+ //
return strings;
}
+
+ protected Object getExternalValue(Object value)
+ {
+ if (cloneInternalValue)
+ {
+ return ((String[])value).clone();
+ }
+ else
+ {
+ return value;
+ }
+ }
+
protected boolean internalValueEquals(Object left, Object right)
{
String[] valuesL = (String[])left;
Modified: trunk/common/src/main/org/jboss/portal/common/util/TypedMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/TypedMap.java 2007-03-12 14:48:11
UTC (rev 6638)
+++ trunk/common/src/main/org/jboss/portal/common/util/TypedMap.java 2007-03-12 14:50:21
UTC (rev 6639)
@@ -81,7 +81,7 @@
return key;
}
- private Object unwrapKey(Object externalKey) throws IllegalArgumentException,
ClassCastException, NullPointerException
+ protected final Object unwrapKey(Object externalKey) throws IllegalArgumentException,
ClassCastException, NullPointerException
{
if (externalKey == null)
{
@@ -101,7 +101,7 @@
return internalKey;
}
- private Object wrapKey(Object internalKey) throws IllegalStateException
+ protected final Object wrapKey(Object internalKey) throws IllegalStateException
{
if (internalKey == null)
{
@@ -135,14 +135,28 @@
}
/**
- * Wrap the internal value into its external representation.
+ * Wrap the internal value into its external representation. The external
representation value should not be null.
+ * If it is not possible to obtain an external value representation of the internal
value, then the the
+ * null value should be returned from this method.
+ *
+ * @param value the param value which will not be null
+ * @return the external value
*/
protected Object getExternalValue(Object value)
{
return value;
}
- private Object unwrapValue(Object externalValue) throws IllegalArgumentException,
ClassCastException, NullPointerException
+ /**
+ * Extract the internal value from an external value.
+ *
+ * @param externalValue the external value to unwrap
+ * @return the non null internal value
+ * @throws IllegalArgumentException
+ * @throws ClassCastException
+ * @throws NullPointerException
+ */
+ protected final Object unwrapValue(Object externalValue) throws
IllegalArgumentException, ClassCastException, NullPointerException
{
if (externalValue == null)
{
@@ -162,7 +176,15 @@
return internalValue;
}
- private Object wrapValue(Object internalValue) throws IllegalStateException
+ /**
+ * Convert an internal value into an external value.
+ *
+ * @param internalValue the internal value
+ * @return the non null external value
+ * @throws IllegalStateException if the internal value was null or some aspect
prevented it to be converted
+ * to an external representation
+ */
+ protected final Object wrapValue(Object internalValue) throws IllegalStateException
{
if (internalValue == null)
{
@@ -367,12 +389,7 @@
*/
public void validate() throws ClassCastException, NullPointerException,
IllegalArgumentException
{
- validate(this);
- }
-
- public void validate(Map m) throws ClassCastException, NullPointerException,
IllegalArgumentException
- {
- for (Iterator i = m.entrySet().iterator(); i.hasNext();)
+ for (Iterator i = getDelegate().entrySet().iterator(); i.hasNext();)
{
Entry entry = (Entry)i.next();
wrapKey(entry.getKey());
@@ -585,7 +602,23 @@
public boolean retainAll(Collection c)
{
- throw new NotYetImplemented("TypedEntrySet.retainAll(Collection c)");
+ if (c == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ boolean changed = false;
+ for (Iterator i = iterator();i.hasNext();)
+ {
+ Object key = i.next();
+ if (!c.contains(key))
+ {
+ i.remove();
+ changed = true;
+ }
+ }
+ return changed;
}
public Iterator iterator()
Modified: trunk/common/src/main/org/jboss/portal/test/common/TypedMapTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/TypedMapTestCase.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/common/src/main/org/jboss/portal/test/common/TypedMapTestCase.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -24,10 +24,12 @@
import junit.framework.TestCase;
import org.jboss.portal.common.util.TypedMap;
+import org.jboss.portal.common.util.CollectionBuilder;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -347,6 +349,39 @@
assertFalse(right.equals(left));
}
+ public void testEntrySetRetainAll()
+ {
+ Map right = new HashMap();
+ right.put("abc", new Integer(0));
+ right.put("def", new Integer(1));
+ right.put("ghi", new Integer(2));
+
+ //
+ StringToIntegerMap left = new StringToIntegerMap();
+ left.delegate.putAll(right);
+
+ try
+ {
+ left.keySet().retainAll(null);
+ fail("Was expecting NPE");
+ }
+ catch (NullPointerException expected)
+ {
+ }
+
+ //
+ boolean changed = left.keySet().retainAll(new
CollectionBuilder().add("abc").add("def").add("ghi").toHashSet());
+ assertFalse(changed);
+ assertEquals(right, left.delegate);
+
+ //
+ changed = left.keySet().retainAll(new
CollectionBuilder().add("def").toHashSet());
+ assertTrue(changed);
+ right.remove("abc");
+ right.remove("ghi");
+ assertEquals(right, left.delegate);
+ }
+
public static class StringToIntegerMap extends TypedMap
{
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/PortalJsp.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/PortalJsp.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/PortalJsp.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -57,8 +57,9 @@
public static final ThreadLocal contextStack = new ThreadLocal();
/** To log JSP related information */
- public static Logger log = Logger.getLogger(PortalJsp.class);
+ public static Logger logger = Logger.getLogger(PortalJsp.class);
+ /** . */
private ServletConfig config;
/**
@@ -168,4 +169,13 @@
{
jspDestroy();
}
+
+ /**
+ * For Jasper which seems to want a log method in the generated JSP.
+ */
+ protected final void log(String msg)
+ {
+ logger.debug(msg);
+ }
+
}
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorTag.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorTag.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorTag.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -74,7 +74,7 @@
}
catch (MissingResourceException e)
{
- PortalJsp.log.error("No such resource key in resource file: " +
key);
+ PortalJsp.logger.error("No such resource key in resource file: " +
key);
}
try
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorsTag.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorsTag.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/ErrorsTag.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -73,7 +73,7 @@
}
catch (MissingResourceException e)
{
- PortalJsp.log.error("No such resource key in resource file: " + key);
+ PortalJsp.logger.error("No such resource key in resource file: " +
key);
}
try
{
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IfTag.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IfTag.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IfTag.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -66,7 +66,7 @@
if (contextStack.isEmpty())
{
include = false;
- PortalJsp.log.debug("No context has been found");
+ PortalJsp.logger.debug("No context has been found");
return SKIP_BODY;
}
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IncludeTag.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IncludeTag.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IncludeTag.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -87,7 +87,7 @@
}
catch (Exception e)
{
- PortalJsp.log.error("Cannot include page: " + page, e);
+ PortalJsp.logger.error("Cannot include page: " + page, e);
}
finally
{
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IterateTag.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IterateTag.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/IterateTag.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -64,7 +64,7 @@
if (contextStack.isEmpty())
{
include = false;
- PortalJsp.log.debug("No context has been found");
+ PortalJsp.logger.debug("No context has been found");
return SKIP_BODY;
}
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/PortalLib.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/PortalLib.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/PortalLib.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -54,14 +54,14 @@
Locale locale = request.getLocale();
PortletConfig portletConfig =
(PortletConfig)request.getAttribute("javax.portlet.config");
ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);
- PortalJsp.log.debug("Use locale:" + locale);
+ PortalJsp.logger.debug("Use locale:" + locale);
try
{
return resourceBundle.getString(key);
}
catch (MissingResourceException e)
{
- PortalJsp.log.error("No such resource key in resource file: " + key);
+ PortalJsp.logger.error("No such resource key in resource file: " +
key);
return key;
}
}
@@ -91,7 +91,7 @@
if (contextStack.isEmpty())
{
- PortalJsp.log.warn("No context has been defined when trying to access
" + key);
+ PortalJsp.logger.warn("No context has been defined when trying to access
" + key);
return "";
}
@@ -110,12 +110,12 @@
}
catch (IndexOutOfBoundsException e)
{
- PortalJsp.log.warn("The key you called: " + key + " is not
valid, please check the key");
+ PortalJsp.logger.warn("The key you called: " + key + " is not
valid, please check the key");
return "";
}
if (!ctxNames[i].equals(tmp.getName()))
{
- PortalJsp.log.warn("The context you called: " + ctxNames[i] +
" does not match " + tmp.getName());
+ PortalJsp.logger.warn("The context you called: " + ctxNames[i] +
" does not match " + tmp.getName());
return "";
}
}
@@ -127,7 +127,7 @@
}
else
{
- PortalJsp.log.warn("There is no such context for " + key);
+ PortalJsp.logger.warn("There is no such context for " + key);
return "";
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/SuccessTag.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/SuccessTag.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/taglib/SuccessTag.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -73,7 +73,7 @@
}
catch (MissingResourceException e)
{
- PortalJsp.log.error("No such resource key in resource file: " + key);
+ PortalJsp.logger.error("No such resource key in resource file: " +
key);
}
try
{
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -110,37 +110,36 @@
*/
public void append(Map params) throws ClassCastException, NullPointerException,
IllegalArgumentException
{
- validate(params);
+ String[] appendedNames = new String[params.size()];
+ String[][] appendedValues = new String[params.size()][];
- //
- internalAppend(params);
- }
-
- /** Append actual implementation. */
- private void internalAppend(Map params)
- {
+ // Unwrap all first and validate so we have the atomic behavior guarantee
+ int index = 0;
for (Iterator entries = params.entrySet().iterator(); entries.hasNext();)
{
Map.Entry entry = (Map.Entry)entries.next();
- String name = (String)entry.getKey();
- String[] appendedValues = (String[])entry.getValue();
+ appendedNames[index] = (String)unwrapKey(entry.getKey());
+ appendedValues[index++] = (String[])unwrapValue(entry.getValue());
+ }
- // Merge or use appended values
- String[] values = (String[])map.get(name);
- if (values != null)
+ // Merge or use appended values
+ while (--index >= 0)
+ {
+ String appendedName = appendedNames[index];
+ String[] appendedValue = appendedValues[index];
+
+ //
+ String[] value = (String[])map.get(appendedName);
+ if (value != null)
{
- String[] tmp = new String[values.length + appendedValues.length];
- System.arraycopy(values, 0, tmp, 0, values.length);
- System.arraycopy(appendedValues, 0, tmp, values.length,
appendedValues.length);
- values = tmp;
+ String[] tmp = new String[value.length + appendedValue.length];
+ System.arraycopy(value, 0, tmp, 0, value.length);
+ System.arraycopy(appendedValue, 0, tmp, value.length, appendedValue.length);
+ appendedValue = tmp;
}
- else
- {
- values = appendedValues;
- }
//
- map.put(name, values);
+ map.put(appendedName, appendedValue);
}
}
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-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -22,12 +22,17 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168;
+import org.jboss.portal.common.http.QueryStringParser;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.PortletParameters;
+
import javax.portlet.RenderRequest;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletRequestWrapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -37,12 +42,13 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class DispatchedHttpServletRequest implements HttpServletRequest
+public class DispatchedHttpServletRequest extends HttpServletRequestWrapper
{
private static final String REQUEST_URI =
"javax.servlet.include.request_uri";
@@ -55,22 +61,26 @@
private HttpServletRequest dreq;
private final Map attrs;
+ private final Map parameters;
public DispatchedHttpServletRequest(
RenderRequest rreq,
HttpServletRequest dreq,
String path)
{
+ super(dreq);
+
+ //
this.rreq = rreq;
this.dreq = dreq;
+
+ //
if (path != null)
{
- attrs = new HashMap();
+ String servletPath;
+ String pathInfo;
+ String queryString;
- String servletPath = null;
- String pathInfo = null;
- String queryString = null;
-
int endOfServletPath = path.indexOf('/', 1);
if (endOfServletPath == -1)
{
@@ -106,15 +116,28 @@
String requestURI = rreq.getContextPath() + servletPath + pathInfo;
//
- 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 = 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);
+
+ //
+ if (queryString.length() > 0)
+ {
+ this.parameters = new PortletParameters(rreq.getParameterMap());
+ this.parameters.putAll(QueryStringParser.parseQueryString(queryString));
+ }
+ else
+ {
+ this.parameters = rreq.getParameterMap();
+ }
}
else
{
- attrs = Collections.EMPTY_MAP;
+ this.attrs = Collections.EMPTY_MAP;
+ this.parameters = rreq.getParameterMap();
}
}
@@ -302,24 +325,50 @@
// Must be equivalent to the method of the PortletRequest with the provision defined
in PLT.16.1.1
- public String getParameter(String s)
+ public String getParameter(String name)
{
- return rreq.getParameter(s);
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Parameter name must not be
null");
+ }
+
+ //
+ String[] values = (String[])parameters.get(name);
+ if (values != null)
+ {
+ return values[0];
+ }
+
+ //
+ return null;
}
public Enumeration getParameterNames()
{
- return rreq.getParameterNames();
+ return Tools.toEnumeration(parameters.keySet().iterator());
}
- public String[] getParameterValues(String s)
+ public String[] getParameterValues(String name)
{
- return rreq.getParameterValues(s);
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Parameter name must not be
null");
+ }
+
+ //
+ String[] values = (String[])parameters.get(name);
+ if (values != null)
+ {
+ return (String[])values.clone();
+ }
+
+ //
+ return null;
}
public Map getParameterMap()
{
- return rreq.getParameterMap();
+ return parameters;
}
// Do not operate and return null or zero
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -26,6 +26,7 @@
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
@@ -35,14 +36,15 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class DispatchedHttpServletResponse implements HttpServletResponse
+public class DispatchedHttpServletResponse extends HttpServletResponseWrapper
{
private RenderResponse rresp;
private ServletOutputStream sos;
- public DispatchedHttpServletResponse(RenderResponse rresp)
+ public DispatchedHttpServletResponse(RenderResponse rresp, HttpServletResponse dresp)
{
+ super(dresp);
this.rresp = rresp;
this.sos = null;
}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -30,11 +30,9 @@
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -43,48 +41,26 @@
* @version $Revision$
*/
public class PortletRequestDispatcherImpl
- implements PortletRequestDispatcher,
- FilterCommand
+ implements PortletRequestDispatcher
{
/** The servlet request dispatcher. */
- private RequestDispatcher dispatcher;
+ private final RequestDispatcher dispatcher;
/** . */
- private String path;
+ private final String path;
- public PortletRequestDispatcherImpl(RequestDispatcher dispatcher)
+ PortletRequestDispatcherImpl(RequestDispatcher dispatcher)
{
this(dispatcher, null);
}
- public PortletRequestDispatcherImpl(RequestDispatcher dispatcher, String path)
+ PortletRequestDispatcherImpl(RequestDispatcher dispatcher, String path)
{
this.dispatcher = dispatcher;
this.path = path;
}
- public void execute(HttpServletRequest req, HttpServletResponse resp, FilterChain
chain) throws ServletException, IOException
- {
- // We need to wrap the tomcat dispatched request because the wrapper implements
getRequestURL
- // such as it does not delegate to the original request provided by the
<code>include</code>
- // method execution.
- HttpServletRequest wrappedReq = new HttpServletRequestWrapper(req)
- {
- /**
- * Override the behavior from tomcat, see above.
- *
- * @return the null value per the spec
- */
- public StringBuffer getRequestURL()
- {
- // Per the spec
- return null;
- }
- };
- chain.doFilter(wrappedReq, resp);
- }
-
public void include(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
{
try
@@ -94,20 +70,26 @@
//
HttpServletRequest dreq = invocation.getDispatchedRequest();
+ HttpServletResponse dresp = invocation.getDispatchedResponse();
+ // It was set by the PortletContainerInvoker before diving into the portlet, so
let's just reuse them
+ RenderRequest rreq =
(RenderRequest)req.getAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
+ RenderResponse rresp =
(RenderResponse)req.getAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+
//
- DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest(req, dreq,
path);
- DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(resp);
+ DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest(rreq,
dreq, path);
+ DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(rresp,
dresp);
//
try
{
- direq.setAttribute(FilterCommand.REQ_ATT_KEY, this);
+ // Set the filter command
+ dreq.setAttribute(FilterCommand.REQ_ATT_KEY, this);
dispatcher.include(direq, diresp);
}
finally
{
- direq.removeAttribute(FilterCommand.REQ_ATT_KEY);
+ dreq.removeAttribute(FilterCommand.REQ_ATT_KEY);
}
}
catch (ServletException e)
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -268,7 +268,10 @@
}
catch (Exception e)
{
- assertTrue(exceptionClasses[i].isAssignableFrom(e.getClass()));
+ if (!exceptionClasses[i].isAssignableFrom(e.getClass()))
+ {
+ fail("Exception class " + exceptionClasses[i].getName() + "
(index=" + i + ") should be assignable from caught exception " +
e.getClass());
+ }
}
}
}
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -51,7 +51,7 @@
{
Logger logger = ((LoggingPortlet)portlet).getLogger();
assertNotNull(logger);
- assertTrue("Logger is an instance of " +
logger.getClass().getName() + " instead of ", logger instanceof CustomLogger);
+ assertTrue("Logger is an instance of " +
logger.getClass().getName() + " instead of " + CustomLogger.class.getName(),
logger instanceof CustomLogger);
return new EndTestResponse();
}
});
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -198,7 +198,7 @@
try
{
dispatcher.include(request, response);
- Object o = (Boolean)UTP1.local.get();
+ Object o = UTP1.local.get();
assertEquals(Boolean.TRUE, o);
}
finally
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletcontext/PortletContextSequenceBuilder.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletcontext/PortletContextSequenceBuilder.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletcontext/PortletContextSequenceBuilder.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -24,6 +24,7 @@
import org.jboss.portal.common.test.driver.response.EndTestResponse;
import org.jboss.portal.common.test.driver.DriverResponse;
+import org.jboss.portal.common.util.Tools;
import org.jboss.portal.test.framework.portlet.Sequence;
import org.jboss.portal.test.framework.portlet.SequenceRegistry;
import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
@@ -286,20 +287,8 @@
/** Simple compare of two Enumerationss */
private boolean compare(Enumeration a, Enumeration b)
{
- List al = new ArrayList();
- List bl = new ArrayList();
-
- for (; a.hasMoreElements();)
- {
- al.add(a.nextElement());
- }
-
- for (; b.hasMoreElements();)
- {
- bl.add(a.nextElement());
- }
+ List al = Tools.toList(a);
+ List bl = Tools.toList(b);
return al.equals(bl);
}
-
-
}
Modified:
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebAppFactory.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebAppFactory.java 2007-03-12
14:48:11 UTC (rev 6638)
+++
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebAppFactory.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -70,8 +70,7 @@
case TOMCAT5:
return new PortalWebTomcat5App(webApp, server, jbossAppEntityResolver);
case TOMCAT6:
- // For now trying to build TC6 with TC5 web app
- return new PortalWebTomcat5App(webApp, server, jbossAppEntityResolver);
+ return new PortalWebTomcat6App(webApp, server, jbossAppEntityResolver);
default:
throw new CannotCreatePortletWebAppException("JBossWeb cannot handle it
: " + version);
}
@@ -113,6 +112,10 @@
{
return TOMCAT6;
}
+ else
+ {
+ log.error("Cannot handle tomcat version: " + result);
+ }
}
}
catch (ClassNotFoundException e)
Added: trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebTomcat6App.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebTomcat6App.java
(rev 0)
+++
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebTomcat6App.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -0,0 +1,268 @@
+/******************************************************************************
+ * 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.server.deployment;
+
+import org.jboss.web.WebApplication;
+import org.jboss.portal.server.servlet.CommandServlet;
+import org.jboss.portal.server.servlet.CommandFilter;
+import org.xml.sax.EntityResolver;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.ServletContext;
+import java.net.URL;
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+import java.lang.reflect.Array;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6091 $
+ */
+public class PortalWebTomcat6App extends PortalWebApp
+{
+
+ private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+ private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
+ private final Object standardContext;
+ private final WebApplication webApp;
+
+ public PortalWebTomcat6App(WebApplication webApp, MBeanServer server, EntityResolver
jbossAppEntityResolver) throws CannotCreatePortletWebAppException
+ {
+ try
+ {
+ ObjectName name = (ObjectName)webApp.getAppData();
+
+ //
+ this.webApp = webApp;
+ this.standardContext = server.getAttribute(name, "managedResource");
+
+ //
+ String contextPath = PortalWebTomcat4App.getContextPath(standardContext);
+ ServletContext servletContext =
PortalWebTomcat4App.getServletContext(standardContext);
+ ClassLoader loader = getClassLoader(server, name);
+ URL url = webApp.getURL();
+
+ //
+ init(servletContext, url, loader, contextPath, jbossAppEntityResolver);
+ }
+ catch (Exception e)
+ {
+ CannotCreatePortletWebAppException ex = null;
+ if (e instanceof CannotCreatePortletWebAppException)
+ {
+ ex = (CannotCreatePortletWebAppException)e;
+ }
+ else
+ {
+ ex = new CannotCreatePortletWebAppException(e);
+ }
+ throw ex;
+ }
+ }
+
+ public void instrument() throws Exception
+ {
+ // Get class loader
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ // Get some class
+ Class containerItf = cl.loadClass("org.apache.catalina.Container");
+
+ // Inject the command servlet only one time, so we look if it exist already
+ Method findChildMethod = containerItf.getMethod("findChild", new
Class[]{String.class});
+ Object commandServlet = findChildMethod.invoke(standardContext, new
Object[]{"CommandServlet"});
+ if (commandServlet == null)
+ {
+ addFilterDef(cl);
+ addFilterMap(cl);
+ startFilter(cl);
+ setRunAsListenerAssociation(webApp.getMetaData());
+ try
+ {
+ addCommandServlet(cl);
+ }
+ finally
+ {
+ setRunAsListenerAssociation(null);
+ }
+ }
+ }
+
+ private void startFilter(ClassLoader cl) throws Exception
+ {
+ // Get classes
+ Class standardContextClass =
cl.loadClass("org.apache.catalina.core.StandardContext");
+
+ // Start filters
+ Method filterStartMethod = standardContextClass.getMethod("filterStart",
new Class[0]);
+ filterStartMethod.invoke(standardContext, new Object[0]);
+ }
+
+ private void setRunAsListenerAssociation(Object o)
+ {
+ try
+ {
+ Class clazz =
Thread.currentThread().getContextClassLoader().loadClass("org.jboss.web.tomcat.security.RunAsListener");
+
+ //
+ log.debug("RunAsListener detected");
+ Field field = clazz.getDeclaredField("metaDataLocal");
+ ThreadLocal threadLocal = (ThreadLocal)field.get(null);
+ threadLocal.set(o);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.debug("RunAsListener not detected");
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Cannot set the RunAsListener threadlocal because of a security
manager", e);
+ }
+ catch (Exception e)
+ {
+ log.error("Unexpected exception");
+ }
+ }
+
+ private void addFilterMap(ClassLoader cl) throws Exception
+ {
+ // Get classes
+ Class containerItf = cl.loadClass("org.apache.catalina.Container");
+ Class standardWrapperClass =
cl.loadClass("org.apache.catalina.core.StandardWrapper");
+ Class filterMapClass =
cl.loadClass("org.apache.catalina.deploy.FilterMap");
+ Class standardContextClass =
cl.loadClass("org.apache.catalina.core.StandardContext");
+
+ // Get all the children
+ Method findChildrenMethod = containerItf.getMethod("findChildren", new
Class[0]);
+ Object[] chilren = (Object[])findChildrenMethod.invoke(standardContext, new
Object[0]);
+
+ // Iterate
+ for (int i = 0; i < chilren.length; i++)
+ {
+ Object child = chilren[i];
+ Class childClass = child.getClass();
+ if (childClass.equals(standardWrapperClass))
+ {
+ // If it is a wrapper we instrument
+ Object filterMap = filterMapClass.newInstance();
+
+ // Get servlet name
+ Method getServletNameMethod =
standardWrapperClass.getMethod("getServletName", new Class[0]);
+ String servletName = (String)getServletNameMethod.invoke(child, new
Object[0]);
+
+ // Configure filter map
+ Method setDispatcherMethod =
filterMapClass.getMethod("setDispatcher", new Class[]{String.class});
+ setDispatcherMethod.invoke(filterMap, new Object[]{"INCLUDE"});
+ Method FilterMapSetFilterNameMethod =
filterMapClass.getMethod("setFilterName", new Class[]{String.class});
+ FilterMapSetFilterNameMethod.invoke(filterMap, new
Object[]{"CommandFilter"});
+ Method setServletNameMethod =
filterMapClass.getMethod("addServletName", new Class[]{String.class});
+ setServletNameMethod.invoke(filterMap, new Object[]{servletName});
+
+ // Add the filter map
+ Method addFilterMapMethod =
standardContextClass.getMethod("addFilterMap", new Class[]{filterMapClass});
+ addFilterMapMethod.invoke(standardContext, new Object[]{filterMap});
+ }
+ }
+ }
+
+ private void addCommandServlet(ClassLoader cl) throws Exception
+ {
+ //
+ Class containerItf = cl.loadClass("org.apache.catalina.Container");
+ Class standardContextClass =
cl.loadClass("org.apache.catalina.core.StandardContext");
+ Class containerBaseClass =
cl.loadClass("org.apache.catalina.core.ContainerBase");
+ Class contextItf = cl.loadClass("org.apache.catalina.Context");
+
+ // Ask the context to create a wrapper
+ Method createWrapperMethod =
standardContextClass.getMethod("createWrapper", EMPTY_CLASS_ARRAY);
+ Object wrapper = createWrapperMethod.invoke(standardContext, EMPTY_OBJECT_ARRAY);
+ Class wrapperClass = wrapper.getClass();
+ Object[] wrapperArray = (Object[])Array.newInstance(containerItf, 1);
+ wrapperArray[0] = wrapper;
+
+ Method setServletNameMethod = wrapperClass.getMethod("setServletName",
new Class[]{String.class});
+ setServletNameMethod.invoke(wrapper, new Object[]{"CommandServlet"});
+
+ Method setServletClassMethod = wrapperClass.getMethod("setServletClass",
new Class[]{String.class});
+ setServletClassMethod.invoke(wrapper, new
Object[]{CommandServlet.class.getName()});
+
+ Method setLoadOnStartupMethod =
wrapperClass.getMethod("setLoadOnStartup", new Class[]{int.class});
+ setLoadOnStartupMethod.invoke(wrapper, new Object[]{new Integer(0)});
+
+ Method addChildMethod = containerBaseClass.getMethod("addChild", new
Class[]{containerItf});
+ addChildMethod.invoke(standardContext, new Object[]{wrapper});
+
+ Method addServletMapping = contextItf.getMethod("addServletMapping", new
Class[]{String.class, String.class});
+ addServletMapping.invoke(standardContext, new Object[]{"/jbossportlet",
"CommandServlet"});
+
+ Method loadOnStartupMethod =
standardContextClass.getMethod("loadOnStartup", new
Class[]{wrapperArray.getClass()});
+ loadOnStartupMethod.invoke(standardContext, new Object[]{wrapperArray});
+ }
+
+ private void addFilterDef(ClassLoader cl) throws Exception
+ {
+ // Get class
+ Class standardContextClass =
cl.loadClass("org.apache.catalina.core.StandardContext");
+ Class filterDefClass =
cl.loadClass("org.apache.catalina.deploy.FilterDef");
+
+ // Create filter def
+ Object filterDef = filterDefClass.newInstance();
+
+ //
+ Method setDescriptionMethod = filterDefClass.getMethod("setDescription",
new Class[]{String.class});
+ setDescriptionMethod.invoke(filterDef, new Object[]{""});
+
+ //
+ Method setDisplayNameMethod = filterDefClass.getMethod("setDisplayName",
new Class[]{String.class});
+ setDisplayNameMethod.invoke(filterDef, new Object[]{""});
+
+ //
+ Method setFilterClassMethod = filterDefClass.getMethod("setFilterClass",
new Class[]{String.class});
+ setFilterClassMethod.invoke(filterDef, new
Object[]{CommandFilter.class.getName()});
+
+ //
+ Method FilterDefSetFilterNameMethod =
filterDefClass.getMethod("setFilterName", new Class[]{String.class});
+ FilterDefSetFilterNameMethod.invoke(filterDef, new
Object[]{"CommandFilter"});
+
+ //
+ Method setLargeIconMethod = filterDefClass.getMethod("setLargeIcon", new
Class[]{String.class});
+ setLargeIconMethod.invoke(filterDef, new Object[]{""});
+
+ //
+ Method setSmallIconMethod = filterDefClass.getMethod("setSmallIcon", new
Class[]{String.class});
+ setSmallIconMethod.invoke(filterDef, new Object[]{""});
+
+ // Finally add the filter def
+ Method addFilterDefMethod =
standardContextClass.getMethod("addFilterDef", new Class[]{filterDefClass});
+ addFilterDefMethod.invoke(standardContext, new Object[]{filterDef});
+ }
+
+ private ClassLoader getClassLoader(MBeanServer server, ObjectName name) throws
Exception
+ {
+ Object loader = server.getAttribute(name, "loader");
+ Method getClassLoaderMethod =
loader.getClass().getMethod("getClassLoader", new Class[0]);
+ return (ClassLoader)getClassLoaderMethod.invoke(loader, new Object[0]);
+ }
+}
Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-03-12
14:48:11 UTC (rev 6638)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-03-12
14:50:21 UTC (rev 6639)
@@ -29,6 +29,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.Exceptions;
import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.http.QueryStringParser;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.RequestControllerDispatcher;
@@ -290,7 +291,7 @@
String queryString = req.getQueryString();
if (queryString != null)
{
- queryParameterMap = parseQueryString(queryString);
+ queryParameterMap = QueryStringParser.parseQueryString(queryString);
}
//
@@ -438,53 +439,4 @@
{
return URLContext.newInstance(req.isSecure(), req.getRemoteUser() != null);
}
-
- /** Parse the query string and build an unmodifiable parameter map of it. */
- private Map parseQueryString(String queryString)
- {
- Map result = Collections.EMPTY_MAP;
- for (StringTokenizer tokenizer = new StringTokenizer(queryString,
"&"); tokenizer.hasMoreTokens();)
- {
- String token = tokenizer.nextToken();
- int pos = token.indexOf('=');
- if (pos > 0)
- {
- // Get name and value
- String encodedName = token.substring(0, pos);
- String encodedValue = token.substring(pos + 1, token.length());
-
- // Decode properly
- String name = URLTools.decodeXWWWFormURL(encodedName);
- String value = URLTools.decodeXWWWFormURL(encodedValue);
-
- // Put the values in the result map
- String[] values = (String[])result.get(name);
- if (values == null)
- {
- values = new String[1];
- }
- else
- {
- String[] tmp = new String[values.length + 1];
- System.arraycopy(values, 0, tmp, 0, values.length);
- values = tmp;
- }
- values[values.length - 1] = value;
-
- // Replace the empty map if necessary with a real hashmap
- if (result.isEmpty())
- {
- result = new HashMap();
- }
- result.put(name, values);
- }
- else
- {
- // Not well formed
- // -1 mean we have just a parameter name
- // 0 means we have an empty name
- }
- }
- return result.isEmpty() ? result : Collections.unmodifiableMap(result);
- }
}