incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r489187 [2/3] - in /incubator/adffaces/branches/jwaldman-portal/trinidad: trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-api/src/main/java/org/apache/m...
Date Wed, 20 Dec 2006 20:12:37 GMT
Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/NullEnumeration.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/NullEnumeration.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/NullEnumeration.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/NullEnumeration.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+
+/**
+ * Enumeration without elements. This was origionally taken from MyFaces.
+ * 
+ * @author Anton Koinov
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+final class NullEnumeration implements Enumeration
+{
+  static final NullEnumeration instance()
+  {
+    return s_nullEnumeration;
+  }
+
+  public boolean hasMoreElements()
+  {
+    return false;
+  }
+
+  public Object nextElement()
+  {
+    throw new UnsupportedOperationException("NullEnumeration has no elements");
+  }
+
+  private static final NullEnumeration s_nullEnumeration = new NullEnumeration();
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+
+import javax.portlet.PortletRequest;
+
+/**
+ * PortletRequest parameters as Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author: grantsmith $)
+ * @version $Revision: 169649 $ $Date: 2005-05-11 09:47:12 -0600 (Wed, 11 May 2005) $
+ */
+public class PortletRequestParameterMap extends AbstractAttributeMap<String, String>
+{
+  public PortletRequestParameterMap(final PortletRequest portletRequest)
+  {
+    _portletRequest = portletRequest;
+  }
+
+  @Override
+  protected String getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _portletRequest.getParameter(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    Enumeration<String> parameterNames = _portletRequest.getParameterNames();
+    return parameterNames;
+  }
+
+  private final PortletRequest _portletRequest;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterValuesMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterValuesMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/PortletRequestParameterValuesMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+import javax.portlet.PortletRequest;
+
+/**
+ * PortletRequest multi-value parameters as Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author: grantsmith $)
+ * @version $Revision: 169649 $ $Date: 2005-05-11 09:47:12 -0600 (Wed, 11 May 2005) $
+ */
+public class PortletRequestParameterValuesMap extends AbstractAttributeMap<String, String[]>
+{
+  public PortletRequestParameterValuesMap(final PortletRequest portletRequest)
+  {
+    _portletRequest = portletRequest;
+  }
+
+  @Override
+  protected String[] getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _portletRequest.getParameterValues(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    Enumeration<String> parameterNames = _portletRequest.getParameterNames();
+    return parameterNames;
+  }
+
+  private final PortletRequest _portletRequest;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletApplicationMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletApplicationMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletApplicationMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletApplicationMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * ServletContext attributes as a Map.
+ *
+ * @author Anton Koinov (latest modification by $Author: oros $)
+ * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
+ */
+class ServletApplicationMap extends ModifiableAbstractAttributeMap<String, Object>
+{
+  ServletApplicationMap(final ServletContext servletContext)
+  {
+    _servletContext = servletContext;
+  }
+
+  @Override
+  protected Object getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _servletContext.getAttribute(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    final Enumeration<String> attributeNames = _servletContext.getAttributeNames();
+
+    return attributeNames;
+  }
+
+  @Override
+  protected void removeAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      _servletContext.removeAttribute(key.toString());
+    }
+  }
+
+  @Override
+  protected void setAttribute(final String key, final Object value)
+  {
+    _servletContext.setAttribute(key, value);
+  }
+
+  final ServletContext _servletContext;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * HttpServletRequest Cookies as Map.
+ * 
+ * @author Dimitry D'hondt
+ * @author Anton Koinov
+ * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
+ */
+class ServletCookieMap extends AbstractAttributeMap<String, Object>
+{
+  ServletCookieMap(final HttpServletRequest httpServletRequest)
+  {
+    _httpServletRequest = httpServletRequest;
+  }
+
+  @Override
+  public boolean containsKey(final Object key)
+  {
+    final Cookie[] cookies = _httpServletRequest.getCookies();
+    if (cookies == null)
+    {
+      return false;
+    }
+    for (Cookie element : cookies)
+    {
+      if (element.getName().equals(key))
+      {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  @Override
+  public boolean containsValue(final Object findValue)
+  {
+    if (findValue == null)
+    {
+      return false;
+    }
+
+    final Cookie[] cookies = _httpServletRequest.getCookies();
+    if (cookies == null)
+    {
+      return false;
+    }
+    for (Cookie element : cookies)
+    {
+      if (findValue.equals(element))
+      {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  @Override
+  public boolean isEmpty()
+  {
+    final Cookie[] cookies = _httpServletRequest.getCookies();
+    return cookies == null || cookies.length == 0;
+  }
+
+  @Override
+  public int size()
+  {
+    final Cookie[] cookies = _httpServletRequest.getCookies();
+    return cookies == null ? 0 : cookies.length;
+  }
+
+  @Override
+  protected Object getAttribute(final Object key)
+  {
+    final Cookie[] cookies = _httpServletRequest.getCookies();
+    if (cookies == null)
+    {
+      return null;
+    }
+    for (Cookie element : cookies)
+    {
+      if (element.getName().equals(key))
+      {
+        return element;
+      }
+    }
+
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    final Cookie[] cookies = _httpServletRequest.getCookies();
+    if (cookies == null)
+    {
+      return new CookieNameEnumeration(EMPTY_ARRAY);
+    }
+    else
+    {
+      return new CookieNameEnumeration(cookies);
+    }
+  }
+
+  final HttpServletRequest      _httpServletRequest;
+  private static final Cookie[] EMPTY_ARRAY = new Cookie[0];
+
+  private static class CookieNameEnumeration implements Enumeration<String>
+  {
+    public CookieNameEnumeration(final Cookie[] cookies)
+    {
+      _cookies = cookies;
+      _length = cookies.length;
+    }
+
+    public boolean hasMoreElements()
+    {
+      return _index < _length;
+    }
+
+    public String nextElement()
+    {
+      return _cookies[_index++].getName();
+    }
+
+    private final Cookie[] _cookies;
+    private int            _index;
+    private final int      _length;
+  }
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,603 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+
+/**
+ * This class will implement the ExternalContext for use with Trinidad Configurations using the
+ * Trinidad {@link org.apache.myfaces.Trinidad.config.Configurator} object. <br>
+ * This code was origionally taken from MyFaces.
+ * 
+ * @author Manfred Geiler (Origional MyFaces Code)
+ * @author Anton Koinov
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ServletExternalContext extends ExternalContext
+{
+  public ServletExternalContext(final ServletContext servletContext,
+      final ServletRequest servletRequest, final ServletResponse servletResponse)
+  {
+    assert servletContext != null;
+
+    _servletContext = servletContext;
+    _servletRequest = servletRequest;
+    _servletResponse = servletResponse;
+
+    if (servletRequest != null && servletRequest instanceof HttpServletRequest)
+    {
+      _httpServletRequest = (HttpServletRequest) servletRequest;
+      _httpServletResponse = (HttpServletResponse) servletResponse;
+    }
+
+    if (_httpServletRequest != null)
+    {
+      // HACK: MultipartWrapper scrambles the servletPath for some reason in Tomcat 4.1.29 embedded
+      // in JBoss 3.2.3!?
+      // (this was reported by frederic.auge [frederic.auge@laposte.net])
+      _requestServletPath = _httpServletRequest.getServletPath();
+      _requestPathInfo = _httpServletRequest.getPathInfo();
+
+      // try to set character encoding as described in section 2.5.2.2 of JSF 1.1 spec
+      // we have to use reflection as method setCharacterEncoding is not supported Servlet API <=
+      // 2.3
+      try
+      {
+        if (_setCharacterEncodingMethod != null)
+        {
+          final String contentType = _httpServletRequest.getHeader("Content-Type");
+
+          String characterEncoding = _lookupCharacterEncoding(contentType);
+
+          if (characterEncoding == null)
+          {
+            final HttpSession session = _httpServletRequest.getSession(false);
+
+            if (session != null)
+            {
+              characterEncoding = (String) session.getAttribute(ViewHandler.CHARACTER_ENCODING_KEY);
+            }
+
+            if (characterEncoding != null)
+            {
+              _setCharacterEncodingMethod
+                  .invoke(servletRequest, new Object[] { characterEncoding });
+            }
+          }
+        }
+      }
+      catch (final Exception e)
+      {
+        if (_LOG.isWarning())
+        {
+          _LOG.warning("Failed to set character encoding " + e);
+        }
+      }
+    }
+  }
+
+  @Override
+  public void dispatch(final String path) throws IOException, FacesException
+  {
+    _checkRequest();
+    final RequestDispatcher requestDispatcher = _servletRequest.getRequestDispatcher(path);
+
+    // If there is no dispatcher, send NOT_FOUND
+    if (requestDispatcher == null)
+    {
+      if (_httpServletResponse != null)
+      {
+        _httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
+      }
+
+      return;
+    }
+
+    try
+    {
+      requestDispatcher.forward(_servletRequest, _servletResponse);
+    }
+    catch (final ServletException e)
+    {
+      if (e.getMessage() != null)
+      {
+        throw new FacesException(e.getMessage(), e);
+      }
+      else
+      {
+        throw new FacesException(e);
+      }
+    }
+  }
+
+  @Override
+  public String encodeActionURL(final String url)
+  {
+    _checkRequest();
+    _checkNull(url, "url");
+    
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    
+    return _httpServletResponse.encodeURL(url);
+  }
+
+  @Override
+  public String encodeNamespace(final String s)
+  {
+    _checkRequest();
+    return s;
+  }
+
+  @Override
+  public String encodeResourceURL(final String s)
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletResponse.encodeURL(s);
+  }
+
+  @Override
+  public Map<String, Object> getApplicationMap()
+  {
+    if (_applicationMap == null)
+    {
+      _applicationMap = new ServletApplicationMap(_servletContext);
+    }
+    return _applicationMap;
+  }
+
+  @Override
+  public String getAuthType()
+  {
+    _checkRequest();
+
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletRequest.getAuthType();
+  }
+
+  @Override
+  public Object getContext()
+  {
+    return _servletContext;
+  }
+
+  @Override
+  public String getInitParameter(final String s)
+  {
+    return _servletContext.getInitParameter(s);
+  }
+
+  @Override
+  public Map getInitParameterMap()
+  {
+    if (_initParameterMap == null)
+    {
+      // We cache it as an attribute in ServletContext itself (is this circular reference a
+      // problem?)
+      if ((_initParameterMap = (Map) _servletContext.getAttribute(_INIT_PARAMETER_MAP_ATTRIBUTE)) == null)
+      {
+        _initParameterMap = new ServletInitParameterMap(_servletContext);
+        _servletContext.setAttribute(_INIT_PARAMETER_MAP_ATTRIBUTE, _initParameterMap);
+      }
+    }
+    return _initParameterMap;
+  }
+
+  @Override
+  public String getRemoteUser()
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletRequest.getRemoteUser();
+  }
+
+  @Override
+  public Object getRequest()
+  {
+    return _servletRequest;
+  }
+
+  @Override
+  public String getRequestContextPath()
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletRequest.getContextPath();
+  }
+
+  @Override
+  public Map<String, Object> getRequestCookieMap()
+  {
+    _checkRequest();
+    if (_requestCookieMap == null)
+    {
+      if (_httpServletRequest == null)
+      {
+        throw new IllegalArgumentException("Only HttpServletRequest supported");
+      }
+      _requestCookieMap = new ServletCookieMap(_httpServletRequest);
+    }
+    return _requestCookieMap;
+  }
+
+  @Override
+  public Map<String, String> getRequestHeaderMap()
+  {
+    _checkRequest();
+    if (_requestHeaderMap == null)
+    {
+      if (_httpServletRequest == null)
+      {
+        throw new IllegalArgumentException("Only HttpServletRequest supported");
+      }
+      _requestHeaderMap = new ServletRequestHeaderMap(_httpServletRequest);
+    }
+    return _requestHeaderMap;
+  }
+
+  @Override
+  public Map<String, String[]> getRequestHeaderValuesMap()
+  {
+    _checkRequest();
+    if (_requestHeaderValuesMap == null)
+    {
+      if (_httpServletRequest == null)
+      {
+        throw new IllegalArgumentException("Only HttpServletRequest supported");
+      }
+      _requestHeaderValuesMap = new ServletRequestHeaderValuesMap(_httpServletRequest);
+    }
+    return _requestHeaderValuesMap;
+  }
+
+  @Override
+  public Locale getRequestLocale()
+  {
+    _checkRequest();
+    return _servletRequest.getLocale();
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public Iterator<Locale> getRequestLocales()
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return new EnumerationIterator<Locale>(_httpServletRequest.getLocales());
+  }
+
+  @Override
+  public Map<String, Object> getRequestMap()
+  {
+    _checkRequest();
+    if (_requestMap == null)
+    {
+      _requestMap = new ServletRequestMap(_servletRequest);
+    }
+    return _requestMap;
+  }
+
+  @Override
+  public Map<String, String> getRequestParameterMap()
+  {
+    _checkRequest();
+    if (_requestParameterMap == null)
+    {
+      _requestParameterMap = new ServletRequestParameterMap(_servletRequest);
+    }
+    return _requestParameterMap;
+  }
+
+  @Override
+  public Iterator<String> getRequestParameterNames()
+  {
+    _checkRequest();
+    @SuppressWarnings("unchecked")
+    final Iterator<String> it = new EnumerationIterator<String>(_servletRequest.getParameterNames());
+    return it;
+  }
+
+  @Override
+  public Map<String, String[]> getRequestParameterValuesMap()
+  {
+    _checkRequest();
+    if (_requestParameterValuesMap == null)
+    {
+      _requestParameterValuesMap = new ServletRequestParameterValuesMap(_servletRequest);
+    }
+    return _requestParameterValuesMap;
+  }
+
+  @Override
+  public String getRequestPathInfo()
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _requestPathInfo;
+  }
+
+  @Override
+  public String getRequestServletPath()
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    // return ((HttpServletRequest)_servletRequest).getServletPath();
+    // HACK: see constructor
+    return _requestServletPath;
+  }
+
+  @Override
+  public URL getResource(final String s) throws MalformedURLException
+  {
+    return _servletContext.getResource(s);
+  }
+
+  @Override
+  public InputStream getResourceAsStream(final String s)
+  {
+    return _servletContext.getResourceAsStream(s);
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public Set<String> getResourcePaths(final String s)
+  {
+    return _servletContext.getResourcePaths(s);
+  }
+
+  @Override
+  public Object getResponse()
+  {
+    return _servletResponse;
+  }
+
+  @Override
+  public Object getSession(final boolean create)
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletRequest.getSession(create);
+  }
+
+  @Override
+  public Map<String, Object> getSessionMap()
+  {
+    _checkRequest();
+    if (_sessionMap == null)
+    {
+      if (_httpServletRequest == null)
+      {
+        throw new IllegalArgumentException("Only HttpServletRequest supported");
+      }
+      _sessionMap = new ServletSessionMap(_httpServletRequest);
+    }
+    return _sessionMap;
+  }
+
+  @Override
+  public Principal getUserPrincipal()
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletRequest.getUserPrincipal();
+  }
+
+  @Override
+  public boolean isUserInRole(final String role)
+  {
+    _checkRequest();
+    if (_httpServletRequest == null)
+    {
+      throw new IllegalArgumentException("Only HttpServletRequest supported");
+    }
+    return _httpServletRequest.isUserInRole(role);
+  }
+
+  @Override
+  public void log(final String message)
+  {
+    _servletContext.log(message);
+  }
+
+  @Override
+  public void log(final String message, final Throwable t)
+  {
+    _servletContext.log(message, t);
+  }
+
+  @Override
+  public void redirect(final String url) throws IOException
+  {
+    _checkRequest();
+    if (_servletRequest == null)
+    {
+      throw new UnsupportedOperationException("No request object present on this context");
+    }
+
+    if (_servletResponse instanceof HttpServletResponse)
+    {
+      _httpServletResponse.sendRedirect(url);
+      FacesContext.getCurrentInstance().responseComplete();
+    }
+    else
+    {
+      throw new IllegalArgumentException("Only HttpServletResponse supported");
+    }
+  }
+
+  public void release()
+  {
+    _servletContext = null;
+    _servletRequest = null;
+    _servletResponse = null;
+    _applicationMap = null;
+    _sessionMap = null;
+    _requestMap = null;
+    _requestParameterMap = null;
+    _requestParameterValuesMap = null;
+    _requestHeaderMap = null;
+    _requestHeaderValuesMap = null;
+    _requestCookieMap = null;
+    _initParameterMap = null;
+  }
+  
+  private void _checkNull(final Object o, final String param)
+  {
+    if (o == null)
+    {
+      throw new NullPointerException(param + " can not be null.");
+    }
+  }
+  
+  private void _checkRequest()
+  {
+    if(_servletRequest == null)
+    {
+      throw new UnsupportedOperationException("Request and Response is null on this context.");
+    }
+  }
+  
+  private String _lookupCharacterEncoding(final String contentType)
+  {
+    String characterEncoding = null;
+
+    if (contentType != null)
+    {
+      final int charsetFind = contentType.indexOf("charset=");
+      if (charsetFind != -1)
+      {
+        if (charsetFind == 0)
+        {
+          // charset at beginning of Content-Type, curious
+          characterEncoding = contentType.substring(8);
+        }
+        else
+        {
+          final char charBefore = contentType.charAt(charsetFind - 1);
+          if (charBefore == ';' || Character.isWhitespace(charBefore))
+          {
+            // Correct charset after mime type
+            characterEncoding = contentType.substring(charsetFind + 8);
+          }
+        }
+        if (_LOG.isFine())
+        {
+          _LOG.fine("Incoming request has Content-Type header with character encoding "
+              + characterEncoding);
+        }
+      }
+      else
+      {
+        if (_LOG.isFine())
+        {
+          _LOG.fine("Incoming request has Content-Type header without character encoding: "
+              + contentType);
+        }
+      }
+    }
+    return characterEncoding;
+  }
+
+  private Map<String, Object>         _applicationMap;
+  private HttpServletRequest          _httpServletRequest;
+  private HttpServletResponse         _httpServletResponse;
+  private Map                         _initParameterMap;
+  private Map<String, Object>         _requestCookieMap;
+  private Map<String, String>         _requestHeaderMap;
+  private Map<String, String[]>       _requestHeaderValuesMap;
+  private Map<String, Object>         _requestMap;
+  private Map<String, String>         _requestParameterMap;
+  private Map<String, String[]>       _requestParameterValuesMap;
+  private String                      _requestPathInfo;
+  private String                      _requestServletPath;
+  private ServletContext              _servletContext;
+  private ServletRequest              _servletRequest;
+  private ServletResponse             _servletResponse;
+  private Map<String, Object>         _sessionMap;
+  private static final String         _INIT_PARAMETER_MAP_ATTRIBUTE = ServletInitParameterMap.class
+                                                                       .getName();
+  private static final TrinidadLogger _LOG                          = TrinidadLogger
+                                                                       .createTrinidadLogger(ServletExternalContext.class);
+  private static Method               _setCharacterEncodingMethod   = null;
+  static
+  {
+    try
+    {
+      _setCharacterEncodingMethod = ServletRequest.class.getMethod("setCharacterEncoding",
+          new Class[] { String.class });
+    }
+    catch (final Exception e)
+    {
+      _LOG.warning("Detecting request character encoding is disable.");
+      _LOG.warning("Failed to obtain ServletRequest#setCharacterEncoding() method: " + e);
+    }
+  }
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletInitParameterMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletInitParameterMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletInitParameterMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletInitParameterMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * ServletContext init parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: oros $)
+ * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
+ */
+class ServletInitParameterMap extends AbstractAttributeMap
+{
+  ServletInitParameterMap(final ServletContext servletContext)
+  {
+    _servletContext = servletContext;
+  }
+
+  @Override
+  protected Object getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _servletContext.getInitParameter(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration getAttributeNames()
+  {
+    return _servletContext.getInitParameterNames();
+  }
+
+  final ServletContext _servletContext;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * HttpServletRequest headers as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: oros $)
+ * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
+ */
+class ServletRequestHeaderMap extends AbstractAttributeMap<String, String>
+{
+  ServletRequestHeaderMap(final HttpServletRequest httpServletRequest)
+  {
+    _httpServletRequest = httpServletRequest;
+  }
+
+  @Override
+  protected String getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _httpServletRequest.getHeader(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    final Enumeration<String> headerNames = _httpServletRequest.getHeaderNames();
+    return headerNames;
+  }
+
+  private final HttpServletRequest _httpServletRequest;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * HttpServletRequest header values (multi-value headers) as Map of String[].
+ * 
+ * @author Anton Koinov (latest modification by $Author: matze $)
+ * @version $Revision: 167257 $ $Date: 2004-10-13 05:51:02 -0600 (Wed, 13 Oct 2004) $
+ */
+class ServletRequestHeaderValuesMap extends AbstractAttributeMap<String, String[]>
+{
+  ServletRequestHeaderValuesMap(final HttpServletRequest httpServletRequest)
+  {
+    _httpServletRequest = httpServletRequest;
+  }
+
+  @Override
+  protected String[] getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      final String k = key.toString();
+      String[] ret = _valueCache.get(k);
+      if (ret == null)
+      {
+        @SuppressWarnings("unchecked")
+        final Enumeration<String> headers = _httpServletRequest.getHeaders(k);
+        ret = _toArray(headers);
+        _valueCache.put(k, ret);
+      }
+
+      return ret;
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    Enumeration<String> headerNames = _httpServletRequest.getHeaderNames();
+    return headerNames;
+  }
+
+  private String[] _toArray(final Enumeration<String> e)
+  {
+    final List<String> ret = new ArrayList<String>();
+
+    while (e.hasMoreElements())
+    {
+      ret.add(e.nextElement());
+    }
+
+    return ret.toArray(new String[ret.size()]);
+  }
+
+  private final HttpServletRequest    _httpServletRequest;
+  private final Map<String, String[]> _valueCache = new HashMap<String, String[]>();
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+import javax.servlet.ServletRequest;
+
+
+/**
+ * ServletRequest attributes Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: oros $)
+ * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
+ */
+class ServletRequestMap extends ModifiableAbstractAttributeMap<String, Object>
+{
+  ServletRequestMap(final ServletRequest servletRequest)
+  {
+    _servletRequest = servletRequest;
+  }
+
+  @Override
+  protected Object getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _servletRequest.getAttribute(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    Enumeration<String> attributeNames = _servletRequest.getAttributeNames();
+    return attributeNames;
+  }
+
+  @Override
+  protected void removeAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      _servletRequest.removeAttribute(key.toString());
+    }
+  }
+
+  @Override
+  protected void setAttribute(final String key, final Object value)
+  {
+    _servletRequest.setAttribute(key, value);
+  }
+
+  final ServletRequest _servletRequest;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+
+
+/**
+ * ServletRequest parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: matze $)
+ * @version $Revision: 167257 $ $Date: 2004-10-13 05:51:02 -0600 (Wed, 13 Oct 2004) $
+ */
+public class ServletRequestParameterMap extends AbstractAttributeMap<String, String>
+{
+  public ServletRequestParameterMap(final ServletRequest servletRequest)
+  {
+    _servletRequest = servletRequest;
+  }
+
+  @Override
+  protected String getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _servletRequest.getParameter(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    Enumeration<String> parameterNames = _servletRequest.getParameterNames();
+    return parameterNames;
+  }
+
+  private final ServletRequest _servletRequest;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterValuesMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterValuesMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestParameterValuesMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+
+
+/**
+ * ServletRequest multi-value parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: matze $)
+ * @version $Revision: 167257 $ $Date: 2004-10-13 05:51:02 -0600 (Wed, 13 Oct 2004) $
+ */
+public class ServletRequestParameterValuesMap extends AbstractAttributeMap<String, String[]>
+{
+  public ServletRequestParameterValuesMap(final ServletRequest servletRequest)
+  {
+    _servletRequest = servletRequest;
+  }
+
+  @Override
+  protected String[] getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      return _servletRequest.getParameterValues(key.toString());
+    }
+    return null;
+  }
+
+  @Override
+  protected Enumeration<String> getAttributeNames()
+  {
+    @SuppressWarnings("unchecked")
+    Enumeration<String> parameterNames = _servletRequest.getParameterNames();
+    return parameterNames;
+  }
+
+  private final ServletRequest _servletRequest;
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.context.external;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+
+import java.util.Enumeration;
+
+/**
+ * HttpSession attibutes as Map.
+ *
+ * @author Anton Koinov (latest modification by $Author: schof $)
+ * @version $Revision: 382015 $ $Date: 2006-03-01 06:47:11 -0700 (Wed, 01 Mar 2006) $
+ */
+class ServletSessionMap extends ModifiableAbstractAttributeMap<String, Object>
+{
+  ServletSessionMap(final HttpServletRequest httpRequest)
+  {
+    _httpRequest = httpRequest;
+  }
+
+  @Override
+  protected Object getAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      final HttpSession httpSession = _getSession();
+      return httpSession == null ? null : httpSession.getAttribute(key.toString());
+    }
+
+    return null;
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  protected Enumeration getAttributeNames()
+  {
+    final HttpSession httpSession = _getSession();
+    return httpSession == null ? NullEnumeration.instance() : httpSession.getAttributeNames();
+  }
+
+  @Override
+  protected void removeAttribute(final Object key)
+  {
+    if (key.toString().equals(key))
+    {
+      final HttpSession httpSession = _getSession();
+      if (httpSession != null)
+      {
+        httpSession.removeAttribute(key.toString());
+      }
+    }
+  }
+
+  @Override
+  protected void setAttribute(final String key, final Object value)
+  {
+    _httpRequest.getSession(true).setAttribute(key, value);
+  }
+
+  private HttpSession _getSession()
+  {
+    return _httpRequest.getSession(false);
+  }
+
+  private final HttpServletRequest _httpRequest;
+}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java?view=diff&rev=489187&r1=489186&r2=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java Wed Dec 20 12:12:35 2006
@@ -25,7 +25,7 @@
 
 import javax.faces.context.ExternalContext;
 
-import org.apache.myfaces.trinidad.util.ExternalContextUtils;
+import org.apache.myfaces.trinidadinternal.util.ExternalContextUtils;
 
 /**
  * MultipartFormHandler - parses an incoming file upload post.
@@ -958,4 +958,5 @@
 
   private int                   _contentStreamSize             = -1;
 }
+
 

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/ExternalContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/ExternalContextUtils.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/ExternalContextUtils.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/ExternalContextUtils.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,255 @@
+/*
+ * Copyright  2001-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.faces.context.ExternalContext;
+import javax.portlet.ActionRequest;
+import javax.servlet.ServletRequest;
+
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+
+/**
+ * This provides some functionality for determining some things about the native request object that
+ * is not provided by the base utils.
+ * 
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ExternalContextUtils
+{
+  /**
+   * Returns the character encoding or null if there isn't any
+   * 
+   * @param externalContext
+   * @return
+   */
+  public static String getCharacterEncoding(final ExternalContext externalContext)
+  {
+    if (isAction(externalContext))
+    {
+      try
+      {
+        if (isPortlet(externalContext))
+        {
+          // Allows us to not have the portal api's in the classpath
+          return _getPortletCharacterEncoding(externalContext.getRequest());
+        }
+        else
+        {
+          return ((ServletRequest) externalContext.getRequest()).getCharacterEncoding();
+        }
+      }
+      catch (final ClassCastException e)
+      {
+        _LOG.severe(e);
+      }
+    }
+
+    return null;
+  }
+
+  /**
+   * Returns the content length or -1 if the unknown.
+   * 
+   * @param externalContext
+   *          the ExternalContext
+   * @return the length or -1
+   */
+  public static int getContentLength(final ExternalContext externalContext)
+  {
+    if (isAction(externalContext))
+    {
+      try
+      {
+        if (isPortlet(externalContext))
+        {
+          // Allows us to not have the portal api's in the classpath
+          _getPortletContentLength(externalContext.getRequest());
+        }
+        else
+        {
+          return ((ServletRequest) externalContext.getRequest()).getContentLength();
+        }
+      }
+      catch (final ClassCastException e)
+      {
+        _LOG.severe(e);
+      }
+    }
+    return -1;
+  }
+
+  /**
+   * Returns the content type from the current externalContext or <code>null</code> if unknown.
+   * 
+   * @param externalContext
+   *          the ExternalContext
+   * @return the content type or <code>null</code>
+   */
+  public static String getContentType(final ExternalContext externalContext)
+  {
+    if (isAction(externalContext))
+    {
+      try
+      {
+        if (isPortlet(externalContext))
+        {
+          // Allows us to not have the portal api's in the classpath
+          return _getPortletContentType(externalContext.getRequest());
+        }
+        else
+        {
+          return ((ServletRequest) externalContext.getRequest()).getContentType();
+        }
+      }
+      catch (final ClassCastException e)
+      {
+        // probably won't happen, but it could if we don't have a portlet OR a servlet container.
+        _LOG.severe(e);
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Returns the request input stream if one is available
+   * 
+   * @param externalContext
+   * @return
+   * @throws IOException
+   */
+  public static InputStream getRequestInputStream(final ExternalContext externalContext)
+      throws IOException
+  {
+    if (isAction(externalContext))
+    {
+      try
+      {
+        if (isPortlet(externalContext))
+        {
+          // Allows us to not have the portal api's in the classpath
+          return _getPortletInputStream(externalContext.getRequest());
+        }
+        else
+        {
+          return ((ServletRequest) externalContext.getRequest()).getInputStream();
+        }
+      }
+      catch (final ClassCastException e)
+      {
+        _LOG.severe(e);
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Returns <code>true</code> if this externalContext represents an "action". An action request
+   * is any ServletRequest or a portlet ActionRequest. It is assumed that the ExternalContext
+   * 
+   * @return a boolean of <code>true</code> if this is a Portlet ActionRequest or an non-portlet
+   *         request.
+   */
+  public static boolean isAction(final ExternalContext externalContext)
+  {
+    final Object request = externalContext.getRequest();
+
+    if (_PORTLET_ACTION_REQUEST_CLASS == null)
+    {
+      _LOG
+          .fine("Portlet API's are not on the classpath so isAction will only check for servlet request.");
+      return request instanceof ServletRequest;
+    }
+
+    return request instanceof ServletRequest || _PORTLET_ACTION_REQUEST_CLASS.isInstance(request);
+  }
+
+  /**
+   * Returns whether or not this external context is from a Portlet or a Servlet.
+   * 
+   * @param externalContext
+   *          the ExternalContext to check
+   * 
+   * @return <code>true</code> if this is a portlet RenderRequest or ActionRequest and
+   *         <code>false<code> if it is not.
+   */
+  public static boolean isPortlet(final ExternalContext externalContext)
+  {
+    if (_PORTLET_CONTEXT_CLASS == null)
+    {
+      _LOG.fine("Portlet API's are not on the classpath therefore isPortlet is false.");
+      return false;
+    }
+
+    return _PORTLET_CONTEXT_CLASS.isInstance(externalContext.getContext());
+  }
+
+  private static final String _getPortletCharacterEncoding(final Object request)
+  {
+    return ((ActionRequest) request).getCharacterEncoding();
+  }
+
+  private static final int _getPortletContentLength(final Object request)
+  {
+    return ((ActionRequest) request).getContentLength();
+  }
+
+  private static final String _getPortletContentType(final Object request)
+  {
+    return ((ActionRequest) request).getContentType();
+  }
+
+  private static final InputStream _getPortletInputStream(final Object request) throws IOException
+  {
+    return ((ActionRequest) request).getPortletInputStream();
+  }
+
+  // prevent this from being instantiated
+  private ExternalContextUtils()
+  {}
+
+  private static final TrinidadLogger _LOG = TrinidadLogger
+                                               .createTrinidadLogger(ExternalContextUtils.class);
+
+  // =-= Scott O'Bryan =-=
+  // Performance enhancement. These will be needed anyway, let's not get them every time.
+  private static final Class          _PORTLET_ACTION_REQUEST_CLASS;
+  private static final Class          _PORTLET_CONTEXT_CLASS;
+  
+  static
+  {
+    Class context;
+    Class actionRequest;
+    try
+    {
+      context = Class.forName("javax.portlet.PortletContext");
+      actionRequest = Class.forName("javax.portlet.ActionRequest");
+    }
+    catch (final ClassNotFoundException e)
+    {
+      _LOG
+          .info("Portlet API is not available on the classpath.  Portlet configurations are disabled.");
+      context = null;
+      actionRequest = null;
+    }
+
+    _PORTLET_CONTEXT_CLASS = context;
+    _PORTLET_ACTION_REQUEST_CLASS = actionRequest;
+  }
+}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java?view=diff&rev=489187&r1=489186&r2=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java Wed Dec 20 12:12:35 2006
@@ -33,7 +33,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
-import org.apache.myfaces.trinidad.context.external.ServletExternalContext;
+import org.apache.myfaces.trinidad.config.Configurator;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 import org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl;
@@ -42,6 +42,7 @@
 import org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl;
 import org.apache.myfaces.trinidadinternal.config.upload.UploadRequestWrapper;
 import org.apache.myfaces.trinidadinternal.context.RequestContextImpl;
+import org.apache.myfaces.trinidadinternal.context.external.ServletExternalContext;
 
 /**
  * Actual implementation of the Trinidad servlet filter.

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java?view=diff&rev=489187&r1=489186&r2=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java Wed Dec 20 12:12:35 2006
@@ -18,7 +18,7 @@
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import org.apache.myfaces.trinidad.config.GlobalConfigurator;
+import org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl;
 
 /**
  * Implementation of the Trinidad Context Listener
@@ -29,13 +29,12 @@
 
 public class TrinidadListenerImpl implements ServletContextListener
 {
-
   /* (non-Javadoc)
    * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
    */
   public void contextDestroyed(ServletContextEvent arg0)
   {
-    GlobalConfigurator config = GlobalConfigurator.getInstance();
+    GlobalConfiguratorImpl config = GlobalConfiguratorImpl.getInstance();
     
     if(config.isInitialized())
     {

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionRequestWrapper.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionRequestWrapper.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionRequestWrapper.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright  2004-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.webapp.wrappers;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import javax.portlet.ActionRequest;
+
+/**
+ * Wrapper for the native ActionRequest object.  Unlike the servlet wrappers,
+ * Portlet Request/Response wrapping is not supported by JSR-160.  Therefore
+ * it is important to use the PortletContextWrapper when retrieving the
+ * PortletRequestDispatcher.  This will give you a special dispatcher that is
+ * aware of the wrapping and will deploy the underlying PortletRequest/Response
+ * implementations.
+ *
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ActionRequestWrapper extends PortletRequestWrapper implements ActionRequest
+{
+  public ActionRequestWrapper(ActionRequest request)
+  {
+    super(request);
+   _req = request;  
+  }
+  
+  private ActionRequest _req;
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionRequest#getCharacterEncoding()
+   */
+  public String getCharacterEncoding()
+  {
+    return _req.getCharacterEncoding();
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionRequest#getContentLength()
+   */
+  public int getContentLength()
+  {
+    return _req.getContentLength();
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionRequest#getContentType()
+   */
+  public String getContentType()
+  {
+    return _req.getContentType();
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionRequest#getPortletInputStream()
+   */
+  public InputStream getPortletInputStream() throws IOException
+  {
+    return _req.getPortletInputStream();
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionRequest#getReader()
+   */
+  public BufferedReader getReader() throws UnsupportedEncodingException, IOException
+  {
+    return _req.getReader();
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionRequest#setCharacterEncoding(java.lang.String)
+   */
+  public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException
+  {
+    _req.setCharacterEncoding(arg0);    
+  }
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionResponseWrapper.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionResponseWrapper.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionResponseWrapper.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/ActionResponseWrapper.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright  2004-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.webapp.wrappers;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+
+/**
+ * TODO: Document this 
+ *
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ActionResponseWrapper extends PortletResponseWrapper implements ActionResponse
+{
+  public ActionResponseWrapper(ActionResponse response)
+  {
+    super(response);
+    _resp = response;
+  }
+  
+  private ActionResponse _resp;
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionResponse#sendRedirect(java.lang.String)
+   */
+  public void sendRedirect(String arg0) throws IOException
+  {
+    _resp.sendRedirect(arg0);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionResponse#setPortletMode(javax.portlet.PortletMode)
+   */
+  public void setPortletMode(PortletMode arg0) throws PortletModeException
+  {
+    _resp.setPortletMode(arg0);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionResponse#setRenderParameter(java.lang.String, java.lang.String)
+   */
+  public void setRenderParameter(String arg0, String arg1)
+  {
+    _resp.setRenderParameter(arg0, arg1);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionResponse#setRenderParameter(java.lang.String, java.lang.String[])
+   */
+  public void setRenderParameter(String arg0, String[] arg1)
+  {
+    _resp.setRenderParameter(arg0, arg1);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionResponse#setRenderParameters(java.util.Map)
+   */
+  public void setRenderParameters(Map arg0)
+  {
+    _resp.setRenderParameters(arg0);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.portlet.ActionResponse#setWindowState(javax.portlet.WindowState)
+   */
+  public void setWindowState(WindowState arg0) throws WindowStateException
+  {
+    _resp.setWindowState(arg0);
+  }
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletContextWrapper.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletContextWrapper.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletContextWrapper.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletContextWrapper.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,225 @@
+/*
+ * Copyright  2004-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.webapp.wrappers;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequestDispatcher;
+
+/**
+ * TODO: Document this 
+ *
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class PortletContextWrapper implements PortletContext
+{
+  public PortletContextWrapper(PortletContext context)
+  {
+    _context = context;
+  }
+  
+  private PortletContext _context;
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getAttribute(java.lang.String)
+   */
+  public Object getAttribute(String arg0)
+  {
+    return _context.getAttribute(arg0);
+  }
+
+  /**
+   * @return
+   * @see javax.portlet.PortletContext#getAttributeNames()
+   */
+  public Enumeration getAttributeNames()
+  {
+    return _context.getAttributeNames();
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getInitParameter(java.lang.String)
+   */
+  public String getInitParameter(String arg0)
+  {
+    return _context.getInitParameter(arg0);
+  }
+
+  /**
+   * @return
+   * @see javax.portlet.PortletContext#getInitParameterNames()
+   */
+  public Enumeration getInitParameterNames()
+  {
+    return _context.getInitParameterNames();
+  }
+
+  /**
+   * @return
+   * @see javax.portlet.PortletContext#getMajorVersion()
+   */
+  public int getMajorVersion()
+  {
+    return _context.getMajorVersion();
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getMimeType(java.lang.String)
+   */
+  public String getMimeType(String arg0)
+  {
+    return _context.getMimeType(arg0);
+  }
+
+  /**
+   * @return
+   * @see javax.portlet.PortletContext#getMinorVersion()
+   */
+  public int getMinorVersion()
+  {
+    return _context.getMinorVersion();
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getNamedDispatcher(java.lang.String)
+   */
+  public PortletRequestDispatcher getNamedDispatcher(String arg0)
+  {
+    return new PortletRequestDispatcherWrapper(_context.getNamedDispatcher(arg0));
+  }
+
+  /**
+   * @return
+   * @see javax.portlet.PortletContext#getPortletContextName()
+   */
+  public String getPortletContextName()
+  {
+    return _context.getPortletContextName();
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getRealPath(java.lang.String)
+   */
+  public String getRealPath(String arg0)
+  {
+    return _context.getRealPath(arg0);
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getRequestDispatcher(java.lang.String)
+   */
+  public PortletRequestDispatcher getRequestDispatcher(String arg0)
+  {
+    return new PortletRequestDispatcherWrapper(_context.getRequestDispatcher(arg0));
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @throws MalformedURLException
+   * @see javax.portlet.PortletContext#getResource(java.lang.String)
+   */
+  public URL getResource(String arg0) throws MalformedURLException
+  {
+    return _context.getResource(arg0);
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getResourceAsStream(java.lang.String)
+   */
+  public InputStream getResourceAsStream(String arg0)
+  {
+    return _context.getResourceAsStream(arg0);
+  }
+
+  /**
+   * @param arg0
+   * @return
+   * @see javax.portlet.PortletContext#getResourcePaths(java.lang.String)
+   */
+  public Set getResourcePaths(String arg0)
+  {
+    return _context.getResourcePaths(arg0);
+  }
+
+  /**
+   * @return
+   * @see javax.portlet.PortletContext#getServerInfo()
+   */
+  public String getServerInfo()
+  {
+    return _context.getServerInfo();
+  }
+
+  /**
+   * @param arg0
+   * @param arg1
+   * @see javax.portlet.PortletContext#log(java.lang.String, java.lang.Throwable)
+   */
+  public void log(String arg0, Throwable arg1)
+  {
+    _context.log(arg0, arg1);
+  }
+
+  /**
+   * @param arg0
+   * @see javax.portlet.PortletContext#log(java.lang.String)
+   */
+  public void log(String arg0)
+  {
+    _context.log(arg0);
+  }
+
+  /**
+   * @param arg0
+   * @see javax.portlet.PortletContext#removeAttribute(java.lang.String)
+   */
+  public void removeAttribute(String arg0)
+  {
+    _context.removeAttribute(arg0);
+  }
+
+  /**
+   * @param arg0
+   * @param arg1
+   * @see javax.portlet.PortletContext#setAttribute(java.lang.String, java.lang.Object)
+   */
+  public void setAttribute(String arg0, Object arg1)
+  {
+    _context.setAttribute(arg0, arg1);
+  }
+}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletRequestDispatcherWrapper.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletRequestDispatcherWrapper.java?view=auto&rev=489187
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletRequestDispatcherWrapper.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/PortletRequestDispatcherWrapper.java Wed Dec 20 12:12:35 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright  2004-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadinternal.webapp.wrappers;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+/**
+ * TODO: Document this 
+ *
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class PortletRequestDispatcherWrapper implements PortletRequestDispatcher
+{
+  public PortletRequestDispatcherWrapper(PortletRequestDispatcher dispatcher)
+  {
+    _dispatch = dispatcher;
+  }
+  
+  private PortletRequestDispatcher _dispatch;
+  
+  /* (non-Javadoc)
+   * @see javax.portlet.PortletRequestDispatcher#include(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
+   */
+  public void include(RenderRequest arg0, RenderResponse arg1) throws PortletException, IOException
+  {
+    //We need to dispatch the origional request/response objects.
+    //So cut through all the wrappers and dispatch the origionals.
+    //TODO: Try out some usecases.
+    RenderRequest req = arg0;
+    while(req instanceof RenderRequestWrapper)
+    {
+      req = ((RenderRequestWrapper)req).getRequest();
+    }
+
+    RenderResponse resp = arg1;
+    while(resp instanceof RenderResponseWrapper)
+    {
+      resp = ((RenderResponseWrapper)resp).getResponse();
+    }
+    _dispatch.include(req, resp);
+
+  }
+
+}



Mime
View raw message