You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/10/26 04:02:02 UTC

svn commit: r1188995 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java

Author: lu4242
Date: Wed Oct 26 02:02:01 2011
New Revision: 1188995

URL: http://svn.apache.org/viewvc?rev=1188995&view=rev
Log:
MYFACES-3372 Multiple Lifecycle instances are not taken into account when setup phase listeners

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=1188995&r1=1188994&r2=1188995&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Wed Oct 26 02:02:01 2011
@@ -18,6 +18,54 @@
  */
 package org.apache.myfaces.config;
 
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELResolver;
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.application.ConfigurableNavigationHandler;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.ResourceHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.PhaseListener;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.faces.event.PreDestroyCustomScopeEvent;
+import javax.faces.event.PreDestroyViewMapEvent;
+import javax.faces.event.SystemEvent;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.validator.BeanValidator;
+import javax.faces.webapp.FacesServlet;
+
 import org.apache.myfaces.application.ApplicationFactoryImpl;
 import org.apache.myfaces.application.BackwardsCompatibleNavigationHandlerWrapper;
 import org.apache.myfaces.component.visit.VisitContextFactoryImpl;
@@ -61,56 +109,10 @@ import org.apache.myfaces.view.facelets.
 import org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener;
 import org.apache.myfaces.webapp.ManagedBeanDestroyerListener;
 
-import javax.el.ELResolver;
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.application.ConfigurableNavigationHandler;
-import javax.faces.application.NavigationHandler;
-import javax.faces.application.ProjectStage;
-import javax.faces.application.ResourceHandler;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.el.PropertyResolver;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.ActionListener;
-import javax.faces.event.ComponentSystemEvent;
-import javax.faces.event.PhaseListener;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.faces.event.PreDestroyCustomScopeEvent;
-import javax.faces.event.PreDestroyViewMapEvent;
-import javax.faces.event.SystemEvent;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.validator.BeanValidator;
-import javax.faces.webapp.FacesServlet;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 /**
  * Configures everything for a given context. The FacesConfigurator is independent of the concrete implementations that
  * lie behind FacesConfigUnmarshaller and FacesConfigDispenser.
- * 
+ *
  * @author Manfred Geiler (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
@@ -128,7 +130,8 @@ public class FacesConfigurator
     private static final String DEFAULT_RENDER_KIT_FACTORY = RenderKitFactoryImpl.class.getName();
     private static final String DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY = PartialViewContextFactoryImpl.class.getName();
     private static final String DEFAULT_VISIT_CONTEXT_FACTORY = VisitContextFactoryImpl.class.getName();
-    private static final String DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY = ViewDeclarationLanguageFactoryImpl.class.getName();
+    private static final String DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY
+            = ViewDeclarationLanguageFactoryImpl.class.getName();
     private static final String DEFAULT_EXCEPTION_HANDLER_FACTORY = ExceptionHandlerFactoryImpl.class.getName();
     private static final String DEFAULT_TAG_HANDLER_DELEGATE_FACTORY = TagHandlerDelegateFactoryImpl.class.getName();
     private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";
@@ -195,12 +198,12 @@ public class FacesConfigurator
 
         return _dispenser;
     }
-    
+
     public void setAnnotationConfigurator(AnnotationConfigurator configurator)
     {
         _annotationConfigurator = configurator;
     }
-    
+
     protected AnnotationConfigurator getAnnotationConfigurator()
     {
         if (_annotationConfigurator == null)
@@ -212,9 +215,9 @@ public class FacesConfigurator
 
     private long getResourceLastModified(String resource)
     {
-        try 
+        try
         {
-            URL url =  _externalContext.getResource(resource);
+            URL url = _externalContext.getResource(resource);
             if (url != null)
             {
                 return getResourceLastModified(url);
@@ -285,8 +288,8 @@ public class FacesConfigurator
         }
 
         return modified;
-    }    
-    
+    }
+
     private long getLastModifiedTime()
     {
         long lastModified = 0;
@@ -294,7 +297,9 @@ public class FacesConfigurator
 
         resModified = getResourceLastModified(DEFAULT_FACES_CONFIG);
         if (resModified > lastModified)
+        {
             lastModified = resModified;
+        }
 
         for (String systemId : getConfigFilesList())
         {
@@ -314,7 +319,9 @@ public class FacesConfigurator
         //and when an application is running on GAE there is no way to update faces config xml file.
         //thus, no need to check if the config file is modified.
         if (ContainerUtils.isRunningOnGoogleAppEngine(_externalContext))
+        {
             return;
+        }
         long refreshPeriod = (MyfacesConfig.getCurrentInstance(_externalContext).getConfigRefreshPeriod()) * 1000;
 
         if (refreshPeriod > 0)
@@ -346,13 +353,14 @@ public class FacesConfigurator
                     log.severe("Error during configuration clean-up" + e.getMessage());
                 }
                 configure();
-                                
+
                 // JSF 2.0 Publish PostConstructApplicationEvent after all configuration resources
                 // has been parsed and processed
                 FacesContext facesContext = FacesContext.getCurrentInstance();
                 Application application = facesContext.getApplication();
-                
-                application.publishEvent(facesContext, PostConstructApplicationEvent.class, Application.class, application);
+
+                application.publishEvent(facesContext, PostConstructApplicationEvent.class,
+                        Application.class, application);
             }
         }
     }
@@ -368,13 +376,16 @@ public class FacesConfigurator
 
         // Check that we have access to all of the necessary purge methods before purging anything
         //
-        ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        ApplicationFactory applicationFactory
+                = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
         appFactoryPurgeMethod = applicationFactory.getClass().getMethod("purgeApplication", NO_PARAMETER_TYPES);
 
-        RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+        RenderKitFactory renderKitFactory
+                = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
         renderKitPurgeMethod = renderKitFactory.getClass().getMethod("purgeRenderKit", NO_PARAMETER_TYPES);
-        
-        LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+        LifecycleFactory lifecycleFactory
+                = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         lifecyclePurgeMethod = lifecycleFactory.getClass().getMethod("purgeLifecycle", NO_PARAMETER_TYPES);
 
         // If there was no exception so far, now we can purge
@@ -399,13 +410,13 @@ public class FacesConfigurator
         configureFactories();
         configureApplication();
         configureRenderKits();
-        
-                //Now we can configure annotations
+
+        //Now we can configure annotations
         //getAnnotationConfigurator().configure(
         //        ((ApplicationFactory) FactoryFinder.getFactory(
         //                FactoryFinder.APPLICATION_FACTORY)).getApplication(),
         //        getDispenser(), metadataComplete);
-        
+
         configureRuntimeConfig();
         configureLifecycle();
         handleSerialFactory();
@@ -415,7 +426,8 @@ public class FacesConfigurator
         lastUpdate = System.currentTimeMillis();
     }
 
-    private List<String> getConfigFilesList() {
+    private List<String> getConfigFilesList()
+    {
         String configFiles = _externalContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
         List<String> configFilesList = new ArrayList<String>();
         if (configFiles != null)
@@ -429,7 +441,8 @@ public class FacesConfigurator
                 {
                     if (log.isLoggable(Level.WARNING))
                     {
-                        log.warning(DEFAULT_FACES_CONFIG + " has been specified in the " + FacesServlet.CONFIG_FILES_ATTR
+                        log.warning(DEFAULT_FACES_CONFIG + " has been specified in the "
+                                + FacesServlet.CONFIG_FILES_ATTR
                                 + " context parameter of "
                                 + "the deployment descriptor. This will automatically be removed, "
                                 + "if we wouldn't do this, it would be loaded twice.  See JSF spec 1.1, 10.3.2");
@@ -443,30 +456,31 @@ public class FacesConfigurator
         }
         return configFilesList;
     }
-    
+
     private void configureFactories()
     {
         FacesConfigData dispenser = getDispenser();
         setFactories(FactoryFinder.APPLICATION_FACTORY, dispenser.getApplicationFactoryIterator(),
-                     DEFAULT_APPLICATION_FACTORY);
+                DEFAULT_APPLICATION_FACTORY);
         setFactories(FactoryFinder.EXCEPTION_HANDLER_FACTORY, dispenser.getExceptionHandlerFactoryIterator(),
-                     DEFAULT_EXCEPTION_HANDLER_FACTORY);        
+                DEFAULT_EXCEPTION_HANDLER_FACTORY);
         setFactories(FactoryFinder.EXTERNAL_CONTEXT_FACTORY, dispenser.getExternalContextFactoryIterator(),
-                     DEFAULT_EXTERNAL_CONTEXT_FACTORY);
+                DEFAULT_EXTERNAL_CONTEXT_FACTORY);
         setFactories(FactoryFinder.FACES_CONTEXT_FACTORY, dispenser.getFacesContextFactoryIterator(),
-                     DEFAULT_FACES_CONTEXT_FACTORY);
+                DEFAULT_FACES_CONTEXT_FACTORY);
         setFactories(FactoryFinder.LIFECYCLE_FACTORY, dispenser.getLifecycleFactoryIterator(),
-                     DEFAULT_LIFECYCLE_FACTORY);
+                DEFAULT_LIFECYCLE_FACTORY);
         setFactories(FactoryFinder.RENDER_KIT_FACTORY, dispenser.getRenderKitFactoryIterator(),
-                     DEFAULT_RENDER_KIT_FACTORY);
+                DEFAULT_RENDER_KIT_FACTORY);
         setFactories(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY, dispenser.getTagHandlerDelegateFactoryIterator(),
-                DEFAULT_TAG_HANDLER_DELEGATE_FACTORY);        
+                DEFAULT_TAG_HANDLER_DELEGATE_FACTORY);
         setFactories(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, dispenser.getPartialViewContextFactoryIterator(),
-                     DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY);
+                DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY);
         setFactories(FactoryFinder.VISIT_CONTEXT_FACTORY, dispenser.getVisitContextFactoryIterator(),
-                     DEFAULT_VISIT_CONTEXT_FACTORY);
-        setFactories(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY, dispenser.getViewDeclarationLanguageFactoryIterator(),
-                     DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY);
+                DEFAULT_VISIT_CONTEXT_FACTORY);
+        setFactories(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
+                dispenser.getViewDeclarationLanguageFactoryIterator(),
+                DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY);
     }
 
     private void setFactories(String factoryName, Collection<String> factories, String defaultFactory)
@@ -480,14 +494,15 @@ public class FacesConfigurator
             }
         }
     }
-    
+
     private void configureApplication()
     {
-        Application application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+        Application application = ((ApplicationFactory)
+                FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
 
         FacesConfigData dispenser = getDispenser();
         application.setActionListener(ClassUtils.buildApplicationObject(ActionListener.class,
-                                                           dispenser.getActionListenerIterator(), null));
+                dispenser.getActionListenerIterator(), null));
 
         if (dispenser.getDefaultLocale() != null)
         {
@@ -505,18 +520,18 @@ public class FacesConfigurator
         }
 
         application.setNavigationHandler(ClassUtils.buildApplicationObject(NavigationHandler.class,
-                                                              ConfigurableNavigationHandler.class,
-                                                              BackwardsCompatibleNavigationHandlerWrapper.class,
-                                                              dispenser.getNavigationHandlerIterator(),
-                                                              application.getNavigationHandler()));
+                ConfigurableNavigationHandler.class,
+                BackwardsCompatibleNavigationHandlerWrapper.class,
+                dispenser.getNavigationHandlerIterator(),
+                application.getNavigationHandler()));
 
         application.setStateManager(ClassUtils.buildApplicationObject(StateManager.class,
-                                                         dispenser.getStateManagerIterator(),
-                                                         application.getStateManager()));
+                dispenser.getStateManagerIterator(),
+                application.getStateManager()));
 
         application.setResourceHandler(ClassUtils.buildApplicationObject(ResourceHandler.class,
-                                                            dispenser.getResourceHandlerIterator(),
-                                                            application.getResourceHandler()));
+                dispenser.getResourceHandlerIterator(),
+                application.getResourceHandler()));
 
         List<Locale> locales = new ArrayList<Locale>();
         for (String locale : dispenser.getSupportedLocalesIterator())
@@ -527,40 +542,49 @@ public class FacesConfigurator
         application.setSupportedLocales(locales);
 
         application.setViewHandler(ClassUtils.buildApplicationObject(ViewHandler.class,
-                                                        dispenser.getViewHandlerIterator(),
-                                                        application.getViewHandler()));
+                dispenser.getViewHandlerIterator(),
+                application.getViewHandler()));
         for (SystemEventListener systemEventListener : dispenser.getSystemEventListeners())
         {
 
 
-            try {
+            try
+            {
                 //note here used to be an instantiation to deal with the explicit source type in the registration,
                 // that cannot work because all system events need to have the source being passed in the constructor
-                //instead we now  rely on the standard system event types and map them to their appropriate constructor types
-                Class eventClass = ClassUtils.classForName((systemEventListener.getSystemEventClass() != null) ? systemEventListener.getSystemEventClass():SystemEvent.class.getName());
+                //instead we now  rely on the standard system event types and map them to their appropriate
+                // constructor types
+                Class eventClass = ClassUtils.classForName((systemEventListener.getSystemEventClass() != null)
+                        ? systemEventListener.getSystemEventClass()
+                        : SystemEvent.class.getName());
                 //application.subscribeToEvent(
                 //    (Class<? extends SystemEvent>)eventClass ,
                 //        (Class<?>)ClassUtils.classForName((systemEventListener.getSourceClass() != null) ? systemEventListener.getSourceClass(): getDefaultSourcClassForSystemEvent(eventClass) ), //Application.class???
                 //        (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
-                
+
                 if (systemEventListener.getSourceClass() != null && systemEventListener.getSourceClass().length() > 0)
                 {
                     application.subscribeToEvent(
-                            (Class<? extends SystemEvent>)eventClass , ClassUtils.classForName(systemEventListener.getSourceClass()), 
-                                (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
+                            (Class<? extends SystemEvent>) eventClass,
+                            ClassUtils.classForName(systemEventListener.getSourceClass()),
+                            (javax.faces.event.SystemEventListener)
+                                    ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
                 }
                 else
                 {
                     application.subscribeToEvent(
-                            (Class<? extends SystemEvent>)eventClass ,
-                                (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
+                            (Class<? extends SystemEvent>) eventClass,
+                            (javax.faces.event.SystemEventListener)
+                                    ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
                 }
-            } catch (ClassNotFoundException e) {
-                log.log(Level.SEVERE, "System event listener could not be initialized, reason:",e);
+            }
+            catch (ClassNotFoundException e)
+            {
+                log.log(Level.SEVERE, "System event listener could not be initialized, reason:", e);
             }
         }
 
-        
+
         for (String componentType : dispenser.getComponentTypes())
         {
             application.addComponent(componentType, dispenser.getComponentClass(componentType));
@@ -576,7 +600,7 @@ public class FacesConfigurator
             try
             {
                 application.addConverter(ClassUtils.simpleClassForName(converterClass),
-                                         dispenser.getConverterClassByClass(converterClass));
+                        dispenser.getConverterClassByClass(converterClass));
             }
             catch (Exception ex)
             {
@@ -594,7 +618,7 @@ public class FacesConfigurator
         //     - bean validation is available in the classpath
         String beanValidatorDisabled = _externalContext.getInitParameter(
                 BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME);
-        final boolean defaultBeanValidatorDisabled = (beanValidatorDisabled != null 
+        final boolean defaultBeanValidatorDisabled = (beanValidatorDisabled != null
                 && beanValidatorDisabled.toLowerCase().equals("true"));
         boolean beanValidatorInstalledProgrammatically = false;
         if (!defaultBeanValidatorDisabled
@@ -610,12 +634,12 @@ public class FacesConfigurator
         {
             application.addDefaultValidatorId(validatorId);
         }
-        
+
         // do some checks if the BeanValidator was not installed as a
         // default-validator programmatically, but via a config file.
-        if (!beanValidatorInstalledProgrammatically 
+        if (!beanValidatorInstalledProgrammatically
                 && application.getDefaultValidatorInfo()
-                        .containsKey(BeanValidator.VALIDATOR_ID))
+                .containsKey(BeanValidator.VALIDATOR_ID))
         {
             if (!ExternalSpecifications.isBeanValidationAvailable())
             {
@@ -633,26 +657,27 @@ public class FacesConfigurator
                 // (section 11.1.3: "though manual installation is still possible")
                 // --> inform the user about this scenario
                 log.log(Level.INFO, "The BeanValidator was disabled as a " +
-                        "default-validator via the config parameter " + 
+                        "default-validator via the config parameter " +
                         BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME +
                         " in web.xml, but a faces-config file added it, " +
                         "thus it actually was installed as a default-validator.");
             }
         }
 
-        for (Behavior behavior : dispenser.getBehaviors()) {
+        for (Behavior behavior : dispenser.getBehaviors())
+        {
             application.addBehavior(behavior.getBehaviorId(), behavior.getBehaviorClass());
         }
-        
+
         RuntimeConfig runtimeConfig = getRuntimeConfig();
 
         runtimeConfig.setPropertyResolverChainHead(ClassUtils.buildApplicationObject(PropertyResolver.class,
-                                                                        dispenser.getPropertyResolverIterator(),
-                                                                        new DefaultPropertyResolver()));
+                dispenser.getPropertyResolverIterator(),
+                new DefaultPropertyResolver()));
 
         runtimeConfig.setVariableResolverChainHead(ClassUtils.buildApplicationObject(VariableResolver.class,
-                                                                        dispenser.getVariableResolverIterator(),
-                                                                        new VariableResolverImpl()));
+                dispenser.getVariableResolverIterator(),
+                new VariableResolverImpl()));
     }
 
     /**
@@ -667,16 +692,19 @@ public class FacesConfigurator
     String getDefaultSourcClassForSystemEvent(Class systemEventClass)
     {
         Constructor[] constructors = systemEventClass.getConstructors();
-        for(Constructor constr: constructors) {
-            Class [] parms = constr.getParameterTypes();
-            if(parms == null || parms.length != 1)
+        for (Constructor constr : constructors)
+        {
+            Class[] parms = constr.getParameterTypes();
+            if (parms == null || parms.length != 1)
             {
                 //for standard types we have only one parameter representing the type
                 continue;
             }
             return parms[0].getName();
         }
-        log.warning("The SystemEvent source type for "+systemEventClass.getName() + " could not be detected, either register it manually or use a constructor argument for auto detection, defaulting now to java.lang.Object");
+        log.warning("The SystemEvent source type for " + systemEventClass.getName()
+                + " could not be detected, either register it manually or use a constructor argument "
+                + "for auto detection, defaulting now to java.lang.Object");
         return "java.lang.Object";
     }
 
@@ -722,7 +750,7 @@ public class FacesConfigurator
         for (String converterClassName : dispenser.getConverterConfigurationByClassName())
         {
             runtimeConfig.addConverterConfiguration(converterClassName,
-                                                                      _dispenser.getConverterConfiguration(converterClassName));
+                    _dispenser.getConverterConfiguration(converterClassName));
         }
 
         for (ResourceBundle bundle : dispenser.getResourceBundles())
@@ -732,44 +760,49 @@ public class FacesConfigurator
 
         for (String className : dispenser.getElResolvers())
         {
-            runtimeConfig.addFacesConfigElResolver((ELResolver)ClassUtils.newInstance(className, ELResolver.class));
+            runtimeConfig.addFacesConfigElResolver((ELResolver) ClassUtils.newInstance(className, ELResolver.class));
         }
-        
-        runtimeConfig.setFacesVersion (dispenser.getFacesVersion());
-        
+
+        runtimeConfig.setFacesVersion(dispenser.getFacesVersion());
+
         runtimeConfig.setNamedEventManager(new NamedEventManager());
-        
+
         for (NamedEvent event : dispenser.getNamedEvents())
         {
             try
             {
                 Class<? extends ComponentSystemEvent> clazz = ClassUtils.classForName(event.getEventClass());
-                runtimeConfig.getNamedEventManager().addNamedEvent(event.getShortName(), clazz);                
-            } catch (ClassNotFoundException e) {
-                log.log(Level.SEVERE, "Named event could not be initialized, reason:",e);
+                runtimeConfig.getNamedEventManager().addNamedEvent(event.getShortName(), clazz);
+            }
+            catch (ClassNotFoundException e)
+            {
+                log.log(Level.SEVERE, "Named event could not be initialized, reason:", e);
             }
         }
 
         String comparatorClass = _externalContext.getInitParameter(ResolverBuilderBase.EL_RESOLVER_COMPARATOR);
-        
+
         if (comparatorClass != null && !"".equals(comparatorClass))
         {
             // get the comparator class
             Class<Comparator<ELResolver>> clazz;
-            try {
+            try
+            {
                 clazz = ClassUtils.classForName(comparatorClass);
                 // create the instance
                 Comparator<ELResolver> comparator = clazz.newInstance();
-                
+
                 runtimeConfig.setELResolverComparator(comparator);
-            } catch (Exception e)
+            }
+            catch (Exception e)
             {
                 if (log.isLoggable(Level.SEVERE))
                 {
-                    log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator "+ comparatorClass+
-                            " . Check org.apache.myfaces.EL_RESOLVER_COMPARATOR web config param. Initialization continues with no comparator used.", e);
+                    log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator " + comparatorClass
+                            + " . Check org.apache.myfaces.EL_RESOLVER_COMPARATOR web config param. "
+                            + "Initialization continues with no comparator used.", e);
                 }
-            } 
+            }
         }
         else
         {
@@ -798,13 +831,14 @@ public class FacesConfigurator
                 }
             }
         }
-        
+
         runtimeConfig.resetManagedBeansNotReaddedAfterPurge();
     }
 
     private void configureRenderKits()
     {
-        RenderKitFactory renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+        RenderKitFactory renderKitFactory
+                = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
 
         FacesConfigData dispenser = getDispenser();
         for (String renderKitId : dispenser.getRenderKitIds())
@@ -823,8 +857,9 @@ public class FacesConfigurator
             for (Renderer element : dispenser.getRenderers(renderKitId))
             {
                 javax.faces.render.Renderer renderer;
-                Collection<ClientBehaviorRenderer> clientBehaviorRenderers = dispenser.getClientBehaviorRenderers (renderKitId);
-                
+                Collection<ClientBehaviorRenderer> clientBehaviorRenderers
+                        = dispenser.getClientBehaviorRenderers(renderKitId);
+
                 try
                 {
                     renderer = (javax.faces.render.Renderer) ClassUtils.newInstance(element.getRendererClass());
@@ -837,23 +872,28 @@ public class FacesConfigurator
                 }
 
                 renderKit.addRenderer(element.getComponentFamily(), element.getRendererType(), renderer);
-                
+
                 // Add in client behavior renderers.
-                
-                for (ClientBehaviorRenderer clientBehaviorRenderer : clientBehaviorRenderers) {
-                    try {
-                        javax.faces.render.ClientBehaviorRenderer behaviorRenderer = (javax.faces.render.ClientBehaviorRenderer)
-                            ClassUtils.newInstance (clientBehaviorRenderer.getRendererClass());
-                        
+
+                for (ClientBehaviorRenderer clientBehaviorRenderer : clientBehaviorRenderers)
+                {
+                    try
+                    {
+                        javax.faces.render.ClientBehaviorRenderer behaviorRenderer
+                                = (javax.faces.render.ClientBehaviorRenderer)
+                                ClassUtils.newInstance(clientBehaviorRenderer.getRendererClass());
+
                         renderKit.addClientBehaviorRenderer(clientBehaviorRenderer.getRendererType(), behaviorRenderer);
                     }
-                    
-                    catch (Throwable e) {
+
+                    catch (Throwable e)
+                    {
                         // Ignore.
-                        
-                        if (log.isLoggable(Level.SEVERE)) {
+
+                        if (log.isLoggable(Level.SEVERE))
+                        {
                             log.log(Level.SEVERE, "failed to configure client behavior renderer class " +
-                                 clientBehaviorRenderer.getRendererClass(), e);
+                                    clientBehaviorRenderer.getRendererClass(), e);
                         }
                     }
                 }
@@ -866,31 +906,39 @@ public class FacesConfigurator
     private void configureLifecycle()
     {
         // create the lifecycle used by the app
-        LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
-        Lifecycle lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
-
-        // add phase listeners
-        for (String listenerClassName : getDispenser().getLifecyclePhaseListeners())
+        LifecycleFactory lifecycleFactory
+                = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+        
+        //Lifecycle lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
+        for (Iterator<String> it = lifecycleFactory.getLifecycleIds(); it.hasNext();)
         {
-            try
+            Lifecycle lifecycle = lifecycleFactory.getLifecycle(it.next());
+            
+            // add phase listeners
+            for (String listenerClassName : getDispenser().getLifecyclePhaseListeners())
             {
-                lifecycle.addPhaseListener((PhaseListener) ClassUtils.newInstance(listenerClassName, PhaseListener.class));
+                try
+                {
+                    lifecycle.addPhaseListener((PhaseListener)
+                            ClassUtils.newInstance(listenerClassName, PhaseListener.class));
+                }
+                catch (ClassCastException e)
+                {
+                    log.severe("Class " + listenerClassName + " does not implement PhaseListener");
+                }
             }
-            catch (ClassCastException e)
+
+            // if ProjectStage is Development, install the DebugPhaseListener
+            FacesContext facesContext = FacesContext.getCurrentInstance();
+            if (facesContext.isProjectStage(ProjectStage.Development) &&
+                    MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isDebugPhaseListenerEnabled())
             {
-                log.severe("Class " + listenerClassName + " does not implement PhaseListener");
+                lifecycle.addPhaseListener(new DebugPhaseListener());
             }
         }
-        
-        // if ProjectStage is Development, install the DebugPhaseListener
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        if (facesContext.isProjectStage(ProjectStage.Development) && 
-            MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isDebugPhaseListenerEnabled())
-        {
-            lifecycle.addPhaseListener(new DebugPhaseListener());
-        }
     }
 
+    /*
     private String getLifecycleId()
     {
         String id = _externalContext.getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR);
@@ -901,7 +949,7 @@ public class FacesConfigurator
         }
 
         return LifecycleFactory.DEFAULT_LIFECYCLE;
-    }
+    }*/
 
     private void handleSerialFactory()
     {
@@ -926,7 +974,7 @@ public class FacesConfigurator
             }
             catch (Exception e)
             {
-                log.log(Level.SEVERE,"", e);
+                log.log(Level.SEVERE, "", e);
             }
             finally
             {