myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r935660 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: application/ApplicationImpl.java lifecycle/LifecycleImpl.java
Date Mon, 19 Apr 2010 16:39:51 GMT
Author: jakobk
Date: Mon Apr 19 16:39:50 2010
New Revision: 935660

URL: http://svn.apache.org/viewvc?rev=935660&view=rev
Log:
MYFACES-2569 setResourceHandler, setViewHandler and setStateManager must throw illegalStateException
if called after at least one request has been processed by the Lifecycle instance (changed
existing solution to allow setting them in the very first request + some code refactoring)

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=935660&r1=935659&r2=935660&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
Mon Apr 19 16:39:50 2010
@@ -18,23 +18,22 @@
  */
 package org.apache.myfaces.application;
 
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.myfaces.application.jsp.JspStateManagerImpl;
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.impl.digester.elements.Property;
-import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
-import org.apache.myfaces.el.PropertyResolverImpl;
-import org.apache.myfaces.el.VariableResolverToApplicationELResolverAdapter;
-import org.apache.myfaces.el.convert.MethodExpressionToMethodBinding;
-import org.apache.myfaces.el.convert.ValueBindingToValueExpression;
-import org.apache.myfaces.el.convert.ValueExpressionToValueBinding;
-import org.apache.myfaces.el.unified.ELResolverBuilder;
-import org.apache.myfaces.el.unified.ResolverBuilderForFaces;
-import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver;
-import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
-import org.apache.myfaces.shared_impl.util.ClassUtils;
-import org.apache.myfaces.view.facelets.el.ELText;
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.TimeZone;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.el.CompositeELResolver;
 import javax.el.ELContext;
@@ -83,22 +82,25 @@ import javax.faces.view.ViewDeclarationL
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.TimeZone;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.myfaces.application.jsp.JspStateManagerImpl;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.config.impl.digester.elements.Property;
+import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
+import org.apache.myfaces.el.PropertyResolverImpl;
+import org.apache.myfaces.el.VariableResolverToApplicationELResolverAdapter;
+import org.apache.myfaces.el.convert.MethodExpressionToMethodBinding;
+import org.apache.myfaces.el.convert.ValueBindingToValueExpression;
+import org.apache.myfaces.el.convert.ValueExpressionToValueBinding;
+import org.apache.myfaces.el.unified.ELResolverBuilder;
+import org.apache.myfaces.el.unified.ResolverBuilderForFaces;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
+import org.apache.myfaces.lifecycle.LifecycleImpl;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+import org.apache.myfaces.view.facelets.el.ELText;
 
 /**
  * DOCUMENT ME!
@@ -138,8 +140,6 @@ public class ApplicationImpl extends App
             since="2.0")
     private static final String PROJECT_STAGE_PARAM_NAME = "javax.faces.PROJECT_STAGE";
 
-    private static final String FIRST_REQUEST_EXECUTED_PARAM = "org.apache.myfaces.lifecycle.first.request.processed";
-
     // ~ Instance fields
     // --------------------------------------------------------------------------
     // --
@@ -1949,7 +1949,8 @@ public class ApplicationImpl extends App
     }
 
     /**
-     * Method to handle determining if the first request has been handled by the associated
lifecycleImpl
+     * Method to handle determining if the first request has 
+     * been handled by the associated LifecycleImpl.
      * @return true if the first request has already been processed, false otherwise
      */
     private boolean isFirstRequestProcessed()
@@ -1957,13 +1958,13 @@ public class ApplicationImpl extends App
         FacesContext context = FacesContext.getCurrentInstance();
         
         //if firstRequestProcessed is not set, check the application map
-        if(!_firstRequestProcessed && context != null && context.getExternalContext().getApplicationMap().containsKey(FIRST_REQUEST_EXECUTED_PARAM))
+        if(!_firstRequestProcessed && context != null 
+                && Boolean.TRUE.equals(context.getExternalContext().getApplicationMap()
+                        .containsKey(LifecycleImpl.FIRST_REQUEST_PROCESSED_PARAM)))
         {
             _firstRequestProcessed = true;
         }
         return _firstRequestProcessed;
-
-        
     }
     
     private static class SystemListenerEntry

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java?rev=935660&r1=935659&r2=935660&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java
Mon Apr 19 16:39:50 2010
@@ -41,22 +41,27 @@ import org.apache.myfaces.util.DebugUtil
 /**
  * Implements the lifecycle as described in Spec. 1.0 PFD Chapter 2
  * 
- * @author Manfred Geiler
+ * @author Manfred Geiler (latest modification by $Author$)
  * @author Nikolay Petrov
+ * @version $Revision$ $Date$
  */
 public class LifecycleImpl extends Lifecycle
 {
     //private static final Log log = LogFactory.getLog(LifecycleImpl.class);
     private static final Logger log = Logger.getLogger(LifecycleImpl.class.getName());
     
-    private static final String FIRST_REQUEST_EXECUTED_PARAM = "org.apache.myfaces.lifecycle.first.request.processed";
+    /**
+     * Boolean.TRUE is stored under this key in the application map if
+     * the first request has been processed.
+     */
+    public static final String FIRST_REQUEST_PROCESSED_PARAM = "org.apache.myfaces.lifecycle.first.request.processed";
     
     private PhaseExecutor[] lifecycleExecutors;
     private PhaseExecutor renderExecutor;
 
     private final List<PhaseListener> _phaseListenerList = new ArrayList<PhaseListener>();
 
-    private boolean _firstRequestExecuted = false;
+    private boolean _firstRequestProcessed = false;
     /**
      * Lazy cache for returning _phaseListenerList as an Array.
      */
@@ -85,8 +90,6 @@ public class LifecycleImpl extends Lifec
     
             new FacesConfigurator(facesContext.getExternalContext()).update();
 
-            requestStarted(facesContext);
-            
             PhaseListenerManager phaseListenerMgr = new PhaseListenerManager(this, facesContext,
getPhaseListeners());
             for (PhaseExecutor executor : lifecycleExecutors)
             {
@@ -217,6 +220,10 @@ public class LifecycleImpl extends Lifec
             {
                 phaseListenerMgr.informPhaseListenersAfter(renderExecutor.getPhase());
                 flash.doPostPhaseActions(facesContext);
+                
+                // publish a field in the application map to indicate
+                // that the first request has been processed
+                requestProcessed(facesContext);
             }
             
             facesContext.getExceptionHandler().handle();
@@ -320,17 +327,21 @@ public class LifecycleImpl extends Lifec
         facesContext.getApplication().publishEvent (facesContext, ExceptionQueuedEvent.class,
context);
     }
     
-    /*
-     * this method places an attribiuet on the application map to indicate that the first
request has been processed. This
-     * attribute is used by several methods in ApplicationImpl to determine whether or not
to throw an illegalStateException
+    /**
+     * This method places an attribute on the application map to 
+     * indicate that the first request has been processed. This
+     * attribute is used by several methods in ApplicationImpl 
+     * to determine whether or not to throw an IllegalStateException
+     * @param facesContext
      */
-    private void requestStarted(FacesContext facesContext)
+    private void requestProcessed(FacesContext facesContext)
     {
-        if(!_firstRequestExecuted)
+        if(!_firstRequestProcessed)
         {
-            _firstRequestExecuted = true;
+            _firstRequestProcessed = true;
 
-            facesContext.getExternalContext().getApplicationMap().put(FIRST_REQUEST_EXECUTED_PARAM,
Boolean.TRUE);
+            facesContext.getExternalContext().getApplicationMap()
+                    .put(FIRST_REQUEST_PROCESSED_PARAM, Boolean.TRUE);
         }        
     }
 



Mime
View raw message