incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r482451 [5/5] - in /incubator/adffaces/branches/jwaldman-portal/trinidad: trinidad-api/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-api/src/main/jav...
Date Tue, 05 Dec 2006 02:02:55 GMT
Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/LazyValueBinding.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/LazyValueBinding.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/LazyValueBinding.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/LazyValueBinding.java Mon Dec  4 18:02:50 2006
@@ -1,126 +0,0 @@
-/*
- * 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;
-
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ReferenceSyntaxException;
-import javax.faces.el.ValueBinding;
-
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-
-/**
- * A ValueBinding class that lazily parses the underlying EL expression
- * (in case the Application object is not yet available).  Unfortunately,
- * this implementation means that errors in the syntax of the EL
- * expression won't get detected until use.
- *
- * @author The Oracle ADF Faces Team
- */
-class LazyValueBinding extends ValueBinding
-{
-  /**
-   * Create a ValueBinding;  if the Application is not yet
-   * available, delay actual parsing until later.
-   */
-  static public ValueBinding createValueBinding(String expression)
-  {
-    ApplicationFactory factory = (ApplicationFactory)
-      FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
-    if (factory != null)
-    {
-      Application application = factory.getApplication();
-      if (application != null)
-      {
-        try
-        {
-          return application.createValueBinding(expression);
-        }
-        catch (NullPointerException npe)
-        {
-          ;
-          // In the Sun RI, JSF 1.0 and 1.1, creating a ValueBinding
-          // when there isn't a FacesContext results in a NullPointerException.
-          // Work around this bug.
-        }
-      }
-    }
-
-    return new LazyValueBinding(expression);
-  }
-
-  private LazyValueBinding(String expression)
-  {
-    _expression = expression;
-  }
-
-  @Override
-  public Object getValue(FacesContext context)
-  {
-    return _getValueBinding().getValue(context);
-  }
-
-  @Override
-  public void setValue(FacesContext context, Object value)
-  {
-    _getValueBinding().setValue(context, value);
-  }
-
-  @Override
-  public boolean isReadOnly(FacesContext context)
-  {
-    return _getValueBinding().isReadOnly(context);
-  }
-
-  @Override
-  public Class<?> getType(FacesContext context)
-  {
-    return _getValueBinding().getType(context);
-  }
-
-  @Override
-  public String getExpressionString()
-  {
-    return _expression;
-  }
-
-  private ValueBinding _getValueBinding()
-  {
-    if (_binding == null)
-    {
-      ApplicationFactory factory = (ApplicationFactory)
-        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
-      Application application = factory.getApplication();
-      try
-      {
-        _binding = application.createValueBinding(_expression);
-      }
-      catch (ReferenceSyntaxException rse)
-      {
-        _LOG.warning(rse);
-      }
-    }
-
-    return _binding;
-  }
-
-  private final String       _expression;
-  private       ValueBinding _binding;
-
-  static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(LazyValueBinding.class);
-}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/PseudoFacesContext.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/PseudoFacesContext.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/PseudoFacesContext.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/PseudoFacesContext.java Mon Dec  4 18:02:50 2006
@@ -15,17 +15,7 @@
  */
 package org.apache.myfaces.trinidadinternal.webapp;
 
-import java.io.InputStream;
-import java.net.URL;
-
-import java.util.AbstractMap;
-import java.util.Collections;
 import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import java.security.Principal;
 
 import javax.faces.application.Application;
 import javax.faces.application.FacesMessage;
@@ -34,16 +24,8 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseStream;
 import javax.faces.context.ResponseWriter;
-
 import javax.faces.render.RenderKit;
 
-//import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
 /**
  * Pseudo FacesContext, vended by the filter for code that 
  * needs to run before (or after) the FacesServlet, but needs
@@ -54,12 +36,10 @@
  */
 class PseudoFacesContext extends FacesContext
 {
-  public PseudoFacesContext(
-    ServletRequest  request,
-    ServletResponse response)
+  public PseudoFacesContext(ExternalContext ec)
   {
-    _external = new External((HttpServletRequest) request,
-                             (HttpServletResponse) response);
+    assert ec!= null;
+    _external = ec;
   }
 
   @Override
@@ -178,281 +158,4 @@
 
 
   private final ExternalContext _external;
-
-  private static final class External extends ExternalContext
-  {
-    public External(
-      HttpServletRequest  request,
-      HttpServletResponse response)
-    {
-      _request  = request;
-      _response = response;
-    }
-    
-    // Can't very well have a ServletContext before a servlet!!!
-    @Override
-    public Object getContext() { throw new UnsupportedOperationException(); }
-    @Override
-    public Object getRequest() { return _request; }
-    @Override
-    public Object getResponse() { return _response; }
-    @Override
-    public Object getSession(boolean create)
-    {
-      return _request.getSession(create);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Map<String, Object> getSessionMap()
-    {
-      Object o = getSession(true);
-      if (o == null)
-        return Collections.EMPTY_MAP;
-
-      return new SessionMap((HttpSession) o);
-    }
-
-    @Override
-    public String getRequestContextPath()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String getRequestServletPath()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String getInitParameter(String name)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String encodeResourceURL(String url)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String encodeActionURL(String url)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, Object> getRequestMap()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, Object> getApplicationMap()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void dispatch(String path)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String encodeNamespace(String name)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String getAuthType()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    // -= Simon Lessard =- 
-    // FIXME: Odd... JSF 1.2 does not give generics type for this map
-    @SuppressWarnings("unchecked")
-    @Override
-    public Map getInitParameterMap()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String getRemoteUser()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, Object> getRequestCookieMap()
-    {
-      throw new UnsupportedOperationException();
-    }
-    
-    @Override
-    public Map<String, String> getRequestHeaderMap()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, String[]> getRequestHeaderValuesMap()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Locale getRequestLocale()
-    {
-      throw new UnsupportedOperationException();
-    }
-    
-    @Override
-    public Iterator<Locale> getRequestLocales()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, String> getRequestParameterMap()
-    {
-      return new ParameterMap(_request);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Iterator<String> getRequestParameterNames()
-    {
-      return _request.getParameterMap().keySet().iterator();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Map<String, String[]> getRequestParameterValuesMap()
-    {
-      return _request.getParameterMap();
-    }
-
-    @Override
-    public String getRequestPathInfo()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public URL getResource(String path)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public InputStream getResourceAsStream(String path)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Set<String> getResourcePaths(String path)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Principal getUserPrincipal()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean isUserInRole(String role)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void log(String message)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void log(String message, Throwable exception)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void redirect(String url)
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    private HttpServletRequest  _request;
-    private HttpServletResponse _response;
-  }
-
-  private static final class ParameterMap extends AbstractMap<String, String>
-  {
-    public ParameterMap(ServletRequest request)
-    {
-      _request = request;
-    }
-    
-    @Override
-    public String get(Object key)
-    {
-      return _request.getParameter((String) key);
-    }
-        
-    @Override
-    public Set<Map.Entry<String, String>> entrySet()
-    {
-      throw new UnsupportedOperationException();
-    }
-    
-    private ServletRequest _request;
-  }
-
-  private static final class SessionMap extends AbstractMap<String, Object>
-  {
-    public SessionMap(HttpSession session)
-    {
-      _session = session;
-    }
-    
-    @Override
-    public Object get(Object key)
-    {
-      return _session.getAttribute((String) key);
-    }
-    
-    @Override
-    public Object put(String key, Object value)
-    {
-      Object old = _session.getAttribute(key);
-      _session.setAttribute(key, value);
-      return old;
-    }
-    
-    @Override
-    public Object remove(Object key)
-    {
-      Object old = _session.getAttribute((String) key);
-      _session.removeAttribute((String) key);
-      return old;
-    }
-    
-    @Override
-    public Set<Map.Entry<String, Object>> entrySet()
-    {
-      throw new UnsupportedOperationException();
-    }
-    
-    private HttpSession _session;
-  }
 }

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=482451&r1=482450&r2=482451
==============================================================================
--- 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 Mon Dec  4 18:02:50 2006
@@ -16,14 +16,11 @@
 package org.apache.myfaces.trinidadinternal.webapp;
 
 import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
-
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
@@ -36,20 +33,15 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
+import org.apache.myfaces.trinidad.context.external.ServletExternalContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-import org.apache.myfaces.trinidad.context.RequestContext;
-import org.apache.myfaces.trinidad.context.RequestContextFactory;
-import org.apache.myfaces.trinidad.model.UploadedFile;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
-
-import org.apache.myfaces.trinidadinternal.context.RequestContextFactoryImpl;
+import org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl;
+import org.apache.myfaces.trinidadinternal.config.dispatch.DispatchResponseConfiguratorImpl;
+import org.apache.myfaces.trinidadinternal.config.dispatch.DispatchServletResponse;
+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.TrinidadPhaseListener;
-import org.apache.myfaces.trinidadinternal.share.util.MultipartFormHandler;
-import org.apache.myfaces.trinidadinternal.share.util.MultipartFormItem;
-import org.apache.myfaces.trinidad.skin.SkinFactory;
-import org.apache.myfaces.trinidadinternal.skin.SkinFactoryImpl;
-import org.apache.myfaces.trinidadinternal.skin.SkinUtils;
 
 /**
  * Actual implementation of the Trinidad servlet filter.
@@ -88,69 +80,35 @@
       context.getExternalContext().getRequestMap().get(_IS_RETURNING_KEY));
   }
 
-
-
-  /**
-   * Sets the maximum number of bytes that MultipartFormItem.writeFile()
-   * will be allowed to write.  This value may be set immediately
-   * before or between calls to MultipartFormItem.writeFile().  If
-   * any call to writeFile() exceeds this value, an EOFException
-   * will be thrown.
-   * <p>
-   * @param maxAllowedBytes the maximum number of bytes that
-   * MultipartFormItem.writeFile() will be allowed to write.  Defaults
-   * to 128MB.
-   * @see org.apache.myfaces.trinidadinternal.share.util.MultipartFormItem#writeFile
-   */
-  public void setMaximumAllowedBytes(long maxAllowedBytes)
-  {
-    _maxAllowedBytes = Math.max(0L, maxAllowedBytes);
-  }
-
-  /**
-   * Gets the maximum number of bytes that MultipartFormItem.writeFile()
-   * will be allowed to write.
-   */
-  public long getMaximumAllowedBytes()
-  {
-    return _maxAllowedBytes;
-  }
-
   public void init(
     FilterConfig filterConfig) throws ServletException
   {
-    if (RequestContextFactory.getFactory() == null)
-      RequestContextFactory.setFactory(new RequestContextFactoryImpl());
-
-    _servletContext = filterConfig.getServletContext();
-
-    // Create a new SkinFactory if needed.
-    if (SkinFactory.getFactory() == null)
-      SkinFactory.setFactory(new SkinFactoryImpl());
-
-    // register the base skins
-    SkinUtils.registerBaseSkins();
-    
-    _filters = ClassLoaderUtils.getServices(TrinidadFilterImpl.class.getName());
-    for(Filter f:_filters)
-    {
-      f.init(filterConfig);
-    }
-    // after the 'services' filters are initialized, then register
-    // the skin extensions & skin additions found in trinidad-skins.xml. 
-    // This gives a chance to the 'services' filters to create more base
-    // skins that the skins in trinidad-skins.xml can extend.
-    SkinUtils.registerSkinExtensions(_servletContext);
-
+      _servletContext = filterConfig.getServletContext();
+      
+      //This is the container agnostic initialization filters.  These will work in the portal
+      //as well, but they will be tied to the creation of the Lifecycle.
+      ExternalContext externalContext = new ServletExternalContext(_servletContext, null, null);
+      GlobalConfiguratorImpl.getInstance().init(externalContext);
+      
+      //There is some functionality that still might require servlet-only filter services.
+      _filters = ClassLoaderUtils.getServices(TrinidadFilterImpl.class.getName());
+      for(Filter f:_filters)
+      {
+        f.init(filterConfig);
+      }
   }
 
   public void destroy()
   {
-    for(Filter f:_filters)
-    {
-      f.destroy();
-    }
-    _filters = null;
+      //Destroy filter services
+      for(Filter f:_filters)
+      {
+          f.destroy();
+      }
+      _filters = null;
+      
+      //Destroy container agnostic services
+      GlobalConfiguratorImpl.getInstance().destroy();
   }
 
   @SuppressWarnings("unchecked")
@@ -159,6 +117,7 @@
     ServletResponse response,
     FilterChain     chain) throws IOException, ServletException
   {
+    //Execute the filter services
     if (!_filters.isEmpty())
       chain = new FilterListChain(_filters, chain);
 
@@ -166,110 +125,26 @@
     // properly installed.
     request.setAttribute(_FILTER_EXECUTED_KEY, Boolean.TRUE);
 
-
-    // If someone didn't release the RequestContext on an earlier request,
-    // then it'd still be around, and trying to create a new one
-    // would trigger an exception.  We don't want to take down
-    // this thread for all eternity, so clean up after poorly-behaved code.
-    RequestContext context = RequestContext.getCurrentInstance();
-    if (context != null)
-    {
-      if (_LOG.isWarning())
-        _LOG.warning("RequestContext had not been properly released on earlier " +
-                     "request.");
-      context.release();
-    }
-
-    RequestContextFactory factory = RequestContextFactory.getFactory();
-    assert(factory != null);
-
-    // See if we've got a cached RequestContext instance;  if so,
-    // reattach it
-    Object cachedRequestContext = 
-      request.getAttribute(TrinidadPhaseListener.CACHED_REQUEST_CONTEXT);
-
-    // Catch both the null scenario and the 
-    // RequestContext-from-a-different-classloader scenario
-    if (cachedRequestContext instanceof RequestContext)
-    {
-      context = (RequestContext) cachedRequestContext;
-      context.attach();
-    }
-    else
+    ExternalContext externalContext = new ServletExternalContext(_servletContext, request, response);    
+    GlobalConfiguratorImpl.getInstance().beginRequest(externalContext);
+    
+    //To maintain backward compatibilty, wrap the request at the filter level
+    Map<String, String[]> addedParams = (Map<String, String[]>) externalContext.getRequestMap().get(FileUploadConfiguratorImpl._PARAMS);
+    
+    if(addedParams != null)
     {
-      context = factory.createContext(_servletContext, request);
-      request.setAttribute(TrinidadPhaseListener.CACHED_REQUEST_CONTEXT,
-                           context);
+      FileUploadConfiguratorImpl.apply(externalContext);
+      request = new UploadRequestWrapper((HttpServletRequest)request, addedParams);
     }
-
-    assert(RequestContext.getCurrentInstance() == context);
-
+    
     try
     {
-      // Only handle multipart and HTTP requests
-      if (!MultipartFormHandler.isMultipartRequest(request) ||
-          !(request instanceof HttpServletRequest))
-      {
-        _doFilterImpl(request, response, chain);
-      }
-      else
-      {
-        MultipartFormHandler mfh = new MultipartFormHandler(request);
-        mfh.setMaximumAllowedBytes(getMaximumAllowedBytes());
-        mfh.setCharacterEncoding(request.getCharacterEncoding());
-
-        HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-
-        // Copy over all parameters that were already present (for example,
-        // query parameters)
-        parameters.putAll(request.getParameterMap());
-
-        MultipartFormItem item;
-        UploadedFiles files = new UploadedFiles(request);
-        while ((item = mfh.getNextPart()) != null)
-        {
-          String name = item.getName();
-          String value = null;
-          // No filename - it's not a file uploaded field
-          if (item.getFilename() == null)
-          {
-            value = item.getValue();
-            Object oldValue = parameters.get(name);
-            if (oldValue == null)
-            {
-              parameters.put(name, new String[]{value});
-            }
-            else
-            {
-              String[] oldArray = (String[]) oldValue;
-              String[] newArray = new String[oldArray.length + 1];
-              System.arraycopy(oldArray, 0, newArray, 1, oldArray.length);
-              newArray[0] = value;
-              parameters.put(name, newArray);
-            }
-          }
-          // Upload a file
-          else if (item.getFilename().length() > 0)
-          {
-            _doUploadFile(context, request, files, item);
-          }
-        }
-
-        request = new UploadRequestWrapper((HttpServletRequest) request,
-                                           parameters);
-
-        _doFilterImpl(request, response, chain);
-
-        files.dispose();
-      }
+      
+      _doFilterImpl(request, response, chain);
     }
     finally
     {
-      if (context != null)
-      {
-        context.release();
-        assert(RequestContext.getCurrentInstance() == null);
-      }
+      GlobalConfiguratorImpl.getInstance().endRequest(externalContext);
     }
   }
 
@@ -280,12 +155,17 @@
     ServletResponse response,
     FilterChain     chain) throws IOException, ServletException
   {
+    // -= Scott O'Bryan =-
+    // This is used for PPR.  Not needed in Portal Environment at the moment
+    // At some point we may want to make this a configurator
     HttpServletResponse monitor
-      = new MonitorRedirectServletResponse((HttpServletResponse) response,
-                                           request);
-
-    ServletResponse dispatch
-      = new DispatchServletResponse(monitor, (HttpServletRequest)request);
+      = new MonitorRedirectServletResponse((HttpServletResponse) response, request);
+    
+    // -= Scott O'Bryan =-
+    // Added for backward compatibility
+    ExternalContext ec = new ServletExternalContext(_servletContext, request, monitor);
+    HttpServletResponse dispatch = new DispatchServletResponse(ec);
+    DispatchResponseConfiguratorImpl.apply(ec);
 
     _invokeDoFilter(request, dispatch, chain);
 
@@ -298,6 +178,12 @@
     //        However, the Servlet specification suggest <String, Object> so this 
     //        could lead to some nasty problems one day. Especially if JEE spec includes 
     //        generics for its Servlet API soon.
+    //
+    // -= Scott O'Bryan =- 
+    // TODO: The following should be made available to the Portal.  This is not trivial 
+    //       because this just re-invokes the filter chain with a new set of parameters.
+    //       In the portal environment, this must rerun the portlet without the use of 
+    //       filters until Portlet 2.0.
     Map<String, String[]> launchParameters = (Map<String, String[]>)
       request.getAttribute(RequestContextImpl.LAUNCH_PARAMETERS);
     if (launchParameters != null)
@@ -319,7 +205,7 @@
     // Set up a PseudoFacesContext with the actual request and response
     // so that RequestContext can be more functional in the interval
     // between now and when the FacesServlet starts.
-    PseudoFacesContext pfc = new PseudoFacesContext(request, response);
+    PseudoFacesContext pfc = new PseudoFacesContext(new ServletExternalContext(_servletContext, request, response));
     _PSEUDO_FACES_CONTEXT.set(pfc);
     try
     {
@@ -331,28 +217,6 @@
     }
   }
 
-  private void _doUploadFile(
-    RequestContext   context,
-    ServletRequest    request,
-    UploadedFiles     files,
-    MultipartFormItem item) throws IOException
-  {
-    UploadedFile temp = new TempUploadedFile(item);
-
-    UploadedFile file =
-      context.getUploadedFileProcessor().processFile(request, temp);
-
-    if (file != null)
-    {
-      // Store the file.
-      files.__put(item.getName(), file);
-
-      if (_LOG.isFine())
-        _LOG.fine("Uploaded file " + file.getFilename() + "(" +
-                  file.getLength() + " bytes) for ID " + item.getName());
-    }
-  }
-
   /**
    * A ServletResponseWrapper that will catch partial page redirects
    * and handle them correctly.
@@ -424,50 +288,6 @@
       _filters.get(_index).doFilter(request, response, next);
     }
   }
-
-  static private class TempUploadedFile implements UploadedFile
-  {
-    public TempUploadedFile(MultipartFormItem item)
-    {
-      _item = item;
-      assert(item.getValue() == null);
-    }
-
-    public String getFilename()
-    {
-      return _item.getFilename();
-    }
-
-    public String getContentType()
-    {
-      return _item.getContentType();
-    }
-
-    public long getLength()
-    {
-      // The length is not known yet.
-      return -1L;
-    }
-
-    public Object getOpaqueData()
-    {
-      return null;
-    }
-
-    public InputStream getInputStream() throws IOException
-    {
-      return _item.getInputStream();
-    }
-
-    public void dispose()
-    {
-      throw new UnsupportedOperationException();
-    }
-
-    private MultipartFormItem _item;
-  }
-
-  private long _maxAllowedBytes = 1L << 27;
 
   private ServletContext _servletContext;
   private List<Filter> _filters = null;

Added: 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=auto&rev=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java Mon Dec  4 18:02:50 2006
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.myfaces.trinidad.config.GlobalConfigurator;
+
+/**
+ * Implementation of the Trinidad Context Listener
+ *
+ * @author Scott O'Bryan (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class TrinidadListenerImpl implements ServletContextListener
+{
+
+  /* (non-Javadoc)
+   * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
+   */
+  public void contextDestroyed(ServletContextEvent arg0)
+  {
+    GlobalConfigurator config = GlobalConfigurator.getInstance();
+    
+    if(config.isInitialized())
+    {
+      //clean up the global configurator if it is initialized
+      config.destroy();
+    }
+  }
+
+  /* (non-Javadoc)
+   * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
+   */
+  public void contextInitialized(ServletContextEvent arg0)
+  {
+    //Do not initialize configurators here.  They should be initialized lazily.
+  }
+
+}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadRequestWrapper.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadRequestWrapper.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadRequestWrapper.java Mon Dec  4 18:02:50 2006
@@ -1,157 +0,0 @@
-/*
- * Copyright  2003-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;
-
-import java.io.UnsupportedEncodingException;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Enumeration;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-
-import org.apache.myfaces.trinidadinternal.share.util.CaboHttpUtils;
-
-/**
- * Request wrapper class that hooks in parameters identified in
- * the servlet request.
- *
- * @todo Stop going String -> bytes -> String;  change MultipartFormHandler
- *  to simply extract byte arrays, and do all the type conversion here.
- * @author The Oracle ADF Faces Team
- */
-@SuppressWarnings("deprecation")
-class UploadRequestWrapper extends HttpServletRequestWrapper
-{
-  public UploadRequestWrapper(
-      HttpServletRequest request, 
-      Map<String, String[]> extractedParams)
-  {
-    super(request);
-    _extractedParams = extractedParams;
-  }
-
-  /**
-   * Hide the content type so that no one tries to re-download the
-   * uploaded files.
-   */
-  @Override
-  public String getContentType()
-  {
-    return _WWW_FORM_URLENCODED_TYPE;
-  }
-
-  /**
-   * Trap calls to setCharacterEncoding() to decode parameters correctly
-   */
-  @Override
-  public void setCharacterEncoding(String encoding)
-    throws UnsupportedEncodingException
-  {
-    super.setCharacterEncoding(encoding);
-    if (_LOG.isFine())
-      _LOG.fine("Switching encoding of wrapper to " + encoding);
-
-    _extractedAndDecodedParams = 
-      new HashMap<String, String[]>(_extractedParams.size());
-      
-    byte[] buffer = new byte[256];
-    
-    for(Map.Entry<String, String[]> entry : _extractedParams.entrySet())
-    {
-      String key = entry.getKey();
-      key = CaboHttpUtils.decodeRequestParameter(key, encoding, buffer);
-
-      String[] oldValue = entry.getValue();
-      int length = oldValue.length;
-      String[] newValue = new String[length];
-      for (int i = 0; i < length; i++)
-      {
-        newValue[i] = CaboHttpUtils.decodeRequestParameter(oldValue[i],
-                                                           encoding,
-                                                           buffer);
-        if (_LOG.isFinest())
-          _LOG.finest("Parameter " + key + ":" + newValue[i]);
-      }
-
-      _extractedAndDecodedParams.put(key, newValue);
-    }
-
-    // Let the UploadedFiles know, so it can fix up filenames
-    UploadedFiles.setCharacterEncoding(this, encoding);
-  }
-
-  @Override
-  public String getParameter(String param)
-  {
-    String[] value = _getParameterValues(param);
-    if (value == null)
-      return null;
-
-    return value[0];
-  }
-
-  @Override
-  public Map<String, String[]> getParameterMap()
-  {
-    Map<String, String[]> map = _getMap();
-    return Collections.unmodifiableMap(map);
-  }
-
-  @Override
-  public Enumeration<String> getParameterNames()
-  {
-    return Collections.enumeration(_getMap().keySet());
-  }
-
-  @Override
-  public String[] getParameterValues(String param)
-  {
-    String[] value = _getParameterValues(param);
-    if (value == null)
-      return null;
-
-    return value.clone();
-  }
-
-  private String[] _getParameterValues(String param)
-  {
-    return _getMap().get(param);
-  }
-
-  /**
-   * Get the correct map of parameters whether or not setCharacterEncoding()
-   * was called.
-   */
-  private Map<String, String[]> _getMap()
-  {
-    if (_extractedAndDecodedParams != null)
-      return _extractedAndDecodedParams;
-
-    return _extractedParams;
-  }
-
-  private Map<String, String[]> _extractedAndDecodedParams;
-  private Map<String, String[]> _extractedParams;
-
-  private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(UploadRequestWrapper.class);
-  private static final String _WWW_FORM_URLENCODED_TYPE =
-    "application/x-www-form-urlencoded";
-}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileImpl.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileImpl.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileImpl.java Mon Dec  4 18:02:50 2006
@@ -1,450 +0,0 @@
-/*
- * Copyright  2002-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;
-
-import java.io.BufferedInputStream;
-import java.io.EOFException;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.myfaces.trinidad.model.UploadedFile;
-
-/**
- * UploadedFileImpl defines a single file that has been uploaded
- * to the server.
- * 
- * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/webapp/UploadedFileImpl.java#0 $) $Date: 10-nov-2005.18:49:03 $
- * @author The Oracle ADF Faces Team
- */
-public class UploadedFileImpl implements UploadedFile, Serializable
-{
-  public UploadedFileImpl()
-  {
-  }
-
-  /**
-   * Returns the filename reported from the client.
-   */
-  public String getFilename()
-  {
-    return _filename;
-  }
-
-  /**
-   * Returns the MIME type of the file.
-   */
-  public String getContentType()
-  {
-    return _contentType;
-  }
-
-  /**
-   * Returns the total length (in bytes) of the file.
-   */
-  public long getLength()
-  {
-    return _length;
-  }
-
-  public Object getOpaqueData()
-  {
-    return null;
-  }
-
-  /**
-   * Returns an InputStream that can be used to read the file.
-   * This method can be called repeatedly.
-   */
-  public InputStream getInputStream() throws IOException
-  {
-    if (_buffers != null)
-    {
-      return new BufferIS(_buffers, _sizeOfLastBuffer);
-    }
-    else if (_file != null)
-    {
-      return new BufferedInputStream(new FileInputStream(_file));
-    }
-
-    return null;
-  }
-
-
-  /**
-   * Writes the entire contents of the file to an OutputStream.
-   */
-  private void _writeFile(OutputStream out) throws IOException
-  {
-    if (_buffers != null)
-    {
-      int size = _buffers.size();
-      for (int i = 0; i < size; i++)
-      {
-        byte[] buffer = _buffers.get(i);
-        int bytes;
-        if (i == (size - 1))
-          bytes = _sizeOfLastBuffer;
-        else
-          bytes = buffer.length;
-
-        out.write(buffer, 0, bytes);
-      }
-    }
-    else if (_file != null)
-    {
-      FileInputStream in = new FileInputStream(_file);
-      try
-      {
-        byte[] buffer = new byte[_DISK_BUFFER_SIZE];
-        while (true)
-        {
-          int bytes = in.read(buffer);
-          if (bytes < 0)
-            break;
-          out.write(buffer, 0, bytes);
-        }
-      }
-      finally
-      {
-        in.close();
-      }
-    }
-  }
-
-  /**
-   * Disposes of all resources used to store this file.
-   */ 
-  public void dispose()
-  {
-    _length = 0;
-    _buffers = null;
-    if (_file != null)
-    {
-      _file.delete();
-      _file = null;
-    }
-  }
-  
-  /**
-   * Loads the file from a MultipartFormItem.
-   */
-  public void loadFile(
-    UploadedFile      file,
-    long              remainingMemory,
-    long              remainingDiskSpace,
-    String            directory) throws IOException
-  {
-    _filename    = file.getFilename();
-    _contentType = file.getContentType();
-    
-    InputStream in = file.getInputStream();
-
-    // First step: try to read it into memory.  Instead of trying
-    // to build up one big buffer, we create a list of buffers
-    // that are each at most 4K.  This is vastly faster to create
-    // and insignificantly slower to read.
-    while (_length < remainingMemory)
-    {
-      // Read another block of buffered memory.  We'll read up to 4K
-      // at a time, but no more than the remaining amount of memory plus
-      // one byte.  Why plus one?  Well, we want to know when we've
-      // exceeded the memory size - not just reached it.
-      int size = Math.min(((int) (remainingMemory - _length)) + 1,
-                          _MEMORY_BUFFER_SIZE);
-      byte[] buffer = new byte[size];
-      int bytes = _fillBuffer(in, buffer, size);
-
-      _sizeOfLastBuffer = bytes;
-      _length           = _length + bytes;
-
-      if (_buffers == null)
-        _buffers = new ArrayList<byte[]>();
-      _buffers.add(buffer);
-      
-      // If we're done, bail right here.
-      if (bytes < size)
-        return;
-    }
-
-    // If we didn't have enough space to read the file into memory,
-    // and we also don't have enough space available on disk, then
-    // punt right here and now.
-    if (_length > remainingDiskSpace)
-    {
-      _buffers = null;
-      _length  = 0;
-      throw new EOFException("Per-request disk space limits exceeded.");
-    }
-
-    OutputStream out = _createOutputStream(directory);
-      
-    try
-    {
-      // First, copy the file from memory to the file
-      if (_length > 0)
-      {
-        _writeFile(out);
-      }
-      
-      // Free the buffers, since we're
-      _buffers = null;
-      
-      // Now, write directly to the file.
-      while (_length < remainingDiskSpace)
-      {
-        byte[] buffer = new byte[_DISK_BUFFER_SIZE];
-        int bytes = _fillBuffer(in, buffer, _DISK_BUFFER_SIZE);
-        out.write(buffer, 0, bytes);
-        _length = _length + bytes;
-
-        if (bytes < _DISK_BUFFER_SIZE)
-          break;
-      }
-    }
-    finally
-    {
-      out.close();
-
-      // If we read too much - then drop the file, and bail.
-      if (_length > remainingDiskSpace)
-      {
-        _file.delete();
-        _file = null;
-        _length = 0;
-
-        throw new EOFException("Per-request disk space limits exceeded.");
-      }
-    }
-  }
-  
-  @Override
-  public int hashCode()
-  {
-    if (_filename == null)
-      return 0;
-    return _filename.hashCode();
-  }
-
-  @Override
-  public boolean equals(Object o)
-  {
-    // UploadedFiles are only equal to themselves.
-    return (this == o);
-  }
-
-  //
-  // Create the OutputStream.
-  //
-  private OutputStream _createOutputStream(String directory) throws IOException
-  {
-    File tempDir;
-    if (directory == null)
-      tempDir = null;
-    else
-      tempDir = new File(directory);
-
-    // Create our temporary file.
-    _file = File.createTempFile("uix", null, tempDir);
-
-    // Even though we're supposed to clean up these files ourselves,
-    // make sure they get deleted even if an exception terminates
-    // our code.
-    _file.deleteOnExit();
-
-    // No need for additional buffering of the output - we always
-    // buffer the writes - so _don't_ add a BufferedOutputStream.
-    return new FileOutputStream(_file);
-  }
-
-
-  //
-  // If true, we're either in memory (or empty);  if false,
-  // we're on disk.
-  //
-  boolean __isInMemory()
-  {
-    return (_buffers != null);
-  }
-
-  //
-  // Fill a byte buffer from an InputStream.
-  //
-  private int _fillBuffer(
-    InputStream in,
-    byte[]      buffer,
-    int         size) throws IOException
-  {
-    int offset = 0;
-
-    // Read until the buffer is full, or the InputStream runs out.
-    do
-    {
-      int bytes = in.read(buffer, offset, size - offset);
-      if (bytes < 0)
-        break;
-      
-      offset = offset + bytes;
-    }
-    while (offset < size);
-
-    return offset;
-  }
-
-
-  //
-  // InputStream implementation that reads from an in-memory buffer.
-  //
-  static private class BufferIS extends InputStream
-  {
-    public BufferIS(List<byte[]> bufferList, int sizeOfLastBuffer)
-    {
-      _bufferList = bufferList;
-      _sizeOfLastBuffer = sizeOfLastBuffer;
-    }
-
-    // Read a single byte.
-    @Override
-    public int read()
-    {
-      int bufferIndex = _bufferIndex;
-      if (bufferIndex < 0)
-        return -1;
-
-      byte[] buffer = _getBuffer(bufferIndex);
-      byte currByte = buffer[_bufferPos];
-
-      int bufferSize = _getBufferSize(buffer, bufferIndex);
-      _advanceTo(_bufferPos + 1, bufferSize);
-     
-      return currByte & 0xff; 
-    }
-    
-    // Read into a buffer.
-    @Override
-    public int read(byte b[], int off, int len)
-    {
-      int bufferIndex = _bufferIndex;
-      if (bufferIndex < 0)
-        return -1;
-
-      byte[] buffer = _getBuffer(bufferIndex);
-      int bufferSize = _getBufferSize(buffer, bufferIndex);
-      
-      // Read as many bytes are available in the current buffer block,
-      // up to "len" bytes.  If "len" is larger, then in theory
-      // we could loop and read multiple blocks, but that'd complicate
-      // our logic here without actually simplifying the developer's
-      // logic any (they can't assume an InputStream behaves that way).
-      int bufferPos = _bufferPos;
-      int bytes = Math.min(len, bufferSize - bufferPos);
-      System.arraycopy(buffer, bufferPos, b, off, bytes);
-      _advanceTo(bufferPos + bytes, bufferSize);
-     
-      return bytes;
-    }
-
-    //
-    // Returns the number of bytes that will be made avaialable
-    // in the next call to read(byte[], int, int);
-    //
-    @Override
-    public int available()
-    {
-      int bufferIndex = _bufferIndex;
-      if (bufferIndex < 0)
-        return 0;
-
-      byte[] buffer = _getBuffer(bufferIndex);
-      int bufferSize = _getBufferSize(buffer, bufferIndex);
-
-      return bufferSize - _bufferPos;
-    }
-
-    // Advance the current buffer to a certain position.
-    private void _advanceTo(int pos, int bufferSize)
-    {
-      if (pos >= bufferSize)
-      {
-        _bufferPos = 0;
-        _bufferIndex = _bufferIndex + 1;
-        if (_bufferIndex >= _bufferList.size())
-          _bufferIndex = -1;
-      }
-      else
-      {
-        _bufferPos = pos;
-      }
-    }
-
-    // Return the size of a given buffer. (The last buffer
-    // may not be completely full.)
-    private int _getBufferSize(byte[] buffer, int bufferIndex)
-    {
-      if (bufferIndex == _bufferList.size() - 1)
-        return _sizeOfLastBuffer;
-      
-      return buffer.length;
-    }
-
-    // Return a buffer.
-    private byte[] _getBuffer(int bufferIndex)
-    {
-      return _bufferList.get(bufferIndex);
-    }
-
-    // ArrayList of all the buffers
-    private List<byte[]> _bufferList;
-    // The number of bytes in the last buffer (which may not be full)
-    private int  _sizeOfLastBuffer;
-
-    // Current index into _bufferList
-    private int  _bufferIndex;
-
-    // Current position in _bufferList[_bufferIndex]
-    private int  _bufferPos;
-  }
-
-
-  private String     _filename;
-  private String     _contentType;
-
-  // Total length fo the content, whether in memory or on disk
-  transient private long       _length;
-
-  // File where the content is stored (or null if the content
-  // is in memory)
-  transient private File       _file;
-
-  // ArrayList of all the in-memory buffers (or null if it's in
-  // a File)
-  transient private ArrayList<byte[]> _buffers;
-  // The number of bytes in the last buffer (which may not be full)
-  transient private int        _sizeOfLastBuffer;
-
-  // Buffer sizes.  The memory buffer size can be very small
-  // because of our list-of-small-buffers technique;  for disk I/O,
-  // use a larger buffer.
-  static private final int _MEMORY_BUFFER_SIZE = 2048;
-  static private final int _DISK_BUFFER_SIZE   = 8192;
-}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileProcessorImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileProcessorImpl.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileProcessorImpl.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFileProcessorImpl.java Mon Dec  4 18:02:50 2006
@@ -1,159 +0,0 @@
-/*
- * Copyright  2002-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;
-
-import java.io.File;
-import java.io.IOException;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import org.apache.myfaces.trinidad.model.UploadedFile;
-import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
-
-public class UploadedFileProcessorImpl implements UploadedFileProcessor
-{
-  public UploadedFileProcessorImpl()
-  {
-  }
-
-  public void init(Object c)
-  {
-    if (!(c instanceof ServletContext))
-      return;
-
-    ServletContext context = (ServletContext) c;
-    //
-    // Get MaxMemory and TempDir properties from servlet init params
-    //
-    if (_maxMemory == -1)
-    {
-      String maxMemory = context.getInitParameter(
-                                 MAX_MEMORY_PARAM_NAME);
-      if (maxMemory != null)
-      {
-        try
-        {
-          _maxMemory = Integer.parseInt(maxMemory);
-        }
-        catch (NumberFormatException nfe)
-        {
-          _maxMemory = _DEFAULT_MAX_MEMORY;
-        }
-      }
-      else
-      {
-        _maxMemory = _DEFAULT_MAX_MEMORY;
-      }
-    }
-      
-    if (_maxDiskSpace == -1)
-    {
-      String maxDiskSpace = context.getInitParameter(
-                                                  MAX_DISK_SPACE_PARAM_NAME);
-      if (maxDiskSpace != null)
-      {
-        try
-        {
-          _maxDiskSpace = Integer.parseInt(maxDiskSpace);
-        }
-        catch (NumberFormatException nfe)
-        {
-          _maxMemory = _DEFAULT_MAX_DISK_SPACE;
-        }
-      }
-      else
-      {
-        _maxDiskSpace = _DEFAULT_MAX_DISK_SPACE;
-      }
-    }
-    
-    if (_tempDir == null)
-    {
-      _tempDir = context.getInitParameter(TEMP_DIR_PARAM_NAME);
-      // Use the webapp temporary directory if the temporary directory
-      // has not been explicitly set.
-      if (_tempDir == null)
-      {
-        File tempDirFile = (File) 
-          context.getAttribute("javax.servlet.context.tempdir");
-        if (tempDirFile != null)
-          _tempDir = tempDirFile.getAbsolutePath();
-      }
-    }
-  }
-
-  public UploadedFile processFile(Object       request,
-                                  UploadedFile tempFile)
-    throws IOException
-  {
-    RequestInfo info = _getRequestInfo(request);
-
-    // Process one new file, loading only as much as can fit
-    // in the remaining memory and disk space.
-    UploadedFileImpl file = new UploadedFileImpl();
-    file.loadFile(tempFile,
-                  _maxMemory - info.totalBytesInMemory,
-                  _maxDiskSpace - info.totalBytesOnDisk,
-                  _tempDir);
-
-    // Keep a tally of how much we've stored in memory and on disk.
-    long length = file.getLength();
-    if (file.__isInMemory())
-    {
-      info.totalBytesInMemory += length;
-    }
-    else
-    {
-      info.totalBytesOnDisk += length;
-    }
-
-    return file;
-  }
-
-  private RequestInfo _getRequestInfo(Object r)
-  {
-    if (!(r instanceof ServletRequest))
-      throw new IllegalArgumentException(
-        "Only servlet-based file upload is supported");
-
-    ServletRequest request = (ServletRequest) r;
-    RequestInfo info = (RequestInfo) request.getAttribute(_REQUEST_INFO_KEY);
-    if (info == null)
-    {
-      info = new RequestInfo();
-      request.setAttribute(_REQUEST_INFO_KEY, info);
-    }
-    
-    return info;
-  }
-
-
-  static private class RequestInfo
-  {
-    public long totalBytesInMemory;
-    public long totalBytesOnDisk;
-  }
-
-  private long   _maxMemory = -1;
-  private long   _maxDiskSpace = -1;
-  private String _tempDir = null;
-
-  private static final long _DEFAULT_MAX_MEMORY = 102400;
-  private static final long _DEFAULT_MAX_DISK_SPACE = 2048000;
-
-  private static final String _REQUEST_INFO_KEY = 
-    "org.apache.myfaces.trinidadinternal.webapp.UploadedFilesInfo";
-
-}

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFiles.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFiles.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFiles.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/UploadedFiles.java Mon Dec  4 18:02:50 2006
@@ -1,222 +0,0 @@
-/*
- * Copyright  2002-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;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import javax.servlet.ServletRequest;
-
-import org.apache.myfaces.trinidad.model.UploadedFile;
-
-import org.apache.myfaces.trinidadinternal.share.util.CaboHttpUtils;
-
-/**
- * UploadedFiles defines the set of files that have been uploaded
- * to the server.
- * 
- * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/webapp/UploadedFiles.java#0 $) $Date: 10-nov-2005.18:49:05 $
- * @author The Oracle ADF Faces Team
- */
-final public class UploadedFiles
-{
-  /**
-   * Returns the map of uploaded files for the current request.
-   */
-  @SuppressWarnings("unchecked")
-  static public UploadedFiles getUploadedFiles(FacesContext context)
-  {
-    Map<String, Object> requestMap = 
-      context.getExternalContext().getRequestMap();
-    return (UploadedFiles) requestMap.get(_UPLOADED_FILES_KEY);
-  }
-
-  /**
-   * Store the character encoding for the current request.
-   */
-  static public void setCharacterEncoding(
-    ServletRequest request,
-    String         encoding)
-  {
-    UploadedFiles files = (UploadedFiles)
-      request.getAttribute(_UPLOADED_FILES_KEY);
-    if (files != null)
-    {
-      files._characterEncoding = encoding;
-    }
-  }
-
-  /**
-   * Returns a single uploaded file.
-   * @param name the name under which the file is stored.  In HTML forms,
-   *   this will be derived from the "name" set on the &lt;input&gt; tag.
-   */
-  public UploadedFile getUploadedFile(String name)
-  {
-    UploadedFile file = _map.get(name);
-    if (file == null)
-      return null;
-
-    return new FixFilename(file, _characterEncoding);
-  }
-
-
-  /**
-   * Returns an Iterator of the names of all uploaded files.
-   */
-  public Iterator<String> getUploadedNames()
-  {
-    return _map.keySet().iterator();
-  }
-
-  /**
-   * Dispose of all UploadedFiles.  This will happen automatically
-   * when the current request ends, so clients do not need to
-   * call this method.  However, if a developer is finished with
-   * processing files, this will free up resources earlier.
-   */
-  public void dispose()
-  {
-    Iterator<UploadedFile> iterator = _map.values().iterator();
-    while (iterator.hasNext())
-    {
-      UploadedFile file = iterator.next();
-      file.dispose();
-    }
-
-    _map.clear();
-
-    _totalMemory    = 0;
-    _totalDiskSpace = 0;
-  }
-
-  /**
-   * Creates an UploadedFiles.
-   */
-  UploadedFiles(ServletRequest request)
-  {
-    request.setAttribute(_UPLOADED_FILES_KEY, this);
-    _map = new HashMap<String, UploadedFile>();
-  }
-
-  /**
-   * Store a single UploadedFile.
-   */
-  void __put(String name, UploadedFile file)
-  {
-    _map.put(name, file);
-  }
-
-
-  /**
-   * Return the tally of total memory used.
-   */
-  public long getTotalMemory()
-  {
-    return _totalMemory;
-  }
-
-
-  /**
-   * Return the tally of total disk space used.
-   */
-  public long getTotalDiskSpace()
-  {
-    return _totalDiskSpace;
-  }
-
-
-
-  private long   _totalMemory;
-  private long   _totalDiskSpace;
-  private String _characterEncoding;
-  private final Map<String, UploadedFile> _map;
-
-  private static final String _UPLOADED_FILES_KEY = 
-    "org.apache.myfaces.trinidadinternal.webapp.UploadedFiles";
-
-  static public class FixFilename implements UploadedFile, Serializable
-  {
-    public FixFilename()
-    {
-      // For serialization
-    }
-
-    public FixFilename(UploadedFile file, String encoding)
-    {
-      _file = file;
-      _encoding = encoding;
-    }
-    
-    public String getFilename()
-    {
-      String filename = _file.getFilename();
-      if (_encoding == null)
-        return filename;
-
-      try
-      {
-        return CaboHttpUtils.decodeRequestParameter(filename,
-                                                    _encoding,
-                                                    null);
-      }
-      catch (UnsupportedEncodingException uee)
-      {
-        // Should never happen, since the encoding should have
-        // already been vetted in UploadedRequestWrapper
-        assert false;
-        return filename;
-      }
-    }
-
-    public String getContentType()
-    {
-      return _file.getContentType();
-    }
-
-    public long getLength()
-    {
-      return _file.getLength();
-    }
-
-    public Object getOpaqueData()
-    {
-      return _file.getOpaqueData();
-    }
-
-    public InputStream getInputStream() throws IOException
-    {
-      return _file.getInputStream();
-    }
-
-
-    public void dispose()
-    {
-      _file.dispose();
-    }
-
-    private UploadedFile _file;
-    private String       _encoding;
-  }
-}

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator?view=auto&rev=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator Mon Dec  4 18:02:50 2006
@@ -0,0 +1,2 @@
+org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl
+org.apache.myfaces.trinidadinternal.config.dispatch.DispatchResponseConfiguratorImpl

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/RequestContextTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/RequestContextTest.java?view=diff&rev=482451&r1=482450&r2=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/RequestContextTest.java (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/RequestContextTest.java Mon Dec  4 18:02:50 2006
@@ -122,6 +122,6 @@
   {
     // =-=AEW Would be better to create it with a mock context so we
     // can test parsing
-    return (new RequestContextFactoryImpl()).createContext(null, null);
+    return (new RequestContextFactoryImpl()).createContext(null);
   }
 }

Added: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator?view=auto&rev=482451
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator (added)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/test/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator Mon Dec  4 18:02:50 2006
@@ -0,0 +1,2 @@
+org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl
+org.apache.myfaces.trinidadinternal.config.dispatch.DispatchResponseConfiguratorImpl



Mime
View raw message