You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2007/11/21 01:19:56 UTC

svn commit: r596889 [1/2] - in /myfaces/portlet-bridge/trunk: api/src/main/java/javax/portlet/faces/ impl/src/main/java/org/apache/myfaces/portlet/faces/application/ impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/ impl/src/main/java/org/apa...

Author: sobryan
Date: Tue Nov 20 16:19:55 2007
New Revision: 596889

URL: http://svn.apache.org/viewvc?rev=596889&view=rev
Log:
PORTLETBRIDGE-6: JDK 1.5 Functionality

Applied Simon Lessards patch and made a few minor enhancements.
Thanks a lot Simon, that was a lot of work.

Added:
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/EnumerationIterator.java
      - copied, changed from r596788, myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/LocalesIterator.java
Removed:
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/SimpleStringBuffer.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/LocalesIterator.java
Modified:
    myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/BridgeRenderRequestWrapper.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletRequestDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/HTTPUtils.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/TextUtils.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/WebConfigurationProcessor.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java

Modified: myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java (original)
+++ myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java Tue Nov 20 16:19:55 2007
@@ -62,12 +62,13 @@
                                                         + "BridgeImplClass";
   public static final String BRIDGE_SERVICE_CLASSPATH = "/META-INF/services/javax.portlet.faces.Bridge";
 
-  private Class              mFacesBridgeClass        = null;
-  private Bridge             mFacesBridge             = null;
+  private Class<? extends Bridge> mFacesBridgeClass   = null;
+  private Bridge                  mFacesBridge        = null;
 
   /**
    * Initialize generic faces portlet from portlet.xml
    */
+  @SuppressWarnings("unchecked")
   @Override
   public void init(PortletConfig portletConfig) throws PortletException
   {
@@ -81,7 +82,8 @@
     {
       try
       {
-        mFacesBridgeClass = Thread.currentThread().getContextClassLoader().loadClass(bridgeClassName);
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        mFacesBridgeClass = (Class<? extends Bridge>)loader.loadClass(bridgeClassName);
       }
       catch (ClassNotFoundException cnfe)
       {
@@ -291,7 +293,7 @@
     {
       try
       {
-        mFacesBridge = (Bridge) mFacesBridgeClass.newInstance();
+        mFacesBridge = mFacesBridgeClass.newInstance();
         mFacesBridge.init(getPortletConfig());
       }
       catch (Exception e)

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Tue Nov 20 16:19:55 2007
@@ -22,10 +22,6 @@
 import java.io.IOException;
 import java.io.Writer;
 
-import java.util.Locale;
-
-import java.util.Map;
-
 import javax.faces.FacesException;
 import javax.faces.FactoryFinder;
 import javax.faces.application.StateManager;
@@ -37,17 +33,12 @@
 import javax.faces.context.ResponseWriter;
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
-
 import javax.portlet.RenderResponse;
-
 import javax.portlet.faces.Bridge;
 import javax.portlet.faces.BridgeUtil;
 import javax.portlet.faces.component.PortletNamingContainerUIViewRoot;
 
-import javax.servlet.ServletContext;
-
 import org.apache.myfaces.portlet.faces.context.PortletExternalContextImpl;
-import org.apache.myfaces.portlet.faces.util.URLUtils;
 
 /**
  * View handler implementation for JSF portlet bridge.

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Tue Nov 20 16:19:55 2007
@@ -21,9 +21,7 @@
 
 import java.io.IOException;
 import java.io.Serializable;
-
 import java.rmi.server.UID;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -33,12 +31,10 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Vector;
 
 import javax.el.ELContext;
 import javax.el.ELContextEvent;
 import javax.el.ELContextListener;
-
 import javax.faces.FacesException;
 import javax.faces.FactoryFinder;
 import javax.faces.application.Application;
@@ -48,7 +44,6 @@
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
-
 import javax.faces.context.FacesContextFactory;
 import javax.faces.event.PhaseEvent;
 import javax.faces.event.PhaseId;
@@ -57,7 +52,6 @@
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.ResponseStateManager;
 import javax.faces.webapp.FacesServlet;
-
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortalContext;
@@ -69,10 +63,8 @@
 import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-
 import javax.portlet.faces.Bridge;
 import javax.portlet.faces.BridgeException;
-
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
@@ -82,41 +74,31 @@
 import javax.servlet.http.HttpSessionBindingListener;
 
 import org.apache.myfaces.portlet.faces.bridge.wrapper.BridgeRenderRequestWrapper;
-import org.apache.myfaces.portlet.faces.util.config.WebConfigurationProcessor;
 import org.apache.myfaces.portlet.faces.context.PortletExternalContextImpl;
+import org.apache.myfaces.portlet.faces.util.config.WebConfigurationProcessor;
 
 public class BridgeImpl
   implements Bridge, ELContextListener, PhaseListener
 {
+  // public so PortletStateManager can see/use
+  public static final String UPDATED_VIEW_STATE_PARAM = "org.apache.myfaces.portlet.faces.updatedViewStateParam";
 
-  /**
-   * 
-   */
-  private static final long serialVersionUID = -2181720908326762776L;
-  private static final String REQUEST_SCOPE_LOCK = 
-    "org.apache.myfaces.portlet.faces.requestScopeLock";
-  private static final String REQUEST_SCOPE_MAP = 
-    "org.apache.myfaces.portlet.faces.requestScopeMap";
-  private static final String REQUEST_SCOPE_LISTENER = 
-    "org.apache.myfaces.portlet.faces.requestScopeWatch";
+  private static final String REQUEST_SCOPE_LOCK = "org.apache.myfaces.portlet.faces.requestScopeLock";
+  private static final String REQUEST_SCOPE_MAP = "org.apache.myfaces.portlet.faces.requestScopeMap";
+  private static final String REQUEST_SCOPE_LISTENER = "org.apache.myfaces.portlet.faces.requestScopeWatch";
   private static final String FACES_VIEWROOT = "org.apache.myfaces.portlet.faces.facesViewRoot";
   private static final String FACES_MESSAGES = "org.apache.myfaces.portlet.faces.facesMessages";
-  // public so PortletStateManager can see/use
-  public static final String UPDATED_VIEW_STATE_PARAM =
-    "org.apache.myfaces.portlet.faces.updatedViewStateParam";
-  private static final String REQUEST_PARAMETERS = 
-    "org.apache.myfaces.portlet.faces.requestParameters";
+  private static final String REQUEST_PARAMETERS = "org.apache.myfaces.portlet.faces.requestParameters";
   private static final String REQUEST_SCOPE_ID_RENDER_PARAM = "_bridgeRequestScopeId";
+  private static final int DEFAULT_MAX_MANAGED_REQUEST_SCOPES = 100;
 
-  private PortletConfig mPortletConfig = null;
   private boolean mPreserveActionParams = false;
 
+  private PortletConfig mPortletConfig = null;
   private FacesContextFactory mFacesContextFactory = null;
   private Lifecycle mLifecycle = null;
+  private List<String> mFacesMappings = null;
 
-  private Vector mFacesMappings = null;
-
-  private static final Integer sDefaultMaxManagedRequestScopes = new Integer(100);
 
   public BridgeImpl()
   {
@@ -126,6 +108,8 @@
   public void init(PortletConfig config)
     throws BridgeException
   {
+  	//TODO: Should we throw an exception if the bridge is already initialized?
+  	
     mPortletConfig = config;
     PortletContext portletContext = mPortletConfig.getPortletContext();
 
@@ -149,6 +133,9 @@
     // putting it in the PortletContext. Hence the sync object allows us
     // to limit syncronizing the PortletContext to once per portlet (init
     // time);
+    
+    // TODO: What about synching on a static object or using a class lock?
+    //       Perhaps even the LRUMap itself if said map is a singleton?
     synchronized (portletContext)
     {
       Object lock = portletContext.getAttribute(REQUEST_SCOPE_LOCK);
@@ -167,18 +154,17 @@
 
     // Process and cache the FacesServlet mappings for use by
     // ExternalContext
-    WebConfigurationProcessor facesConfig = new WebConfigurationProcessor(portletContext);
-    mFacesMappings = facesConfig.getFacesMappings();
+    WebConfigurationProcessor webConfig = new WebConfigurationProcessor(portletContext);
+    mFacesMappings = webConfig.getFacesMappings();
     for (int i = 0; i < mFacesMappings.size(); i++)
     {
-      portletContext.log("Mapping: " + (String) mFacesMappings.elementAt(i));
+      portletContext.log("Mapping: " + mFacesMappings.get(i));
     }
   }
 
   public void doFacesRequest(ActionRequest request, ActionResponse response)
     throws BridgeException
   {
-    Map m = null;
     // Set the Portlet lifecycle phase as a request attribute so its
     // available to Faces extensions -- allowing that code to NOT rely on
     // instanceof which can fail if a portlet container uses a single class
@@ -198,7 +184,7 @@
     // acquiring the FacesContext because its possible (though unlikely)
     // the application has inserted itself in this process and sets up
     // needed request attributes.
-    String[] excludedAttributes = getExcludedAttributes(request);
+    List<String> excludedAttributes = getExcludedAttributes(request);
 
     FacesContext context = null;
     try
@@ -206,8 +192,6 @@
       // Get the FacesContext instance for this request
       context = 
           getFacesContextFactory().getFacesContext(mPortletConfig, request, response, getLifecycle());
-      logMap("Received ActionParams: ", 
-             context.getExternalContext().getRequestParameterValuesMap());
 
       // Each action starts a new "action lifecycle"
       // The Bridge preserves request scoped data and if so configured
@@ -275,12 +259,9 @@
     {
       if (context != null)
       {
-        m = context.getExternalContext().getRequestMap();
         context.release();
       }
     }
-
-    logMap("Action completed: ", m);
   }
 
   public void doFacesRequest(RenderRequest request, RenderResponse response)
@@ -310,9 +291,6 @@
           getFacesContextFactory().getFacesContext(mPortletConfig, request, response, lifecycle);
       ExternalContext extCtx = context.getExternalContext();
 
-      logMap("Received RenderParams: ", 
-             context.getExternalContext().getRequestParameterValuesMap());
-
       // Use request from ExternalContext in case its been wrapped by an
       // extension
       RenderRequest extRequest = (RenderRequest) extCtx.getRequest();
@@ -496,13 +474,13 @@
     saveFacesMessageState(context);
 
     // now place the viewRoot in the request scope
-    Map requestMap = context.getExternalContext().getRequestMap();
+    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
     requestMap.put(FACES_VIEWROOT, context.getViewRoot());
   }
 
   private void restoreFacesView(FacesContext context, String scopeId)
   {
-    Map requestMap = context.getExternalContext().getRequestMap();
+    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
     UIViewRoot viewRoot = (UIViewRoot) requestMap.get(FACES_VIEWROOT);
     if (viewRoot != null)
     {
@@ -521,14 +499,14 @@
     // Always preserve the FACES_VIEW_STATE parameter as per spec.
     // If portlet requests it, also preserve the rst of them.
     ExternalContext ec = context.getExternalContext();
-    Map requestMap = ec.getRequestMap();
-    Map requestParameterMap = ec.getRequestParameterValuesMap();
+    Map<String, Object> requestMap = ec.getRequestMap();
+    Map<String, String[]> requestParameterMap = ec.getRequestParameterValuesMap();
     if (!mPreserveActionParams)
     {
       if (requestMap != null && requestParameterMap != null && 
           requestParameterMap.containsKey(ResponseStateManager.VIEW_STATE_PARAM))
       {
-        HashMap m = new HashMap(1);
+        Map<String, String[]> m = new HashMap<String, String[]>(1);
         m.put(ResponseStateManager.VIEW_STATE_PARAM, 
               requestParameterMap.get(ResponseStateManager.VIEW_STATE_PARAM));
         requestMap.put(REQUEST_PARAMETERS, m);
@@ -576,27 +554,33 @@
       values[0] = updatedViewStateParam;
 
       // now see if this scope is in the Map
-      Map scopeMap = (Map) requestScopeMap.get(scopeId);
+      Map<String, Object> scopeMap = requestScopeMap.get(scopeId);
+      
       Boolean isNew = false;
 
       if (scopeMap == null) 
       {
         // allocate a Map  and put
-        scopeMap = new HashMap(1);
+        scopeMap = new HashMap<String, Object>(1);
         // delay adding to requestScopeMap until populated
         isNew = true;
       }
       
       // Now get the RequestParameters from the scope
-      Map requestParams = (Map) scopeMap.get(REQUEST_PARAMETERS);
+      @SuppressWarnings("unchecked")
+      Map<String, String[]> requestParams = (Map<String, String[]>)scopeMap.get(REQUEST_PARAMETERS);
+      
       if (requestParams == null) 
       {
-        requestParams = (Map) new HashMap(1);
+        requestParams = new HashMap<String, String[]>(1);
         scopeMap.put(REQUEST_PARAMETERS, requestParams);
       }
       // finally update the value in the Map
       requestParams.put(ResponseStateManager.VIEW_STATE_PARAM, values);
       
+      //TODO: We delay putting this on the map in case an exception occurs in the above
+      //      code.  The above code should never generate an exception, however, so this
+      //      could be simplified.
       // if a newly allocated scope -- don't forget to add it in
       if (isNew)
       {
@@ -611,31 +595,27 @@
   {
     // see if portlet has defined how many requestScopes to manage
     // for this portlet
-    String managedScopesSetting = 
-      portletContext.getInitParameter(Bridge.MAX_MANAGED_REQUEST_SCOPES);
-    Integer managedScopes = null;
+    int managedScopes = DEFAULT_MAX_MANAGED_REQUEST_SCOPES;
     
+    String managedScopesSetting = 
+    	portletContext.getInitParameter(Bridge.MAX_MANAGED_REQUEST_SCOPES);
     if (managedScopesSetting != null)
     {
-        managedScopes = Integer.getInteger(managedScopesSetting);
+      managedScopes = Integer.parseInt(managedScopesSetting);
     }
     
-    if (managedScopes == null || managedScopes.intValue() <= 0)
-    {
-      managedScopes = sDefaultMaxManagedRequestScopes;
-    }
-
-    return new LRUMap(managedScopes.intValue());
+    return new LRUMap(managedScopes);
   }
 
-  private RenderRequest restoreActionParams(FacesContext context)
+  @SuppressWarnings("unchecked")
+	private RenderRequest restoreActionParams(FacesContext context)
   {
     // this is a little trickier then saving because there is no
     // corresponding set. Instead we wrap the request object and set it
     // on the externalContext.
     ExternalContext ec = context.getExternalContext();
     // Note: only available/restored if this scope was restored.
-    Map m = (Map) ec.getRequestMap().get(REQUEST_PARAMETERS);
+    Map<String, String[]> m = (Map<String, String[]>) ec.getRequestMap().get(REQUEST_PARAMETERS);
 
     // ensures current request returned if nothing to restore/wrap
     RenderRequest wrapped = (RenderRequest) ec.getRequest();
@@ -649,24 +629,21 @@
 
   public void saveFacesMessageState(FacesContext context)
   {
-    Iterator messages;
     // get the messages from Faces Context
-    Iterator clientIds = context.getClientIdsWithMessages();
+    Iterator<String> clientIds = context.getClientIdsWithMessages();
     if (clientIds.hasNext())
     {
       FacesMessageState state = new FacesMessageState();
       while (clientIds.hasNext())
       {
         String clientId = (String) clientIds.next();
-        messages = context.getMessages(clientId);
-        while (messages.hasNext())
+        for(Iterator<FacesMessage> messages = context.getMessages(clientId);messages.hasNext();)
         {
-          state.addMessage(clientId, (FacesMessage) messages.next());
+        	state.addMessage(clientId, messages.next());
         }
       }
-
       // save state in ViewRoot attributes
-      Map requestMap = context.getExternalContext().getRequestMap();
+      Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
       requestMap.put(FACES_MESSAGES, state);
     }
   }
@@ -676,22 +653,18 @@
     // Only restore for Render request
     if (context.getExternalContext().getRequest() instanceof RenderRequest)
     {
-      Map map = context.getExternalContext().getRequestMap();
+      Map<String, Object> map = context.getExternalContext().getRequestMap();
 
       // restoring FacesMessages
-      FacesMessageState state1 = (FacesMessageState) map.get(FACES_MESSAGES);
+      FacesMessageState state = (FacesMessageState) map.get(FACES_MESSAGES);
 
-      if (state1 != null)
+      if (state != null)
       {
-        Iterator messages;
-        Iterator clientIds = state1.getClientIds();
-        while (clientIds.hasNext())
-        {
-          String clientId = (String) clientIds.next();
-          messages = state1.getMessages(clientId);
-          while (messages.hasNext())
-          {
-            context.addMessage(clientId, (FacesMessage) messages.next());
+      	for(String clientId:state.getClientIds())
+      	{
+      		for(FacesMessage message:state.getMessages(clientId))
+      		{
+      			context.addMessage(clientId, message);
           }
         }
       }
@@ -717,7 +690,7 @@
   }
 
   private void saveBridgeRequestScopeData(FacesContext context, String scopeId, 
-                                          String[] excludeList)
+                                          List<String> excludeList)
   {
 
     // Store the RequestMap @ the bridge's request scope
@@ -729,7 +702,8 @@
     watchScope(context, scopeId);
   }
 
-  private void putBridgeRequestScopeData(String scopeId, Object o)
+  @SuppressWarnings("unchecked")
+  private void putBridgeRequestScopeData(String scopeId, Map<String, Object> o)
   {
     PortletContext portletContext = mPortletConfig.getPortletContext();
 
@@ -745,83 +719,35 @@
         requestScopeMap = createRequestScopeMap(portletContext);
         portletContext.setAttribute(REQUEST_SCOPE_MAP, requestScopeMap);
       }
-
-      logMap("Saving RequestScope @ requestScopeId: " + scopeId, (Map) o);
       requestScopeMap.put(scopeId, o);
     }
   }
 
-  private Map copyRequestMap(Map m, String[] excludeList)
+  private Map<String, Object> copyRequestMap(Map<String, Object> m, List<String> excludeList)
   {
-    HashMap copy = new HashMap(m.size());
-
-    Set keySet = m.keySet();
-    if (keySet != null)
-    {
-      Iterator keys = keySet.iterator();
-      while (keys != null && keys.hasNext())
-      {
-        String requestAttrKey = (String) keys.next();
-        Object requestAttrValue = m.get(requestAttrKey);
-        // TODO -- restore the ACTION PARAMS if there
-
-        // Don't copy any of the portlet or Faces objects
-        if (!inExcludeList(excludeList, requestAttrKey) && 
-            !contextObject(requestAttrKey, requestAttrValue))
-        {
-          copy.put(requestAttrKey, requestAttrValue);
-        }
-      }
-    }
+    Map<String, Object> copy = new HashMap<String, Object>(m.size());
+     
+  	for(Map.Entry<String, Object> entry:m.entrySet())
+  	{
+      // TODO -- restore the ACTION PARAMS if there
+
+      // Don't copy any of the portlet or Faces objects
+  		String key = entry.getKey();
+  		Object value = entry.getValue();
+  		if(!excludeList.contains(key) &&
+  			 !contextObject(key, value))
+  		{
+  			copy.put(key, value);
+  		}
+  	}
     return copy;
   }
 
-  private boolean inExcludeList(String[] excludeList, String key)
-  {
-    if (excludeList == null || excludeList.length <= 0)
-    {
-      return false;
-    }
-    for (String element: excludeList)
-    {
-      if (element.equals(key))
-      {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  private String[] getExcludedAttributes(PortletRequest request)
+  
+  @SuppressWarnings("unchecked")
+  private List<String> getExcludedAttributes(PortletRequest request)
   {
-    String[] names = null;
-
-    // first count them to allocate the array
-    int i = 0, count = 0;
-    Enumeration e = request.getAttributeNames();
-    if (e == null)
-    {
-      return null;
-    }
-
-    while (e.hasMoreElements())
-    {
-      e.nextElement();
-      count += 1;
-    }
-
-    names = new String[count];
-    e = request.getAttributeNames();
-    if (e == null)
-    {
-      return null;
-    }
-
-    while (e.hasMoreElements() && i < count)
-    {
-      names[i++] = (String) e.nextElement();
-    }
-    return names;
+  	return Collections.list((Enumeration<String>)request.getAttributeNames());
   }
 
   private boolean contextObject(String s, Object o)
@@ -838,43 +764,17 @@
       s.startsWith("javax.portlet.");
   }
 
-  private void logMap(String message, Map m)
-  {
-    PortletContext context = mPortletConfig.getPortletContext();
-
-    context.log(message);
-    Set keySet = m.keySet();
-    if (keySet != null)
-    {
-      Iterator keys = keySet.iterator();
-      while (keys != null && keys.hasNext())
-      {
-        String requestAttrKey = (String) keys.next();
-        Object o = m.get(requestAttrKey);
-        if (o instanceof String)
-          context.log("     Map entry: " + requestAttrKey +"   value:" + (String) o);
-        else if (o instanceof String[])
-          context.log("     Map entry: " + requestAttrKey + "   value:" + ((String[]) o)[0]);
-        else
-          context.log("     Map entry: " + requestAttrKey);
-      }
-    }
-    else
-    {
-      context.log("Map is empty");
-    }
-
-    context.log("logMap completed");
-  }
-
-  private boolean restoreBridgeRequestScopeData(FacesContext context, String scopeId)
+	@SuppressWarnings("unchecked")
+	private boolean restoreBridgeRequestScopeData(FacesContext context, String scopeId)
     throws BridgeException
   {
 
     PortletContext portletContext = mPortletConfig.getPortletContext();
-    Map m = null;
-    Map requestMap = context.getExternalContext().getRequestMap();
-
+    Map<String, Object> m;
+    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+    
+    //TODO: Since this is a private method, is it easier to ensure scope id is not null here thus replacing this with
+    //an assert
     if (scopeId == null)
     {
       return false;
@@ -891,35 +791,14 @@
         return false;
       }
 
-      m = (Map) requestScopeMap.get(scopeId);
+      m = requestScopeMap.get(scopeId);
       if (m == null)
       {
         return false;
       }
-
-      logMap("Restoring scope: " + scopeId, m);
-    }
-
-    // Restore it as the RequestMap
-    Set keySet = m.keySet();
-    if (keySet != null)
-    {
-      Iterator keys = keySet.iterator();
-      while (keys != null && keys.hasNext())
-      {
-        String requestAttrKey = (String) keys.next();
-        Object requestAttrValue = m.get(requestAttrKey);
-
-        requestMap.put(requestAttrKey, requestAttrValue);
-      }
     }
-    else
-    {
-      return false;
-    }
-    // Let's see what actually made it into the Map
-    logMap("Restored RequestMap: ", context.getExternalContext().getRequestMap());
-
+    
+    requestMap.putAll(m);
     return true;
   }
 
@@ -927,9 +806,10 @@
                                                    String key)
   {
     PortletContext portletContext = mPortletConfig.getPortletContext();
-    Map m = null;
-    Map requestMap = context.getExternalContext().getRequestMap();
+    Map<String, Object> m = null;
 
+    //TODO: Since this is a private method, is it easier to ensure scope id is not null here thus replacing this with
+    //an assert
     if (scopeId == null)
     {
       return false;
@@ -946,7 +826,7 @@
         return false;
       }
 
-      m = (Map) requestScopeMap.get(scopeId);
+      m = requestScopeMap.get(scopeId);
       if (m != null)
       {
         return m.remove(key) != null;
@@ -1048,34 +928,20 @@
     {
       // get the managedScopeMap
       LRUMap requestScopeMap = (LRUMap) portletContext.getAttribute(REQUEST_SCOPE_MAP);
-      Vector v = new Vector(10);
 
       if (requestScopeMap != null)
       {
-        Set keySet = requestScopeMap.keySet();
-        if (keySet != null)
-        {
-          Iterator keys = keySet.iterator();
-          while (keys != null && keys.hasNext())
+      	Iterator<String> iterator = requestScopeMap.keySet().iterator();
+      	while(iterator.hasNext())
+      	{
+      		String scopeId = iterator.next();
+          if (scopeId != null && scopeId.startsWith(scopePrefix))
           {
-            String scopeId = (String) keys.next();
-            if (scopeId != null && scopeId.startsWith(scopePrefix))
-            {
-              // can't remove while iterating or else get a concurrency exception
-              v.add(scopeId);
-            }
+          	iterator.remove();
           }
-        }
-
-        for (int i = 0; i < v.size(); i++)
-        {
-          String scopeId = (String) v.elementAt(i);
-          requestScopeMap.remove(scopeId);
-        }
+      	}
       }
     }
-    
-    
   }
 
   /* Implement the PhaseListener methods */
@@ -1101,7 +967,7 @@
   }
 
   private final class LRUMap
-    extends LinkedHashMap
+    extends LinkedHashMap<String, Map<String, Object>>
   {
 
     /**
@@ -1117,7 +983,7 @@
     }
 
     @Override
-    protected boolean removeEldestEntry(Map.Entry eldest)
+    protected boolean removeEldestEntry(Map.Entry<String, Map<String,Object>> eldest)
     {
       return size() > mMaxCapacity;
     }
@@ -1140,37 +1006,37 @@
      */
     private static final long serialVersionUID = 8438070672451887050L;
     // For saving and restoring FacesMessages
-    private Map mMessages = new HashMap(); // key=clientId;
+    private Map<String, List<FacesMessage>> mMessages = new HashMap<String, List<FacesMessage>>(); // key=clientId;
 
     // value=FacesMessages
 
     public void addMessage(String clientId, FacesMessage message)
     {
-      List list = (List) mMessages.get(clientId);
+      List<FacesMessage> list = mMessages.get(clientId);
       if (list == null)
       {
-        list = new ArrayList();
+        list = new ArrayList<FacesMessage>();
         mMessages.put(clientId, list);
       }
       list.add(message);
     }
 
-    public Iterator getMessages(String clientId)
+    public List<FacesMessage> getMessages(String clientId)
     {
-      List list = (List) mMessages.get(clientId);
+      List<FacesMessage> list = mMessages.get(clientId);
       if (list != null)
       {
-        return list.iterator();
+        return list;
       }
       else
       {
-        return Collections.EMPTY_LIST.iterator();
+        return Collections.emptyList();
       }
     }
 
-    public Iterator getClientIds()
+    public Set<String> getClientIds()
     {
-      return mMessages.keySet().iterator();
+      return mMessages.keySet();
     }
   }
 

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java Tue Nov 20 16:19:55 2007
@@ -19,6 +19,8 @@
 
 package org.apache.myfaces.portlet.faces.bridge.wrapper;
 
+import java.util.Map;
+
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletMode;
 import javax.portlet.PortletModeException;
@@ -164,7 +166,8 @@
    * @exception java.lang.IllegalStateException
    *              if the method is invoked after <code>sendRedirect</code> has been called.
    */
-  public void setRenderParameters(java.util.Map parameters)
+  // FIXME: When portlet API is Java 5 compliant, fix this generic issue
+  public void setRenderParameters(Map parameters)
   {
     // mResponse is a protected memeber of PortletResponseDecorator
     ((ActionResponse) mResponse).setRenderParameters(parameters);

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/BridgeRenderRequestWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/BridgeRenderRequestWrapper.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/BridgeRenderRequestWrapper.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/BridgeRenderRequestWrapper.java Tue Nov 20 16:19:55 2007
@@ -21,20 +21,19 @@
 
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
-import java.util.Set;
 
 import javax.portlet.RenderRequest;
 
 public class BridgeRenderRequestWrapper extends RenderRequestDecorator
 {
-  private Map mActionParams     = null;
-  private Map mCombinedParamMap = null;
+  private Map<String, String[]> mActionParams     = null;
+  private Map<String, String[]> mCombinedParamMap = null;
 
-  public BridgeRenderRequestWrapper(RenderRequest request, Map actionParams)
-                                                                            throws IllegalArgumentException
+  public BridgeRenderRequestWrapper(RenderRequest request, 
+                                    Map<String, String[]> actionParams)
+                                      throws IllegalArgumentException
   {
     super(request);
 
@@ -95,23 +94,9 @@
    *         <code>Enumeration</code> if the request has no parameters.
    */
   @Override
-  public Enumeration getParameterNames()
+  public Enumeration<String> getParameterNames()
   {
-    final Enumeration e = Collections.enumeration(getParameterMap().entrySet());
-    Enumeration en = new Enumeration() {
-      public boolean hasMoreElements()
-      {
-        return e.hasMoreElements();
-      }
-
-      public Object nextElement()
-      {
-        Map.Entry entry = (Map.Entry) e.nextElement();
-        return entry.getKey();
-      }
-    };
-
-    return en;
+    return Collections.enumeration(getParameterMap().keySet());
   }
 
   /**
@@ -142,7 +127,7 @@
       throw new IllegalArgumentException();
     }
 
-    return (String[]) getParameterMap().get(name);
+    return getParameterMap().get(name);
 
   }
 
@@ -159,40 +144,34 @@
    *         parameter map are of type String. The values in the parameter map are of type String
    *         array (<code>String[]</code>).
    */
+  @SuppressWarnings("unchecked")
   @Override
-  public java.util.Map getParameterMap()
+  public Map<String, String[]> getParameterMap()
   {
-    if (mActionParams != null && !mActionParams.isEmpty())
+    if (mActionParams == null || mActionParams.isEmpty())
     {
-      if (mCombinedParamMap == null)
-      {
-        mCombinedParamMap = new LinkedHashMap(getParent().getParameterMap());
+      return null;
+    }
+    
+    if (mCombinedParamMap == null)
+    {
+      mCombinedParamMap = new LinkedHashMap<String, String[]>(getParent().getParameterMap());
 
-        // now walk through the actionParams adding those that aren't
-        // already in the ParameterMap
-        Set s = mActionParams.entrySet();
-        if (s != null)
+      // now walk through the actionParams adding those that aren't
+      // already in the ParameterMap
+      for (Map.Entry<String, String[]> entry : mActionParams.entrySet())
+      {
+        String key = entry.getKey();
+        if (!mCombinedParamMap.containsKey(key))
         {
-          Iterator entries = s.iterator();
-          while (entries != null && entries.hasNext())
-          {
-            Map.Entry entry = (Map.Entry) entries.next();
-            String key = (String) entry.getKey();
-            if (!mCombinedParamMap.containsKey(key))
-            {
-              mCombinedParamMap.put(key, entry.getValue());
-            }
-          }
-          // now make this an immutable Map
-          mCombinedParamMap = Collections.unmodifiableMap(mCombinedParamMap);
+          mCombinedParamMap.put(key, entry.getValue());
         }
       }
-      return mCombinedParamMap;
-    }
-    else
-    {
-      return null;
+      
+      // now make this an immutable Map
+      mCombinedParamMap = Collections.unmodifiableMap(mCombinedParamMap);
     }
+    
+    return mCombinedParamMap;
   }
-
 }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletRequestDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletRequestDecorator.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletRequestDecorator.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletRequestDecorator.java Tue Nov 20 16:19:55 2007
@@ -20,6 +20,8 @@
 package org.apache.myfaces.portlet.faces.bridge.wrapper;
 
 import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
 
 import javax.portlet.PortalContext;
 import javax.portlet.PortletMode;
@@ -198,7 +200,8 @@
    * @exception java.lang.IllegalArgumentException
    *              if name is <code>null</code>.
    */
-  public java.util.Enumeration getProperties(String name)
+  @SuppressWarnings("unchecked")
+  public Enumeration<String> getProperties(String name)
   {
     return mRequest.getProperties(name);
   }
@@ -212,7 +215,8 @@
    * @return an <code>Enumeration</code> of all the property names sent with this request; if the
    *         request has no properties, an empty <code>Enumeration</code>.
    */
-  public java.util.Enumeration getPropertyNames()
+  @SuppressWarnings("unchecked")
+  public Enumeration<String> getPropertyNames()
   {
     return mRequest.getPropertyNames();
   }
@@ -237,7 +241,7 @@
    *         comparison) indicating the authentication scheme, a custom one, or <code>null</code>
    *         if the request was not authenticated.
    */
-  public java.lang.String getAuthType()
+  public String getAuthType()
   {
     return mRequest.getAuthType();
   }
@@ -269,7 +273,7 @@
    *         <code>null</code> if the user login is not known.
    * 
    */
-  public java.lang.String getRemoteUser()
+  public String getRemoteUser()
   {
     return mRequest.getRemoteUser();
   }
@@ -296,7 +300,7 @@
    * @return a <code>boolean</code> indicating whether the user making this request belongs to a
    *         given role; <code>false</code> if the user has not been authenticated.
    */
-  public boolean isUserInRole(java.lang.String role)
+  public boolean isUserInRole(String role)
   {
     return mRequest.isUserInRole(role);
   }
@@ -336,7 +340,8 @@
    *         attributes, or an empty <code>Enumeration</code> if the request has no attributes
    *         available to it.
    */
-  public java.util.Enumeration getAttributeNames()
+  @SuppressWarnings("unchecked")
+  public Enumeration<String> getAttributeNames()
   {
     return mRequest.getAttributeNames();
   }
@@ -385,7 +390,8 @@
    *         <code>String</code> containing the name of a request parameter; or an empty
    *         <code>Enumeration</code> if the request has no parameters.
    */
-  public Enumeration getParameterNames()
+  @SuppressWarnings("unchecked")
+  public Enumeration<String> getParameterNames()
   {
     return mRequest.getParameterNames();
   }
@@ -429,7 +435,8 @@
    *         parameter map are of type String. The values in the parameter map are of type String
    *         array (<code>String[]</code>).
    */
-  public java.util.Map getParameterMap()
+  @SuppressWarnings("unchecked")
+  public Map<String, String[]> getParameterMap()
   {
     return mRequest.getParameterMap();
   }
@@ -553,7 +560,8 @@
    * 
    * @return ordered list of MIME types for the response
    */
-  public java.util.Enumeration getResponseContentTypes()
+  @SuppressWarnings("unchecked")
+  public Enumeration<String> getResponseContentTypes()
   {
     return mRequest.getResponseContentTypes();
   }
@@ -564,7 +572,7 @@
    * 
    * @return the prefered Locale in which the portal will accept content.
    */
-  public java.util.Locale getLocale()
+  public Locale getLocale()
   {
     return mRequest.getLocale();
   }
@@ -577,7 +585,8 @@
    * @return an Enumeration of Locales, in decreasing order, in which the portal will accept content
    *         for this request
    */
-  public java.util.Enumeration getLocales()
+  @SuppressWarnings("unchecked")
+  public Enumeration<Locale> getLocales()
   {
     return mRequest.getLocales();
   }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java Tue Nov 20 16:19:55 2007
@@ -23,7 +23,6 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.FacesContextFactory;
 import javax.faces.lifecycle.Lifecycle;
-
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Tue Nov 20 16:19:55 2007
@@ -22,36 +22,42 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
-
 import java.net.MalformedURLException;
 import java.net.URL;
-
 import java.security.Principal;
-
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.Vector;
 
 import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
 import javax.faces.context.ExternalContext;
-
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.PortletResponse;
 import javax.portlet.PortletURL;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
+import javax.portlet.faces.Bridge;
+import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
+import javax.portlet.faces.BridgeUtil;
 
-import org.apache.myfaces.portlet.faces.util.map.LocalesIterator;
+import org.apache.myfaces.portlet.faces.util.QueryString;
+import org.apache.myfaces.portlet.faces.util.URLUtils;
+import org.apache.myfaces.portlet.faces.util.map.EnumerationIterator;
 import org.apache.myfaces.portlet.faces.util.map.PortletApplicationMap;
 import org.apache.myfaces.portlet.faces.util.map.PortletInitParameterMap;
 import org.apache.myfaces.portlet.faces.util.map.PortletRequestHeaderMap;
@@ -61,22 +67,6 @@
 import org.apache.myfaces.portlet.faces.util.map.PortletRequestParameterMap;
 import org.apache.myfaces.portlet.faces.util.map.PortletRequestParameterValuesMap;
 import org.apache.myfaces.portlet.faces.util.map.PortletSessionMap;
-import org.apache.myfaces.portlet.faces.util.QueryString;
-import org.apache.myfaces.portlet.faces.util.URLUtils;
-
-import java.util.Vector;
-
-import javax.faces.application.ViewHandler;
-
-import javax.faces.context.FacesContext;
-
-import javax.portlet.PortletMode;
-import javax.portlet.WindowState;
-import javax.portlet.faces.Bridge;
-
-import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
-import javax.portlet.faces.BridgeUtil;
-
 /**
  * This implementation of {@link ExternalContext} is specific to the portlet implementation.
  * 
@@ -113,19 +103,19 @@
   private PortletResponse       mOrigPortletResponse               = null;
 
   // External context maps
-  private Map                   mApplicationMap                    = null;
-  private Map                   mSessionMap                        = null;
-  private Map                   mRequestMap                        = null;
-  private Map                   mRequestParameterMap               = null;
-  private Map                   mRequestParameterValuesMap         = null;
-  private Map                   mRequestHeaderMap                  = null;
-  private Map                   mRequestHeaderValuesMap            = null;
-  private Map                   mInitParameterMap                  = null;
+  private Map<String, Object>   mApplicationMap                    = null;
+  private Map<String, Object>   mSessionMap                        = null;
+  private Map<String, Object>   mRequestMap                        = null;
+  private Map<String, String>   mRequestParameterMap               = null;
+  private Map<String, String[]> mRequestParameterValuesMap         = null;
+  private Map<String, String>   mRequestHeaderMap                  = null;
+  private Map<String, String[]> mRequestHeaderValuesMap            = null;
+  private Map<String, String>   mInitParameterMap                  = null;
 
   // maps for internal parameters (eg, those specified in query string of
   // any defaultViewId)
-  private Map                   mInternalRequestParameterMap       = Collections.EMPTY_MAP;
-  private Map                   mInternalRequestParameterValuesMap = Collections.EMPTY_MAP;
+  private Map<String, String>   mInternalRequestParameterMap       = Collections.emptyMap();
+  private Map<String, String[]> mInternalRequestParameterValuesMap = Collections.emptyMap();
 
   private PortletRequestHeaders mPortletRequestHeaders             = null;
 
@@ -133,13 +123,14 @@
   private String                mViewId                            = null;
 
   // Reverse engineered serlvet paths from mappings
-  private Vector                mFacesMappings                     = null;
+  private List<String>          mFacesMappings                     = null;
   private String                mServletPath                       = null;
   private String                mPathInfo                          = null;
 
   // Current Portlet phase
   private Bridge.PortletPhase   mPhase                             = null;
 
+  @SuppressWarnings("unchecked")
   public PortletExternalContextImpl(PortletConfig portletConfig, PortletRequest portletRequest,
                                     PortletResponse portletResponse) throws FacesException
   {
@@ -156,7 +147,7 @@
     
     // Now reverse engineer the servlet paths from the mappings 
     // So Faces thinks was a client request
-    mFacesMappings = (Vector) mPortletRequest.getAttribute(FACES_MAPPING_ATTRIBUTE);
+    mFacesMappings = (Vector<String>) mPortletRequest.getAttribute(FACES_MAPPING_ATTRIBUTE);
     mapPathsFromViewId(mViewId, mFacesMappings);
 
 
@@ -172,12 +163,11 @@
     // itself because its a per portlet setting but without the config
     // object
     // the ViewHandler has no way to get the portlet's name.
-    Bridge.BridgeRenderPolicy renderPolicy = (Bridge.BridgeRenderPolicy) mPortletContext
-                                                                                        .getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX
-                                                                                                      + mPortletConfig
-                                                                                                                      .getPortletName()
-                                                                                                      + "."
-                                                                                                      + Bridge.RENDER_POLICY);
+    Bridge.BridgeRenderPolicy renderPolicy = 
+      (Bridge.BridgeRenderPolicy) mPortletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX
+                                                               + mPortletConfig.getPortletName()
+                                                               + "."
+                                                               + Bridge.RENDER_POLICY);
     if (renderPolicy != null)
     {
       mPortletRequest.setAttribute(RENDER_POLICY_ATTRIBUTE, renderPolicy);
@@ -287,7 +277,7 @@
       // Add extra parameters so they don't get lost
       if (queryStr != null)
       {
-        Enumeration list = queryStr.getParameterNames();
+        Enumeration<String> list = queryStr.getParameterNames();
         while (list.hasMoreElements())
         {
           String param = list.nextElement().toString();
@@ -346,10 +336,10 @@
       // set other request params (if any) into navigational states
       if (queryStr != null)
       {
-        Enumeration list = queryStr.getParameterNames();
+        Enumeration<String> list = queryStr.getParameterNames();
         while (list.hasMoreElements())
         {
-          String param = list.nextElement().toString();
+          String param = list.nextElement();
           if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
           {
             try 
@@ -358,6 +348,13 @@
             }
             catch (Exception e)
             {
+            	//TODO: Ignoring is probably dangerous here as it means that we are
+            	//      EITHER using exceptions for flow control (which is extreemly
+            	//      inefficient) or we should log a message saying what the issue
+            	//      is.  According to the Javadocs an exception is thrown here if the
+            	//      portlet mode is not allowed or if sendRedirect has already been
+            	//      called.  In either case we should log an information type message
+            	//      here.
               ; // do nothing -- just ignore
             }
           }
@@ -506,7 +503,7 @@
   }
 
   @Override
-  public Map getApplicationMap()
+  public Map<String, Object> getApplicationMap()
   {
     if (mApplicationMap == null)
     {
@@ -516,7 +513,7 @@
   }
 
   @Override
-  public Map getSessionMap()
+  public Map<String, Object> getSessionMap()
   {
     if (mSessionMap == null)
     {
@@ -526,7 +523,7 @@
   }
 
   @Override
-  public Map getRequestMap()
+  public Map<String, Object> getRequestMap()
   {
     if (mRequestMap == null)
     {
@@ -536,19 +533,17 @@
   }
 
   @Override
-  public Map getRequestParameterMap()
+  public Map<String, String> getRequestParameterMap()
   {
     if (mRequestParameterMap == null)
     {
-      mRequestParameterMap = Collections
-                                        .unmodifiableMap(new PortletRequestParameterMap(
-                                                                                        mPortletRequest,
-                                                                                        mInternalRequestParameterMap));
+      mRequestParameterMap = Collections.unmodifiableMap(new PortletRequestParameterMap(                                                                                        mPortletRequest,
+                                                                                       mInternalRequestParameterMap));
     }
     return mRequestParameterMap;
   }
 
-  public Map getRequestParameterValuesMap()
+  public Map<String, String[]> getRequestParameterValuesMap()
   {
     if (mRequestParameterValuesMap == null)
     {
@@ -560,32 +555,13 @@
     return mRequestParameterValuesMap;
   }
 
-  public Iterator getRequestParameterNames()
+  public Iterator<String> getRequestParameterNames()
   {
-    Map requestParameters = getRequestParameterMap();
-    final Iterator i = requestParameters.entrySet().iterator();
-    Iterator it = new Iterator() {
-      public boolean hasNext()
-      {
-        return i.hasNext();
-      }
-
-      public Object next()
-      {
-        Map.Entry entry = (Map.Entry) i.next();
-        return entry.getKey();
-      }
-
-      public void remove()
-      {
-        throw new UnsupportedOperationException();
-      }
-    };
-
-    return it;
+  	//Map is unmodifiable, so the iterator will be as well
+  	return getRequestParameterMap().keySet().iterator();
   }
 
-  public Map getRequestHeaderMap()
+  public Map<String, String> getRequestHeaderMap()
   {
     if (mRequestHeaderMap == null)
     {
@@ -599,7 +575,8 @@
     return mRequestHeaderMap;
   }
 
-  public Map getRequestHeaderValuesMap()
+  @Override
+  public Map<String, String[]> getRequestHeaderValuesMap()
   {
     if (mRequestHeaderValuesMap == null)
     {
@@ -613,32 +590,39 @@
     return mRequestHeaderValuesMap;
   }
 
-  public Map getRequestCookieMap()
+  @Override
+  public Map<String, Object> getRequestCookieMap()
   {
-    return Collections.unmodifiableMap(Collections.EMPTY_MAP);
+    Map<String, Object> dummy = Collections.emptyMap();
+    return dummy;
   }
 
+  @Override
   public Locale getRequestLocale()
   {
     return mPortletRequest.getLocale();
   }
 
+  @Override
   public String getRequestPathInfo()
   {
     return mPathInfo;
   }
 
+  @Override
   public String getRequestContextPath()
   {
     return mPortletRequest.getContextPath();
   }
 
+  @Override
   public String getInitParameter(String s)
   {
     return mPortletContext.getInitParameter(s);
   }
 
-  public Map getInitParameterMap()
+  @Override
+  public Map<String, String> getInitParameterMap()
   {
     if (mInitParameterMap == null)
     {
@@ -647,7 +631,8 @@
     return mInitParameterMap;
   }
 
-  public Set getResourcePaths(String s)
+  @SuppressWarnings("unchecked")
+	public Set<String> getResourcePaths(String s)
   {
     return mPortletContext.getResourcePaths(s);
   }
@@ -669,46 +654,57 @@
     }
   }
 
+  @Override
   public String getRequestServletPath()
   {
     return mServletPath;
   }
 
+  @Override
   public String getAuthType()
   {
     return mPortletRequest.getAuthType();
   }
 
+  @Override
   public String getRemoteUser()
   {
     return mPortletRequest.getRemoteUser();
   }
 
+  @Override
   public boolean isUserInRole(String role)
   {
     return mPortletRequest.isUserInRole(role);
   }
 
+  @Override
   public Principal getUserPrincipal()
   {
     return mPortletRequest.getUserPrincipal();
   }
 
+  @Override
   public void log(String message)
   {
     mPortletContext.log(message);
   }
 
+  @Override
   public void log(String message, Throwable t)
   {
     mPortletContext.log(message, t);
   }
 
-  public Iterator getRequestLocales()
+  @SuppressWarnings("unchecked")
+  @Override
+  public Iterator<Locale> getRequestLocales()
   {
-    return new LocalesIterator(mPortletRequest.getLocales());
+  	//TODO: Cache this value...
+    return new EnumerationIterator<Locale>(mPortletRequest.getLocales());
   }
 
+  @Override
   public URL getResource(String s) throws MalformedURLException
   {
     return mPortletContext.getResource(s);
@@ -730,6 +726,7 @@
    * 
    * @since 1.2
    */
+  @Override
   public void setRequest(Object request)
   {
     mPortletRequest = (PortletRequest) request;
@@ -775,6 +772,7 @@
    * @since 1.2
    * 
    */
+  @Override
   public void setRequestCharacterEncoding(String encoding) throws UnsupportedEncodingException,
                                                           IllegalStateException
   {
@@ -811,6 +809,7 @@
    * @since 1.2
    * 
    */
+  @Override
   public String getRequestCharacterEncoding()
   {
     if (mPhase == Bridge.PortletPhase.RenderPhase)
@@ -846,6 +845,7 @@
    * 
    * @since 1.2
    */
+  @Override
   public String getRequestContentType()
   {
     if (mPhase == Bridge.PortletPhase.RenderPhase)
@@ -882,6 +882,7 @@
    * 
    * @since 1.2
    */
+  @Override
   public String getResponseCharacterEncoding()
   {
     if (mPhase == Bridge.PortletPhase.ActionPhase)
@@ -917,6 +918,7 @@
    * 
    * @since 1.2
    */
+  @Override
   public String getResponseContentType()
   {
     if (mPhase == Bridge.PortletPhase.ActionPhase)
@@ -942,6 +944,7 @@
    * 
    * @since 1.2
    */
+  @Override
   public void setResponse(Object response)
   {
     mPortletResponse = (PortletResponse) response;
@@ -972,6 +975,7 @@
    * @since 1.2
    * 
    */
+  @Override
   public void setResponseCharacterEncoding(String encoding)
   {
     // JSR 168 has no corresponding API.
@@ -984,7 +988,7 @@
    */
   private String getViewId() throws BridgeDefaultViewNotSpecifiedException
   {
-    String viewId = (String) mPortletRequest.getParameter(ACTION_ID_PARAMETER_NAME);
+    String viewId = mPortletRequest.getParameter(ACTION_ID_PARAMETER_NAME);
 
     log("PortletExternalContextImpl.getViewId: found action_id = " + viewId);
 
@@ -1014,16 +1018,16 @@
       // they are needed/called by the client
       queryStr = new QueryString(viewId.substring(queryStart + 1), "UTF8");
 
-      mInternalRequestParameterMap = new HashMap(5);
-      mInternalRequestParameterValuesMap = new HashMap(5);
+      // TODO: Constants
+      mInternalRequestParameterMap = new HashMap<String, String>(5);
+      mInternalRequestParameterValuesMap = new HashMap<String, String[]>(5);
 
-      Enumeration list = queryStr.getParameterNames();
+      Enumeration<String> list = queryStr.getParameterNames();
       while (list.hasMoreElements())
       {
-        String param = (String) list.nextElement().toString();
+        String param = list.nextElement();
         mInternalRequestParameterMap.put(param, queryStr.getParameter(param));
-        mInternalRequestParameterValuesMap
-                                          .put(param, new String[] { queryStr.getParameter(param) });
+        mInternalRequestParameterValuesMap.put(param, new String[]{queryStr.getParameter(param)});
       }
 
       viewId = viewId.substring(0, queryStart);
@@ -1033,7 +1037,7 @@
     return viewId;
   }
   
-  private void mapPathsFromViewId(String viewId, Vector mappings)
+  private void mapPathsFromViewId(String viewId, List<String> mappings)
   {
     if (viewId == null || mappings == null)
     {
@@ -1046,7 +1050,7 @@
     
     // The only thing that matters is we use a configured mapping
     // So just use the first one
-    String mapping = (String) mappings.elementAt(0);
+    String mapping = mappings.get(0);
     if (mapping.startsWith("*"))
     {
       // we are using suffix mapping
@@ -1094,7 +1098,7 @@
 
     if (extLoc != -1 && extLoc > viewId.lastIndexOf('/'))
     {
-      StringBuffer sb = new StringBuffer("*");
+      StringBuilder sb = new StringBuilder("*");
       sb.append(viewId.substring(extLoc));
       return sb.toString();
     }
@@ -1143,7 +1147,7 @@
     return viewId;
   }
 
-  private boolean isSuffixedMapped(String url, Vector mappings)
+  private boolean isSuffixedMapped(String url, List<String> mappings)
   {
     // see if the viewId terminates with an extension
     // if non-null value contains *.XXX where XXX is the extension
@@ -1151,7 +1155,7 @@
     return ext != null && mappings.contains(ext);
   }
 
-  private String viewIdFromSuffixMapping(String url, Vector mappings, String ctxDefault)
+  private String viewIdFromSuffixMapping(String url, List<String> mappings, String ctxDefault)
   {
     // replace extension with the DEFAULT_SUFFIX
     if (ctxDefault == null)
@@ -1175,12 +1179,12 @@
     return url;
   }
 
-  private boolean isPrefixedMapped(String url, Vector mappings)
+  private boolean isPrefixedMapped(String url, List<String> mappings)
   {
     for (int i = 0; i < mappings.size(); i++)
     {
       String prefix = null;
-      String mapping = (String) mappings.elementAt(i);
+      String mapping = mappings.get(i);
       if (mapping.startsWith("/"))
       {
         int j = mapping.lastIndexOf("/*");
@@ -1197,12 +1201,12 @@
     return false;
   }
 
-  private String viewIdFromPrefixMapping(String url, Vector mappings)
+  private String viewIdFromPrefixMapping(String url, List<String> mappings)
   {
     for (int i = 0; i < mappings.size(); i++)
     {
       String prefix = null;
-      String mapping = (String) mappings.elementAt(i);
+      String mapping = mappings.get(i);
       if (mapping.startsWith("/"))
       {
         int j = mapping.lastIndexOf("/*");
@@ -1216,37 +1220,6 @@
         return url.substring(prefix.length());
       }
     }
-    return null;
-  }
-
-  private String viewIdWithPrefixMapping(String viewId, Vector mappings)
-  {
-    // use first prefix mapping found
-    for (int i = 0; i < mappings.size(); i++)
-    {
-      String prefix = null;
-      String mapping = (String) mappings.elementAt(i);
-      if (mapping.startsWith("/"))
-      {
-        int j = mapping.lastIndexOf("/*");
-        if (j != -1)
-        {
-          prefix = mapping.substring(0, j);
-        }
-      }
-      if (prefix != null)
-      {
-        if (viewId.startsWith("/"))
-        {
-          return prefix + viewId;
-        }
-        else
-        {
-          return prefix + "/" + viewId;
-        }
-      }
-    }
-
     return null;
   }
 

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java Tue Nov 20 16:19:55 2007
@@ -20,19 +20,19 @@
 package org.apache.myfaces.portlet.faces.context;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import javax.el.ELContext;
-
+import javax.faces.FacesException;
 import javax.faces.FactoryFinder;
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIViewRoot;
-import javax.faces.FacesException;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseStream;
@@ -40,9 +40,7 @@
 import javax.faces.lifecycle.Lifecycle;
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
-
 import javax.portlet.PortletResponse;
-
 import javax.portlet.faces.Bridge;
 import javax.portlet.faces.component.PortletNamingContainer;
 
@@ -61,9 +59,9 @@
   private UIViewRoot            mViewRoot;
   private boolean               mRenderResponse   = false;
   private boolean               mResponseComplete = false;
-  private Map                   mMessages         = new HashMap();
   private FacesMessage.Severity mMaximumSeverity  = FacesMessage.SEVERITY_INFO;
   private ELContext             mElContext        = null;
+  private Map<String, List<FacesMessage>> mMessages = new HashMap<String, List<FacesMessage>>();
 
   public PortletFacesContextImpl(ExternalContext externalContext, Lifecycle lifecycle)
                                                                                       throws FacesException
@@ -158,15 +156,14 @@
   }
 
   @Override
-  public Iterator getMessages()
+  public Iterator<FacesMessage> getMessages()
   {
-    List results = new ArrayList();
-    Iterator clientIds = mMessages.keySet().iterator();
-    while (clientIds.hasNext())
+    List<FacesMessage> results = new ArrayList<FacesMessage>();
+    for (List<FacesMessage> messages : mMessages.values())
     {
-      String clientId = (String) clientIds.next();
-      results.addAll((List) mMessages.get(clientId));
+      results.addAll(messages);
     }
+    
     return results.iterator();
   }
 
@@ -177,19 +174,20 @@
   }
 
   @Override
-  public Iterator getClientIdsWithMessages()
+  public Iterator<String> getClientIdsWithMessages()
   {
     return mMessages.keySet().iterator();
   }
 
   @Override
-  public Iterator getMessages(String clientId)
+  public Iterator<FacesMessage> getMessages(String clientId)
   {
-    List list = (List) mMessages.get(clientId);
+    List<FacesMessage> list = mMessages.get(clientId);
     if (list == null)
     {
-      list = new ArrayList();
+      list = Collections.emptyList();
     }
+    
     return list.iterator();
   }
 
@@ -294,14 +292,18 @@
     {
       throw new NullPointerException();
     }
-    List list = (List) mMessages.get(clientId);
+    
+    List<FacesMessage> list = mMessages.get(clientId);
     if (list == null)
     {
-      list = new ArrayList();
+      list = new ArrayList<FacesMessage>(2); // default capacity of 10 is an overkill
       mMessages.put(clientId, list);
     }
     list.add(message);
 
+    // -= Simon Lessard =-
+    // FIXME: This is wrong, FacesMessage.setSeverity can be called later making
+    //        this cached result potentially incoherent.
     FacesMessage.Severity severity = message.getSeverity();
     if (severity != null && severity.compareTo(mMaximumSeverity) > 0)
     {

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java Tue Nov 20 16:19:55 2007
@@ -19,9 +19,9 @@
 package org.apache.myfaces.portlet.faces.el;
 
 import java.beans.FeatureDescriptor;
-
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -32,13 +32,10 @@
 import javax.el.ELResolver;
 import javax.el.PropertyNotFoundException;
 import javax.el.PropertyNotWritableException;
-
-import javax.faces.context.FacesContext;
 import javax.faces.context.ExternalContext;
-
+import javax.faces.context.FacesContext;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletRequest;
-
 import javax.portlet.faces.Bridge;
 import javax.portlet.faces.BridgeUtil;
 
@@ -227,25 +224,32 @@
     return fd;
   }
 
-  private Map getPreferencesValueMap(ExternalContext extCtx)
+  @SuppressWarnings("unchecked")
+  private Map<String, String> getPreferencesValueMap(ExternalContext extCtx)
   {
-    PortletRequest portletRequest = (PortletRequest) extCtx.getRequest();
-    Enumeration e = portletRequest.getPreferences().getNames();
-    Map m = null;
+    Map<String, String> m;
 
-    while (e.hasMoreElements())
+    PortletRequest portletRequest = (PortletRequest) extCtx.getRequest();
+    Enumeration<String> e = portletRequest.getPreferences().getNames();
+    
+    if (e.hasMoreElements())
     {
-      if (m == null)
-      {
-        m = new HashMap();
-      }
-      String name = (String) e.nextElement();
-      String value = portletRequest.getPreferences().getValue(name, null);
-      if (value != null)
+      m = new HashMap<String, String>();
+      while (e.hasMoreElements())
       {
-        m.put(name, value);
+        String name = e.nextElement();
+        String value = portletRequest.getPreferences().getValue(name, null);
+        if (value != null)
+        {
+          m.put(name, value);
+        }
       }
     }
+    else
+    {
+      m = Collections.emptyMap();
+    }
+    
     return m;
   }
 

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/HTTPUtils.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/HTTPUtils.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/HTTPUtils.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/HTTPUtils.java Tue Nov 20 16:19:55 2007
@@ -21,10 +21,8 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-
 import java.util.Locale;
 import java.util.TimeZone;
 
@@ -173,7 +171,7 @@
                                          + " host: " + host + " port: " + port + " path: " + path);
     }
 
-    SimpleStringBuffer url = new SimpleStringBuffer(200);
+    StringBuilder url = new StringBuilder(200);
 
     url.append(scheme).append("://").append(host);
 
@@ -209,7 +207,7 @@
     // Create a buffer that is roughly 1.5 times bigger than the value to
     // account for possible expansion of the resulting encoded string
     int len = value.length();
-    SimpleStringBuffer out = new SimpleStringBuffer(len * 3 / 2);
+    StringBuilder out = new StringBuilder(len * 3 / 2);
 
     for (int charIndex = 0; charIndex < len; charIndex++)
     {
@@ -538,7 +536,7 @@
     String variant = locale.getVariant();
     if (country.length() > 0 || variant.length() > 0)
     {
-      SimpleStringBuffer buff = new SimpleStringBuffer(20).append(language).append('-')
+      StringBuilder buff = new StringBuilder(20).append(language).append('-')
                                                           .append(country);
       if (variant.length() > 0)
       {
@@ -698,7 +696,7 @@
     int i = 0;
     int bytesToWrite = bytes.length;
 
-    SimpleStringBuffer buff = new SimpleStringBuffer(bytes.length * 4 / 3);
+    StringBuilder buff = new StringBuilder(bytes.length * 4 / 3);
 
     while (bytesToWrite >= 3)
     {

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java Tue Nov 20 16:19:55 2007
@@ -20,7 +20,6 @@
 package org.apache.myfaces.portlet.faces.util;
 
 import java.io.UnsupportedEncodingException;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -36,9 +35,9 @@
 {
   private String mQueryString;
   private String mCharacterEncoding;
-  private Map    mParameterMap;
-  private List   mParameterList;
-  private List   mParameterNames;
+  private Map<String, List<Parameter>> mParameterMap;
+  private List<Parameter> mParameterList;
+  private List<String> mParameterNames;
 
   /**
    * Construct a <code>QueryString</code> from a pre-encoded string.
@@ -58,7 +57,7 @@
     mCharacterEncoding = source.mCharacterEncoding;
     if (source.mParameterList != null)
     {
-      mParameterList = new ArrayList(source.mParameterList);
+      mParameterList = new ArrayList<Parameter>(source.mParameterList);
     }
   }
 
@@ -85,14 +84,14 @@
   /**
    * Constructs a query string from a list of PRE-ENCODED name-value pairs
    */
-  public QueryString(List params, String characterEncoding)
+  public QueryString(List<String[]> params, String characterEncoding)
   {
     this(characterEncoding);
 
-    Iterator pairs = params.iterator();
-    while (pairs.hasNext())
+    for (String[] pair : params)
     {
-      String[] pair = (String[]) pairs.next();
+      // -= Simon Lessard =-
+      // FIXME: Add if (pair == null) check
       addParameter(pair[0], pair[1], true);
     }
   }
@@ -106,7 +105,7 @@
     // Use appendTo to concatenate the parameters together
     if (mQueryString == null)
     {
-      appendTo(new SimpleStringBuffer(200));
+      appendTo(new StringBuilder(200));
     }
     return mQueryString;
   }
@@ -117,42 +116,44 @@
    * @param buff
    *          the buffer to append to
    */
-  public void appendTo(SimpleStringBuffer buff)
+  public void appendTo(StringBuilder buff)
   {
-    // If we don't have a cached query string yet, generate it
     if (mQueryString == null)
     {
-      // Remember the start position in the buffer, so that we can also
-      // cache the
-      // concatenated string in mQueryString
-      int startPos = buff.length();
-      Iterator i;
-      if (mParameterList != null && (i = mParameterList.iterator()).hasNext())
+      // If we don't have a cached query string yet, generate it
+      if (mParameterList == null || mParameterList.isEmpty())
+      {
+        // If we don't have any parameters at all, cache the empty string
+        mQueryString = "";
+      }
+      else
       {
-        Parameter param = (Parameter) i.next();
+        // Remember the start position in the buffer, so that we can also
+        // cache the concatenated string in mQueryString
+        int startPos = buff.length();
+        
+        Iterator<Parameter> iter = mParameterList.iterator();
+        Parameter param = iter.next();
         buff.append(param.getEncodedName()).append('=').append(param.getEncodedValue());
-        while (i.hasNext())
+        
+        while (iter.hasNext())
         {
-          param = (Parameter) i.next();
+          param = iter.next();
           buff.append('&').append(param.getEncodedName()).append('=')
-              .append(param.getEncodedValue());
+            .append(param.getEncodedValue());
         }
+          
         mQueryString = buff.substring(startPos);
       }
-      // If we don't have any parameters at all, cache the empty string
-      else
-      {
-        mQueryString = "";
-      }
     }
-    // If we have a cached query string, reuse it
     else
     {
+      // If we have a cached query string, reuse it
       buff.append(mQueryString);
     }
   }
 
-  public Enumeration getParameterNames()
+  public Enumeration<String> getParameterNames()
   {
     initParameterMap();
     return Collections.enumeration(mParameterNames);
@@ -161,26 +162,26 @@
   public String getParameter(String name)
   {
     initParameterMap();
-    List values = (List) mParameterMap.get(name);
-    return values == null ? null : ((Parameter) values.get(0)).getValue();
+    List<Parameter> values = mParameterMap.get(name);
+    return values == null ? null : values.get(0).getValue();
   }
 
-  public Enumeration getParameterValues(String name)
+  public Enumeration<Object> getParameterValues(String name)
   {
     initParameterMap();
-    List params = (List) mParameterMap.get(name);
-    if (params == null)
+    List<Parameter> params = mParameterMap.get(name);
+    if (params == null || params.isEmpty())
     {
-      return Collections.enumeration(Collections.EMPTY_LIST);
+      List<Object> temp = Collections.emptyList();
+      return Collections.enumeration(temp);
     }
-    List values = new ArrayList(params.size());
-    Iterator i = params.iterator();
-    Parameter param;
-    while (i.hasNext())
+    
+    List<Object> values = new ArrayList<Object>(params.size());
+    for (Parameter param : params)
     {
-      param = (Parameter) i.next();
       values.add(param.getValue());
     }
+    
     return Collections.enumeration(values);
   }
 
@@ -208,15 +209,15 @@
     if (mParameterMap != null)
     {
       String decodedName = param.getName();
-      List values = (List) mParameterMap.get(decodedName);
+      List<Parameter> values = mParameterMap.get(decodedName);
       if (values == null)
       {
-        values = new ArrayList(4);
-        mParameterMap.put(decodedName, values);
-        // Only add UNIQUE parameter names (preserving order)
-        mParameterNames.add(decodedName);
+        createParameterList(param);
+      }
+      else
+      {
+        values.add(param);
       }
-      values.add(param);
     }
   }
 
@@ -240,13 +241,10 @@
     // Update the map
     Parameter param = new Parameter(name, value, isEncoded);
     String decodedName = param.getName();
-    List values = (List) mParameterMap.get(decodedName);
+    List<Parameter> values = mParameterMap.get(decodedName);
     if (values == null)
     {
-      values = new ArrayList(4);
-      mParameterMap.put(decodedName, values);
-      // Only add UNIQUE parameter names (preserving order)
-      mParameterNames.add(decodedName);
+      createParameterList(param);
       mParameterList.add(param);
     }
     else
@@ -263,8 +261,9 @@
       {
         mParameterList.remove(j);
       }
+      
+      values.add(param);
     }
-    values.add(param);
   }
 
   public String removeParameter(String name)
@@ -284,37 +283,54 @@
     Parameter templateParam = new Parameter(name, "", isEncoded);
 
     // Update the parameter list
-    Iterator i = mParameterList.iterator();
-    Parameter param = null, firstParam = null;
+    Iterator<Parameter> i = mParameterList.iterator();
+    Parameter firstParam = null;
     while (i.hasNext())
     {
-      param = (Parameter) i.next();
+      Parameter param = i.next();
       // Compare the parameter with our template (only the template name
-      // will
-      // be encoded / decoded if necessary)
+      // will be encoded / decoded if necessary)
       if (templateParam.equals(param))
       {
         if (firstParam == null)
         {
           firstParam = param;
         }
+        
         i.remove();
       }
     }
 
+    if (firstParam == null)
+    {
+      return null;
+    }
+
     // Update the map, if it is initialized and we found a parameter
-    if (mParameterMap != null && firstParam != null)
+    if (mParameterMap != null)
     {
       String decodedName = templateParam.getName();
-      List values = (List) mParameterMap.remove(decodedName);
+      List<Parameter> values = mParameterMap.remove(decodedName);
       if (values != null)
       {
         mParameterNames.remove(decodedName);
       }
     }
 
-    return firstParam == null ? null : isEncoded ? firstParam.getEncodedValue()
-                                                : firstParam.getValue();
+    return isEncoded ? firstParam.getEncodedValue() : firstParam.getValue();
+  }
+  
+  private void createParameterList(Parameter param)
+  {
+    String decodedName = param.getName();
+    
+    List<Parameter> values = new ArrayList<Parameter>(4);
+    mParameterMap.put(decodedName, values);
+    
+    // Only add UNIQUE parameter names (preserving order)
+    mParameterNames.add(decodedName);
+    
+    values.add(param);
   }
 
   private void initParameterMap()
@@ -323,29 +339,28 @@
     {
       initParameterList();
 
-      mParameterMap = new HashMap(30);
-      mParameterNames = new ArrayList(30);
-      if (mParameterList.size() == 0)
+      // TODO: Constants
+      mParameterMap = new HashMap<String, List<Parameter>>(30);
+      mParameterNames = new ArrayList<String>(30);
+      if (mParameterList.isEmpty())
       {
         return;
       }
+      
       String decodedName;
-      Parameter param;
-      List values;
-      Iterator i = mParameterList.iterator();
-      while (i.hasNext())
+      
+      for (Parameter param : mParameterList)
       {
-        param = (Parameter) i.next();
         decodedName = param.getName();
-        values = (List) mParameterMap.get(decodedName);
+        List<Parameter> values = mParameterMap.get(decodedName);
         if (values == null)
         {
-          values = new ArrayList(4);
-          mParameterMap.put(decodedName, values);
-          // Only add UNIQUE parameter names (preserving order)
-          mParameterNames.add(decodedName);
+          createParameterList(param);
+        }
+        else
+        {
+          values.add(param);
         }
-        values.add(param);
       }
     }
   }
@@ -354,7 +369,8 @@
   {
     if (mParameterList == null)
     {
-      mParameterList = new ArrayList(30);
+      // TODO: Constant
+      mParameterList = new ArrayList<Parameter>(30);
       int length;
       if (mQueryString == null || (length = mQueryString.length()) == 0)
       {
@@ -493,7 +509,7 @@
   private void handleUnsupportedEncoding()
   {
     throw new IllegalArgumentException(
-                                       new SimpleStringBuffer(100)
+                                       new StringBuilder(100)
                                                                   .append(
                                                                           "Unrecognized character encoding \"")
                                                                   .append(mCharacterEncoding)

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/TextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/TextUtils.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/TextUtils.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/TextUtils.java Tue Nov 20 16:19:55 2007
@@ -79,7 +79,7 @@
     }
     int origLen = orig.length();
     int startPos = 0;
-    SimpleStringBuffer result = new SimpleStringBuffer(origLen + 100);
+    StringBuilder result = new StringBuilder(origLen + 100);
 
     // Use 'do' loop, because we know the search string occurs at least once
     do

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java Tue Nov 20 16:19:55 2007
@@ -25,7 +25,7 @@
   /**
    * Borrowed from package oracle.adfinternal.view.faces.share.url.EncoderUtils
    */
-  public static String appendURLArguments(StringBuffer buffer, String baseURL,
+  public static String appendURLArguments(StringBuilder buffer, String baseURL,
                                           String[] keysAndValues)
   {
 
@@ -86,7 +86,7 @@
       }
     }
 
-    StringBuffer buffer = new StringBuffer(bufferLength);
+    StringBuilder buffer = new StringBuilder(bufferLength);
 
     return appendURLArguments(buffer, baseURL, keysAndValues);
   }
@@ -116,7 +116,7 @@
       }
     }
 
-    StringBuffer sb = new StringBuffer(currentPath);
+    StringBuilder sb = new StringBuilder(currentPath);
     if (currentPath.endsWith("/"))
     {
       sb = sb.deleteCharAt(currentPath.length() - 1);

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/WebConfigurationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/WebConfigurationProcessor.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/WebConfigurationProcessor.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/WebConfigurationProcessor.java Tue Nov 20 16:19:55 2007
@@ -20,11 +20,10 @@
 package org.apache.myfaces.portlet.faces.util.config;
 
 import java.io.StringReader;
-
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.portlet.PortletContext;
-
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
@@ -33,12 +32,13 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
+//TODO: This is probably better under the Bridge package as a package private utility
+//TODO: This is probably better as a static utility class since it's never kept around.
 public class WebConfigurationProcessor
 {
 
   private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
-
-  private Vector              mMappings    = null;
+  private List<String> mMappings = null;
 
   /**
    * <p>
@@ -52,19 +52,15 @@
    */
   public WebConfigurationProcessor(PortletContext context)
   {
-
     if (context != null)
     {
       scanForFacesMappings(context);
     }
-
   } // END WebXmlProcessor
 
-  public Vector getFacesMappings()
+  public List<String> getFacesMappings()
   {
-
     return mMappings;
-
   } // END getFacesMappings
 
   /**
@@ -138,7 +134,7 @@
     private String              mClass                   = null;
 
     private String              mFacesServletName        = null;
-    private StringBuffer        mContent;
+    private StringBuilder       mContent;
 
     @Override
     public InputSource resolveEntity(String publicId, String systemId) throws SAXException
@@ -187,7 +183,7 @@
       }
       if (parseContent)
       {
-        mContent = new StringBuffer();
+        mContent = new StringBuilder();
       }
 
     } // END startElement
@@ -224,7 +220,7 @@
         {
           if (mMappings == null)
           {
-            mMappings = new Vector();
+            mMappings = new ArrayList<String>();
           }
           mMappings.add(mContent.toString().trim());
         }