You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2011/07/26 20:27:34 UTC

svn commit: r1151193 - in /myfaces/portlet-bridge/core/branches/refactored_3.0.x: controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/ controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/config/ controller-api/src/main...

Author: mfreedman
Date: Tue Jul 26 18:27:32 2011
New Revision: 1151193

URL: http://svn.apache.org/viewvc?rev=1151193&view=rev
Log:
Minor updates

Added:
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScopeUtil.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/config/
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/context/
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/controller/
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/event/
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/logger/
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/
Modified:
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeConfig.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeContext.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScope.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/context/BridgeContextImpl.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/controller/BridgeControllerImpl.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeImpl.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeRepository.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
    myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextFactoryImpl.java

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeConfig.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeConfig.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeConfig.java Tue Jul 26 18:27:32 2011
@@ -228,7 +228,7 @@ public interface BridgeConfig
    * (non-recusive) are excluded.
    * 
    * @return <code>List</code> of request attribute names that are to be
-   * excluded from the bridge's managed request scope.
+   * excluded from the bridge's managed request scope.  If no entries an empty List is returned.
    */
   public List<String> getExcludedRequestAttributes();
   

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeContext.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeContext.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeContext.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeContext.java Tue Jul 26 18:27:32 2011
@@ -452,50 +452,89 @@ public abstract class BridgeContext 
     // ---------------------------------------------------------- Static Methods
 
 
-    /**
-     * <p>The <code>ThreadLocal</code> variable used to record the
-     * {@link FacesContext} instance for each processing thread.</p>
-     */
-    private static ThreadLocal<BridgeContext> sInstance = new ThreadLocal<BridgeContext>() {
-            protected BridgeContext initialValue() { return (null); }
-        };
-
-
-    /**
-     * <p class="changed_modified_2_0">Return the {@link FacesContext}
-     * instance for the request that is being processed by the current
-     * thread.  If called during application initialization or shutdown,
-     * any method documented as "valid to call this method during
-     * application startup or shutdown" must be supported during
-     * application startup or shutdown time.  The result of calling a
-     * method during application startup or shutdown time that does not
-     * have this designation is undefined.</p>
-     */
-    public static BridgeContext getCurrentInstance() {
+  /**
+   * <p>The <code>ThreadLocal</code> variable used to record the
+   * {@link FacesContext} instance for each processing thread.</p>
+   */
+  private static ThreadLocal<BridgeContext> sInstance =
+    new ThreadLocal<BridgeContext>()
+  {
+    protected BridgeContext initialValue()
+    {
+      return (null);
+    }
+  };
 
-        return (sInstance.get());
 
+  /**
+   * Return the {@link BridgeContext}
+   * instance for the request that is being processed by the current
+   * thread.
+   */
+  public static BridgeContext getCurrentInstance()
+  {
+
+    return (sInstance.get());
+
+  }
+  
+  /**
+   * <p>Set the {@link FacesContext} instance for the request that is
+   * being processed by the current thread.</p>
+   *
+   * @param context The {@link FacesContext} instance for the current
+   * thread, or <code>null</code> if this thread no longer has a
+   * <code>FacesContext</code> instance.
+   *
+   */
+  protected static void setCurrentInstance(BridgeContext context)
+  {
+
+    if (context == null)
+    {
+      sInstance.remove();
+    }
+    else
+    {
+      sInstance.set(context);
     }
 
+  }
+
+  /**
+   * Convenience methods for classes that need to log without having or knowing 
+   * whether they are currently executing in a BridgeContext
+   * 
+   * @param s
+   * @param t
+   */
+  public static void log(String s, Throwable t)
+  {
+    BridgeContext bCtx = getCurrentInstance();
+    if (bCtx != null)
+    {
+      bCtx.getBridgeConfig().getLogger().log(s, t);
+    }
+  }
 
-    /**
-     * <p>Set the {@link FacesContext} instance for the request that is
-     * being processed by the current thread.</p>
-     *
-     * @param context The {@link FacesContext} instance for the current
-     * thread, or <code>null</code> if this thread no longer has a
-     * <code>FacesContext</code> instance.
-     *
-     */
-    protected static void setCurrentInstance(BridgeContext context) {
-
-        if (context == null) {
-            sInstance.remove();
-        } else {
-            sInstance.set(context);
-        }
 
+  /**
+   * Convenience methods for classes that need to log without having or knowing 
+   * whether they are currently executing in a BridgeContext
+   * 
+   * @param s
+   */
+  public static void log(String s)
+  {
+    BridgeContext bCtx = getCurrentInstance();
+    if (bCtx != null)
+    {
+      bCtx.getBridgeConfig().getLogger().log(s);
     }
+  }
+
+
+
 
  
 

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScope.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScope.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScope.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScope.java Tue Jul 26 18:27:32 2011
@@ -98,12 +98,5 @@ public interface BridgeRequestScope exte
    */
  public boolean isExcluded(String key, Object value);
  
- /**
-  * Note:  The RequestScope must override put() and putAll().  In the case of put() and putIfAbsent()
-  * the attribute is only put if its not excluded. If it is excluded null is returned.  In the case of putAll(), only
-  * those attributes that aren't excluded are put.  
-  */
- 
-public void release();
   
 }
\ No newline at end of file

Added: myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScopeUtil.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScopeUtil.java?rev=1151193&view=auto
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScopeUtil.java (added)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/controller-api/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeRequestScopeUtil.java Tue Jul 26 18:27:32 2011
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you 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.portlet.faces.bridge;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.faces.annotation.ExcludeFromManagedRequestScope;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpSession;
+
+
+/**
+ * BridgeRequestScopeUtil contains static class methods to test whether an atrtibute belongs in the
+ * BridgeManagedScope or not.  This is provided not only for the BridgeScope implementation
+ * but also so impls supporting the specified Bridge PreDestory can test attributes being
+ * added to the request scope when a bridge scope hasn't yet been established.
+ */
+ 
+public class BridgeRequestScopeUtil 
+{
+  
+
+  /**
+    * Allows the caller to (pre-determine) if a given attribute name/value pair
+    * will be excluded ot not.
+    * 
+    * @param key name of the attribute 
+    * @param value of the attribute
+    * @param configuredExcludes
+    * @return true if the attribute will be excluded, false otherwise.
+    */
+
+  static public boolean isExcluded(String key, Object value, List<String> configuredExcludes)
+  {
+    return ((value != null && value.getClass().getAnnotation(ExcludeFromManagedRequestScope.class) != null) || 
+          (configuredExcludes != null && configuredExcludes.contains(key)) ||
+          isPreDefinedExcludedObject(key, value) ||
+          isExcludedNamespace(key, configuredExcludes));
+  }
+  
+  static public boolean isPreDefinedExcludedObject(String s, Object o)
+  {
+    if (o != null &&
+        (o instanceof PortletConfig || o instanceof PortletContext ||
+         o instanceof PortletRequest || o instanceof PortletResponse ||
+         o instanceof PortletSession || o instanceof PortletPreferences ||
+         o instanceof PortalContext || o instanceof FacesContext ||
+         o instanceof ExternalContext || o instanceof ServletConfig ||
+         o instanceof ServletContext || o instanceof ServletRequest ||
+         o instanceof ServletResponse || o instanceof HttpSession))
+      return true;
+    else
+    {
+      return isInNamespace(s, "javax.portlet.") ||
+        isInNamespace(s, "javax.portlet.faces.") ||
+        isInNamespace(s, "javax.faces.") ||
+        isInNamespace(s, "javax.servlet.") ||
+        isInNamespace(s, "javax.servlet.include.") ||
+        isInNamespace(s, "org.apache.myfaces.portlet.faces.") ||
+        // our ExternalContext uses this prefix internally to append to url which might
+        // contain another '.' -- so exclude all that are prefixed with this
+        s.startsWith("org.apache.myfaces.portlet.faces.context.");
+    }
+  }
+
+  static public boolean isExcludedNamespace(String s, List<String> configuredExcludes)
+  {
+    if (configuredExcludes == null)
+    {
+      return false;
+    }
+
+    if (configuredExcludes.contains(s))
+    {
+      return true;
+    }
+
+    // No direct match -- walk through this list and process namespace checks
+    Iterator<String> i = configuredExcludes.iterator();
+    while (i.hasNext())
+    {
+      String exclude = i.next();
+      if (exclude.endsWith("*"))
+      {
+        if (isInNamespace(s, exclude.substring(0, exclude.length() - 1)))
+        {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  static private boolean isInNamespace(String s, String namespace)
+  {
+    // This is a non-recursive check so s must be the result of removing the namespace.
+    if (s.startsWith(namespace))
+    {
+      // extract entire namespace and compare
+      s = s.substring(0, s.lastIndexOf('.') + 1);
+      return s.equals(namespace);
+    }
+    return false;
+  }
+  
+ 
+ 
+
+ 
+  
+}
\ No newline at end of file

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Tue Jul 26 18:27:32 2011
@@ -182,7 +182,7 @@ public class PortletViewHandlerImpl exte
     // the following code checks/and does the right thing to satisfy the spec.
     
     if (viewRoot.getClass() == UIViewRoot.class &&
-        UIViewRoot.class.isAnnotationPresent(PortletNamingContainer.class))
+        !UIViewRoot.class.isAnnotationPresent(PortletNamingContainer.class))
     {
       String prior = setUIViewRootComponent(facesContext);
       try 

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Tue Jul 26 18:27:32 2011
@@ -77,7 +77,6 @@ public class BridgeImpl
   public void init(PortletConfig config)
     throws BridgeException
   {
-    //TODO: Should we throw an exception if the bridge is already initialized?
     if (mInitialized)
       throw new BridgeException("Bridge already initialized.");
     
@@ -273,9 +272,7 @@ public class BridgeImpl
     bCtx.setPortletRequestPhase(phase);
     bCtx.setPortletResponse(response);
     bCtx.setPreFacesRequestAttrNames(Collections.list(request.getAttributeNames()));
-    
-    BridgeContext.setCurrentInstance(bCtx);
-    
+        
     sendExFacesSystemEvent(bCtx, BridgeInitializeRequestSystemEvent.class);
     
     return bCtx;
@@ -318,7 +315,7 @@ public class BridgeImpl
       // Do nothing if we don't have a BriegeEventHandler
       if (mBridgeConfig.getEventHandler() == null)
       {
-        // TODO: maybe log something here?
+        mBridgeConfig.getLogger().log("WARNING: Received an event but there is no event handler registered by this portlet in the bridge.");
         return;
       }
     }

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/context/BridgeContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/context/BridgeContextImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/context/BridgeContextImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/context/BridgeContextImpl.java Tue Jul 26 18:27:32 2011
@@ -95,6 +95,9 @@ public class BridgeContextImpl extends B
     
   public BridgeContextImpl()
   {
+    
+    BridgeContext.setCurrentInstance(this);
+
     // Add self as ELContextListener to the Faces App so we can add the
     // portletConfig to any newly created contexts.    
     ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
@@ -107,10 +110,15 @@ public class BridgeContextImpl extends B
    */
   public void release()
   {
+    
+    BridgeContext.setCurrentInstance(null);
+    
     // Add self as ELContextListener to the Faces App so we can add the
     // portletConfig to any newly created contexts.    
     ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
         .getApplication().removeELContextListener(this);
+    
+    
   }
   
   

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/controller/BridgeControllerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/controller/BridgeControllerImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/controller/BridgeControllerImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/controller/BridgeControllerImpl.java Tue Jul 26 18:27:32 2011
@@ -33,7 +33,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
 import java.util.Set;
@@ -50,40 +49,30 @@ import javax.faces.application.Applicati
 import javax.faces.application.ApplicationFactory;
 import javax.faces.application.FacesMessage;
 import javax.faces.application.ViewHandler;
-import javax.faces.component.UIViewRoot;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.FacesContextFactory;
-import javax.faces.event.AbortProcessingException;
 import javax.faces.event.PhaseEvent;
 import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.faces.event.SystemEvent;
-import javax.faces.event.SystemEventListener;
+
 import javax.faces.lifecycle.Lifecycle;
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.ResponseStateManager;
 import javax.portlet.EventRequest;
 import javax.portlet.EventResponse;
-import javax.portlet.MimeResponse;
+import javax.portlet.PortletContext;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
-import javax.portlet.ResourceResponse;
 import javax.portlet.StateAwareResponse;
 import javax.portlet.faces.Bridge;
 import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
-import javax.portlet.faces.BridgeEventHandler;
 import javax.portlet.faces.BridgeException;
-import javax.portlet.faces.BridgeNotAFacesRequestException;
-import javax.portlet.faces.BridgePublicRenderParameterHandler;
 import javax.portlet.faces.BridgeUninitializedException;
 import javax.portlet.faces.BridgeUtil;
-import javax.portlet.faces.BridgeWriteBehindResponse;
 
 import javax.portlet.faces.annotation.BridgeRequestScopeAttributeAdded;
 import javax.portlet.faces.event.EventNavigationResult;
@@ -95,11 +84,12 @@ import org.apache.myfaces.portlet.faces.
 import org.apache.myfaces.portlet.faces.bridge.BridgeContext;
 import org.apache.myfaces.portlet.faces.bridge.BridgeController;
 import org.apache.myfaces.portlet.faces.bridge.BridgeImpl;
+import org.apache.myfaces.portlet.faces.bridge.BridgeLogger;
 import org.apache.myfaces.portlet.faces.bridge.BridgePostConstructFacesContextSystemEvent;
 import org.apache.myfaces.portlet.faces.bridge.BridgePreReleaseFacesContextSystemEvent;
 import org.apache.myfaces.portlet.faces.bridge.BridgeRequestScope;
 import org.apache.myfaces.portlet.faces.bridge.BridgeRequestScopeManager;
-import org.apache.myfaces.portlet.faces.bridge.scope.BridgeRequestScopeManagerImpl;
+import org.apache.myfaces.portlet.faces.bridge.BridgeRequestScopeUtil;
 import org.apache.myfaces.portlet.faces.bridge.wrapper.BridgeEventRequestWrapper;
 import org.apache.myfaces.portlet.faces.bridge.wrapper.BridgeRenderRequestWrapper;
 import org.apache.myfaces.portlet.faces.context.PortletExternalContextImpl;
@@ -107,7 +97,7 @@ import org.apache.myfaces.portlet.faces.
 import org.apache.myfaces.portlet.faces.util.QueryString;
 
 public class BridgeControllerImpl
-  implements BridgeController, ELContextListener, PhaseListener
+  implements BridgeController, ELContextListener, PhaseListener, ServletRequestAttributeListener
 {
   private static final long serialVersionUID = 5807626987246270989L;
 
@@ -179,7 +169,6 @@ public class BridgeControllerImpl
     
     // Once a RenderRedirect occurs state is preserved until the next non-render occurs
     // Clear this state here to ensure the following render isn't confused
-    // TODO:  can we figure out a way to store this so its autocleared when a scope is restarted?
     clearRenderRedirectCache(bCtx);
     
     // Remove any BridgeRequestScope associate with this view/mode
@@ -223,18 +212,13 @@ public class BridgeControllerImpl
     }
     finally
     {   
-      // TODO:  add this back in 
-      // dumpScopeId(scopeId, "ACTION_PHASE");
+      dumpScope(bCtx, "ACTION_PHASE");
 
       if (lifecycle != null)
       {
         lifecycle.removePhaseListener(this);
       }
       
-      // TODO:  I removed the code for reseting the redirect flag -- in old controller this was on a requedst attr
-      // in in some environments the portlet container ran both the action and render in the same overall servlet request
-      // In new code this flag is on the BridgeContext -- which is reacquired each portlet request.
-
       if (fCtx != null)
       {
         releaseFacesContext(bCtx, fCtx);
@@ -253,13 +237,12 @@ public class BridgeControllerImpl
     
     // Once a RenderRedirect occurs state is preserved until the next non-render occurs
     // Clear this state here to ensure the following render isn't confused
-    // TODO:  can we figure out a way to store this so its autocleared when a scope is restarted?
     clearRenderRedirectCache(bCtx);
    
     // Do nothing if we don't have a BridgeEventHandler
     if (bCtx.getBridgeConfig().getEventHandler() == null)
     {
-      // TODO: maybe log something here?
+      bCtx.getBridgeConfig().getLogger().log("Bridge has been sent an event but has no registered event handler.  Returning without processing the event.");
       return;
     }
   
@@ -345,18 +328,13 @@ public class BridgeControllerImpl
         }
       }
       
-      // TODO: add back in
-      // dumpScopeId(scopeId, "EVENT_PHASE");
+      dumpScope(bCtx, "EVENT_PHASE");
       
       if (lifecycle != null)
       {
         lifecycle.removePhaseListener(this);
       }
 
-      // TODO:  I removed the code for reseting the redirect flag -- in old controller this was on a requedst attr
-      // in in some environments the portlet container ran both the action and render in the same overall servlet request
-      // In new code this flag is on the BridgeContext -- which is reacquired each portlet request.
-
       if (fCtx != null)
       {
         releaseFacesContext(bCtx, fCtx);
@@ -427,9 +405,8 @@ public class BridgeControllerImpl
       // get context as it may have been reacquired if exception occurred during redirect during render.
       fCtx = FacesContext.getCurrentInstance();
 
-      // TODO: 
-      // if (!mDebugLoggingEnabled.booleanValue())
-      //   mPortletConfig.getPortletContext().log("Exception thrown in doFacesRequest:render", e);
+      if (bCtx.getBridgeConfig().getLogger().isEnabled()) 
+        bCtx.getBridgeConfig().getLogger().log("Exception thrown in doFacesRequest:render", e);
       
       if (!(e instanceof BridgeException))
       {
@@ -439,8 +416,7 @@ public class BridgeControllerImpl
     }
     finally
     {
-      // TODO:
-      //dumpScopeId(scopeId, "RENDER_PHASE");
+      dumpScope(bCtx, "RENDER_PHASE");
 
       if (fCtx != null)
       {
@@ -491,11 +467,7 @@ public class BridgeControllerImpl
 
     FacesContext fCtx = null;
     BridgeRequestScope scope = getBridgeRequestScope(bCtx);
-    if (scope == null)
-    {
-      // don't expect this as we should always have a scope -- but to be safe
-      scope = getNewBridgeRequestScope(bCtx);
-    }
+
     try
     {
       // Get the FacesContext instance for this request
@@ -507,9 +479,8 @@ public class BridgeControllerImpl
     }
     catch (Exception e)
     {
-      // TODO:
-      // if (!mDebugLoggingEnabled.booleanValue())
-      //  context.getExternalContext().log("Exception thrown in doFacesRequest:resource", e);
+      if (bCtx.getBridgeConfig().getLogger().isEnabled()) 
+        bCtx.getBridgeConfig().getLogger().log("Exception thrown in doFacesRequest:resource", e);
       
       if (!(e instanceof BridgeException))
       {
@@ -519,8 +490,7 @@ public class BridgeControllerImpl
     }
     finally
     {
-      // TODO:
-      //dumpScopeId(scopeId, "RESOURCE_PHASE");
+      dumpScope(bCtx, "RESOURCE_PHASE");
 
       if (fCtx != null)
       {
@@ -550,6 +520,85 @@ public class BridgeControllerImpl
     }
   }
   
+  // ServetContextAttributeListener methods
+  public void attributeAdded(ServletRequestAttributeEvent srae)
+  {
+    BridgeContext bCtx = BridgeContext.getCurrentInstance();
+    
+    // Do nothing if there is no current BridgeContext
+    if (bCtx == null) return;
+    
+    // use this phase attribute as an indicator of whether 
+    // we are actively working on a request
+    Bridge.PortletPhase phase = (Bridge.PortletPhase) srae.getServletRequest().getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
+
+    // do nothing if before/after bridge processing or in the render phase.
+    // Don't care about render phase because we don't update/change the managed
+    // scope based on changes during render.
+    // ALSO: do nothing if not in the Bridge's managed request scope
+    if (phase == null || phase == Bridge.PortletPhase.RENDER_PHASE ||
+        BridgeRequestScopeUtil.isExcluded(srae.getName(), srae.getValue(), bCtx.getBridgeConfig().getExcludedRequestAttributes()))
+    {
+      return;
+    }
+    
+
+    // Otherwise -- see if the added attribute implements the bridge's 
+    // BridgeRequestScopeAdded annotation -- call each method so annotated
+    Object o = srae.getValue();
+    Method[] methods = o.getClass().getMethods();
+    for (int i = 0; i < methods.length; i++)
+    {
+      if (methods[i].isAnnotationPresent(BridgeRequestScopeAttributeAdded.class))
+      {
+        try
+        {
+          methods[i].invoke(o, null);
+        }
+        catch (Exception e)
+        {
+          BridgeContext.log("Unexpected problem notifying object with BridgeRequestScopeAdded annotation.", e);
+        }
+      }
+    }
+  }
+  
+  public void attributeRemoved(ServletRequestAttributeEvent srae)
+  {
+    removeAttrFromScope(srae);
+  }
+
+  public void attributeReplaced(ServletRequestAttributeEvent srae)
+  {
+    removeAttrFromScope(srae);
+  }
+  
+  private void removeAttrFromScope(ServletRequestAttributeEvent srae)
+  {
+    // use this phase attribute as an indicator of whether 
+    // we are actively working on a request
+    Bridge.PortletPhase phase = (Bridge.PortletPhase) srae.getServletRequest().getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
+
+    // If not in a render this means the attribute has been removed before we have
+    // saved the request scope -- since the managed bean has been informed we are
+    // running in a portlet environment it should have ignored the PreDestroy.
+    // To make up for this we call its BridgePredestroy
+    if (phase != null && phase != Bridge.PortletPhase.RENDER_PHASE)
+    {
+      BridgeContext bCtx = BridgeContext.getCurrentInstance();
+      
+      // Do nothing if there is no current BridgeContext
+      if (bCtx == null) return;
+      
+      BridgeRequestScope scope = bCtx.getBridgeScope();
+      
+      if (scope != null)
+      {
+        scope.remove(srae.getName(), srae.getValue()); // in outerclass (BridgeImpl)
+      }
+    }
+  }
+  
   
   private void doFacesRender(
       BridgeContext bCtx,
@@ -754,92 +803,16 @@ public class BridgeControllerImpl
     }
   }
   
-  //TODO: unneeded??
-  
-  /*
-  private BridgeRequestScope getResourceRequestScope(BridgeContext bCtx, ExternalContext extCtx)
-  {
-    BridgeRequestScope childScope = null;
-    // get the render scope this resource request is contained in
-    BridgeRequestScope scope = getRequestScope(bCtx);
-       
-    if (scope == null)
-    {
-      // first request is a resource request -- return null so one is created
-      return scope;
-    }
-
-    
-    // Check to see if this resource request is targeting the same view or a different one
-    Map<String, String> childResourceScopeMap = (Map<String, String>) scope.get(CHILD_RESOURCE_REQUEST_SCOPE_MAP);
-    String scopeIdKey = (String) scope.get(SCOPE_VIEW_KEY);
-    String childIdKey = getScopeViewKey(extCtx);
-    
-    // If the resource is a PPR it will target the same view as the render/parent
-    // In which case use the same scope
-    if (scopeIdKey == null || scopeIdKey.equalsIgnoreCase(childIdKey))
-    {
-      return scope;
-    }
-    else
-    {  
-      String childScopeId = null;
-  
-      if (childResourceScopeMap != null)
-      {
-        childScopeId = childResourceScopeMap.get(childIdKey);
-      }
-      
-      if (childScopeId == null)
-      {
-        childScope = getNewBridgeRequestScope(bCtx);
-      
-        if (childResourceScopeMap == null)
-        {
-          childResourceScopeMap = (Map<String, String>) new HashMap(3); 
-          scope.put(CHILD_RESOURCE_REQUEST_SCOPE_MAP, childResourceScopeMap);
-        }
-        childResourceScopeMap.put(childIdKey, childScope.getId());
-      }
-          
-      return childScope;
-    }
-  } 
-  
-  private String getScopeViewKey(ExternalContext extCtx)
-  {
-    String scopeIdKey = null;
-    String pathInfo = extCtx.getRequestPathInfo();
-    String servletPath = extCtx.getRequestServletPath();
-    
-    if (pathInfo == null) scopeIdKey = servletPath;
-    else if (servletPath == null) scopeIdKey = pathInfo;
-    else scopeIdKey = servletPath + pathInfo;
-    
-    return scopeIdKey;
-
-  }
-  
-  private void clearBridgeRequestScopeSessionParameter(BridgeContext bCtx)
-  {
-    // in case a prior scope was managed temporarily on the session -- remove it
-    // also ensure that the scopeId is now carried forward as a renderParameter
-    bCtx.getPortletRequest().getPortletSession().removeAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + REQUEST_SCOPE_ID_RENDER_PARAM);
-  }
-*/
   
   @SuppressWarnings("unchecked")
   private boolean restoreBridgeRequestScopeData(BridgeContext bCtx, BridgeRequestScope scope)
     throws BridgeException
   {   
-    //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 (scope == null)
     {
       return false;
     }
     
-
     restoreFacesViewFromBridgeRequestScope(bCtx, scope);
     
     Set<Map.Entry<String, Object>> s = scope.entrySet();
@@ -1038,9 +1011,7 @@ public class BridgeControllerImpl
   
   
   private void clearRenderRedirectCache(BridgeContext bCtx)
-  {
-    // TODO:  Can't this data be held/managed in the Bridge RequestScope and if so will it be naturally cleared?
-    
+  {   
     PortletSession session = bCtx.getPortletRequest().getPortletSession(true);
     
     session.removeAttribute(BridgeControllerImpl.RENDER_REDIRECT_VIEWPARAMS);
@@ -1116,11 +1087,7 @@ public class BridgeControllerImpl
         return;
       }
       else
-      {  
-        // TODO:
-        // if (!mDebugLoggingEnabled.booleanValue())
-        // context.getExternalContext().log("WARNING: Unexpected situation -- reached end of internal doFacesRender without a scopeId");
-      
+      {     
         scope = getNewBridgeRequestScope(bCtx);
       }
     }
@@ -1477,6 +1444,35 @@ public class BridgeControllerImpl
       }
     }
   }  
+  
+  private void dumpScope(BridgeContext bCtx, String phase)
+  {
+    if (bCtx == null || !bCtx.getBridgeConfig().getLogger().isEnabled()) return;
+
+    // Get the data from the scope
+    BridgeLogger logger = bCtx.getBridgeConfig().getLogger();
+    
+    BridgeRequestScope scope = bCtx.getBridgeScope();
+    
+    if (scope != null)
+    {
+      logger.log("dumpScope: " + phase);
+      logger.log("Elements in scope: " + scope.getPortletMode() + " : " + scope.getViewId());
+    }
+    else 
+    {
+      logger.log("dumpScope: " + phase + " : Scope not established.");
+      return;
+    }
+    
+    for (String s : scope.keySet())
+    {
+      logger.log("     " + s);
+
+    }
+
+    logger.log("end dumpScope");
+  }
    
 
 

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeImpl.java Tue Jul 26 18:27:32 2011
@@ -12,6 +12,8 @@
 
 package org.apache.myfaces.portlet.faces.bridge.scope;
 
+import java.lang.reflect.Method;
+
 import java.rmi.server.UID;
 
 import java.util.Collection;
@@ -36,6 +38,7 @@ import javax.portlet.PortletPreferences;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;
 import javax.portlet.PortletSession;
+import javax.portlet.faces.annotation.BridgePreDestroy;
 import javax.portlet.faces.annotation.ExcludeFromManagedRequestScope;
 
 import javax.servlet.ServletConfig;
@@ -44,7 +47,9 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpSession;
 
+import org.apache.myfaces.portlet.faces.bridge.BridgeContext;
 import org.apache.myfaces.portlet.faces.bridge.BridgeRequestScope;
+import org.apache.myfaces.portlet.faces.bridge.BridgeRequestScopeUtil;
 
 
 /**
@@ -72,9 +77,7 @@ public class  BridgeRequestScopeImpl ext
   private String mPortletMode;
   private String mId;
   private Vector<String> mExcludedEntries;
-  
-// TODO: implement notifyPredestory function as weell as the ServletRequestAttributeListener stuff that used to be in BridgeImpl 
-  
+   
   public BridgeRequestScopeImpl(String portletId, String sessionId, String viewId, String portletMode)
   {
     super(DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL);
@@ -212,10 +215,7 @@ public class  BridgeRequestScopeImpl ext
    */
  public boolean isExcluded(String key, Object value)
  {
-   return ((value != null && value.getClass().getAnnotation(ExcludeFromManagedRequestScope.class) != null) || 
-         (mExcludedEntries != null && mExcludedEntries.contains(key)) ||
-         isPreDefinedExcludedObject(key, value) ||
-         isExcludedNamespace(key));
+   return BridgeRequestScopeUtil.isExcluded(key, value, mExcludedEntries);
  }
  
  /**
@@ -228,7 +228,7 @@ public class  BridgeRequestScopeImpl ext
   {
     if (!isExcluded(key, value))
     {
-      return super.put(key, value);
+      return notifyPreDestroy(super.put(key, value));
     }
     else
     {
@@ -240,7 +240,7 @@ public class  BridgeRequestScopeImpl ext
   {
     if (!isExcluded(key, value))
     {
-      return super.putIfAbsent(key, value);
+      return notifyPreDestroy(super.putIfAbsent(key, value));
     }
     else
     {
@@ -261,75 +261,61 @@ public class  BridgeRequestScopeImpl ext
     }
   }
   
-  public void release()
+  public Object remove(String key)
   {
-    
+    return notifyPreDestroy(super.remove(key));
   }
   
-
-  private boolean isPreDefinedExcludedObject(String s, Object o)
+  public Object remove(String key, Object value)
   {
-    if (o != null &&
-        (o instanceof PortletConfig || o instanceof PortletContext ||
-         o instanceof PortletRequest || o instanceof PortletResponse ||
-         o instanceof PortletSession || o instanceof PortletPreferences ||
-         o instanceof PortalContext || o instanceof FacesContext ||
-         o instanceof ExternalContext || o instanceof ServletConfig ||
-         o instanceof ServletContext || o instanceof ServletRequest ||
-         o instanceof ServletResponse || o instanceof HttpSession))
-      return true;
-    else
-    {
-      return isInNamespace(s, "javax.portlet.") ||
-        isInNamespace(s, "javax.portlet.faces.") ||
-        isInNamespace(s, "javax.faces.") ||
-        isInNamespace(s, "javax.servlet.") ||
-        isInNamespace(s, "javax.servlet.include.") ||
-        isInNamespace(s, "org.apache.myfaces.portlet.faces.") ||
-        // our ExternalContext uses this prefix internally to append to url which might
-        // contain another '.' -- so exclude all that are prefixed with this
-        s.startsWith("org.apache.myfaces.portlet.faces.context.");
-    }
+    return notifyPreDestroy(super.remove(key, value));
   }
-
-  private boolean isExcludedNamespace(String s)
+  
+  public boolean replace(String key, Object oldValue, Object newValue)
   {
-    if (mExcludedEntries == null)
+    if (super.replace(key, oldValue, newValue))
     {
-      return false;
+      notifyPreDestroy(oldValue);
+      return true;
     }
-
-    if (mExcludedEntries.contains(s))
+    return false;
+  }
+  
+  public Object replace(String key, Object value)
+  {
+    return notifyPreDestroy(super.replace(key, value));
+  }
+  
+  public void clear()
+  {
+    for (Object o : values())
     {
-      return true;
+      notifyPreDestroy(o);
     }
-
-    // No direct match -- walk through this list and process namespace checks
-    Iterator<String> i = mExcludedEntries.iterator();
-    while (i.hasNext())
+    super.clear();
+  }
+  
+  
+  private Object notifyPreDestroy(Object o)
+  {
+    Method[] methods = o.getClass().getMethods();
+    for (int m = 0; m < methods.length; m++)
     {
-      String exclude = i.next();
-      if (exclude.endsWith("*"))
+      if (methods[m].isAnnotationPresent(BridgePreDestroy.class))
       {
-        if (isInNamespace(s, exclude.substring(0, exclude.length() - 1)))
+        try
+        {
+          methods[m].invoke(o, null);
+        }
+        catch (Exception e)
         {
-          return true;
+          // do nothing and forge ahead
+          BridgeContext.log("Bridge notifyPreDestroy attempt failed.", e);
         }
       }
     }
-    return false;
-  }
-
-  private boolean isInNamespace(String s, String namespace)
-  {
-    // This is a non-recursive check so s must be the result of removing the namespace.
-    if (s.startsWith(namespace))
-    {
-      // extract entire namespace and compare
-      s = s.substring(0, s.lastIndexOf('.') + 1);
-      return s.equals(namespace);
-    }
-    return false;
+    return o;
   }
   
+  
 }
\ No newline at end of file

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeRepository.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeRepository.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeRepository.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/scope/BridgeRequestScopeRepository.java Tue Jul 26 18:27:32 2011
@@ -57,7 +57,7 @@ public class BridgeRequestScopeRepositor
   public BridgeRequestScope remove(String key)
   {
     BridgeRequestScope scope = super.remove(key);
-    // TODO: add notify Predestroy
+    // Note: clear() will call NotifyPreDestroy on elements in the scope being removed
     scope.clear();
     return scope;
   }

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Tue Jul 26 18:27:32 2011
@@ -46,6 +46,9 @@ import javax.faces.application.ViewHandl
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.Flash;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
 import javax.faces.render.ResponseStateManager;
 import javax.portlet.ActionResponse;
 import javax.portlet.BaseURL;
@@ -70,6 +73,7 @@ import javax.servlet.http.Cookie;
 
 import org.apache.myfaces.portlet.faces.bridge.BridgeContext;
 import org.apache.myfaces.portlet.faces.bridge.BridgeImpl;
+import org.apache.myfaces.portlet.faces.bridge.BridgePreReleaseFacesContextSystemEvent;
 import org.apache.myfaces.portlet.faces.util.FacesVersionUtil;
 import org.apache.myfaces.portlet.faces.util.QueryString;
 import org.apache.myfaces.portlet.faces.util.URLUtils;
@@ -91,7 +95,7 @@ import org.apache.myfaces.shared_portlet
  * Methods of interests are: - encodeActionURL - redirect
  */
 public class PortletExternalContextImpl
-  extends ExternalContext
+  extends ExternalContext implements SystemEventListener
 { 
   // Note: be careful -- as this attribute is prefixed to a value containing '.' it
   // wouldn't be exlcuded using normal logic -- so instead BridgeImpl specially
@@ -225,8 +229,7 @@ public class PortletExternalContextImpl
   }
   
   public void release()
-  {
-
+  {   
     // Restore the included path attributes if we unset them
     if (mIncludedPathInfo != null)
     {
@@ -235,22 +238,7 @@ public class PortletExternalContextImpl
     if (mIncludedServletPath != null)
     {
       mPortletRequest.setAttribute(SERVLET_INCLUDED_SERVLETPATH_ATTRIBUTE, mIncludedServletPath);
-    }
-                                                                                                           
-    mPortletContext = null;
-    mPortletRequest = null;
-    mPortletResponse = null;
-
-    mApplicationMap = null;
-    mSessionMap = null;
-    mRequestMap = null;
-    mRequestParameterMap = null;
-    mRequestParameterValuesMap = null;
-    mRequestHeaderMap = null;
-    mRequestHeaderValuesMap = null;
-    mInitParameterMap = null;
-
-    mViewId = null;
+    }                                                                                                          
   }
   
   /**
@@ -1887,7 +1875,7 @@ public class PortletExternalContextImpl
   {
     //TODO: What should I do here.  It would be cool to render out an
     //error page to display in the portlet
-    System.out.println("*****Status Code: "+ statusCode);
+    BridgeContext.getCurrentInstance().getBridgeConfig().getLogger().log("*****Status Code: "+ statusCode);
   }
   
   @Override
@@ -1905,6 +1893,22 @@ public class PortletExternalContextImpl
 
   // End of JSF 1.2 API
   
+  // SystemEventListener IMPL
+  void processEvent(SystemEvent event)
+                    throws AbortProcessingException
+  {
+    if (event instanceof BridgePreReleaseFacesContextSystemEvent)
+    {
+      release();
+    }
+  }
+  
+  boolean isListenerForSource(Object source)
+  {
+    BridgeContext bCtx = BridgeContext.getCurrentInstance();
+    return source == bCtx;
+  }
+  
   private void debugLog(String message)
   {
     if (getBridgeContext().getBridgeConfig().getLogger().isEnabled())

Modified: myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextFactoryImpl.java?rev=1151193&r1=1151192&r2=1151193&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextFactoryImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/refactored_3.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextFactoryImpl.java Tue Jul 26 18:27:32 2011
@@ -216,11 +216,6 @@ public class PortletFacesContextFactoryI
           reqAttrs.remove(iter.next());
         }
       }
-      
-      if(ec instanceof PortletExternalContextImpl)
-      {
-        ((PortletExternalContextImpl)ec).release();
-      }
 
       super.release();
     }