You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2021/08/28 19:41:11 UTC

[myfaces] branch master updated: Normalize files based on .gitattributes (#220)

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new f8a90dd  Normalize files based on .gitattributes (#220)
f8a90dd is described below

commit f8a90dd4823b7d2ddb9fbe04eadae59f54cdb330
Author: Melloware <me...@gmail.com>
AuthorDate: Sat Aug 28 15:41:07 2021 -0400

    Normalize files based on .gitattributes (#220)
---
 .../java/jakarta/faces/component/_BundleMap.java   |  334 +-
 .../faces/component/_EventListenerWrapper.java     |  680 ++--
 .../myfaces/core/api/shared/AttributeUtils.java    |  128 +-
 .../myfaces/core/api/shared/SelectItemsUtil.java   |  600 +--
 .../core/api/shared/lang/CollectionUtils.java      |  148 +-
 .../viewstate/SerializedViewCollection.java        |  604 +--
 .../cdi/clientwindow/ClientWindowScopeContext.java |  350 +-
 .../ClientWindowScopeContextualStorageHolder.java  |  214 +-
 .../cdi/util/AbstractContextualStorageHolder.java  |  586 +--
 .../apache/myfaces/cdi/view/ViewScopeContext.java  |  408 +-
 .../cdi/view/ViewScopeContextualStorageHolder.java |  142 +-
 .../apache/myfaces/config/FacesConfigurator.java   | 3026 +++++++--------
 .../org/apache/myfaces/config/MyfacesConfig.java   | 3522 ++++++++---------
 .../flow/cdi/DefaultCDIFacesFlowProvider.java      |  270 +-
 .../flow/cdi/FlowScopeContextualStorageHolder.java |  442 +--
 .../flow/impl/DefaultFacesFlowProvider.java        |  268 +-
 .../org/apache/myfaces/flow/impl/FlowScopeMap.java |  326 +-
 .../myfaces/push/WebsocketComponentRenderer.java   |  542 +--
 .../apache/myfaces/renderkit/RendererUtils.java    | 1988 +++++-----
 .../myfaces/renderkit/html/HtmlFormatRenderer.java |  392 +-
 .../myfaces/renderkit/html/HtmlLabelRenderer.java  |  534 +--
 .../myfaces/renderkit/html/HtmlScriptRenderer.java |  488 +--
 .../html/base/HtmlButtonRendererBase.java          | 1038 +++---
 .../html/base/HtmlCheckboxRendererBase.java        | 1052 +++---
 .../renderkit/html/base/HtmlFormRendererBase.java  |  642 ++--
 .../renderkit/html/base/HtmlGridRendererBase.java  |  844 ++---
 .../renderkit/html/base/HtmlImageRendererBase.java |  340 +-
 .../renderkit/html/base/HtmlLinkRendererBase.java  | 2318 ++++++------
 .../html/base/HtmlListboxRendererBase.java         |  372 +-
 .../html/base/HtmlMessageRendererBase.java         |  962 ++---
 .../html/base/HtmlMessagesRendererBase.java        | 1134 +++---
 .../base/HtmlOutcomeTargetButtonRendererBase.java  |  418 +--
 .../renderkit/html/base/HtmlRadioRendererBase.java | 1284 +++----
 .../html/base/HtmlSecretRendererBase.java          |  474 +--
 .../renderkit/html/base/HtmlTableRendererBase.java | 2882 +++++++-------
 .../renderkit/html/base/HtmlTextRendererBase.java  |  780 ++--
 .../html/base/HtmlTextareaRendererBase.java        |  462 +--
 .../renderkit/html/util/HtmlRendererUtils.java     | 3938 ++++++++++----------
 .../myfaces/renderkit/html/util/ResourceUtils.java |  300 +-
 .../renderkit/html/util/SelectItemsUtils.java      |  436 +--
 .../org/apache/myfaces/resource/ResourceImpl.java  |  670 ++--
 .../myfaces/util/lang/SerializableConsumer.java    |   56 +-
 .../org/apache/myfaces/view/ViewScopeProxyMap.java |  390 +-
 .../myfaces/view/facelets/compiler/Compiler.java   |  596 +--
 .../view/facelets/compiler/SAXCompiler.java        | 2250 +++++------
 .../myfaces/view/facelets/impl/DefaultFacelet.java | 1348 +++----
 .../view/facelets/tag/faces/ComponentSupport.java  | 1546 ++++----
 .../view/facelets/tag/faces/core/CoreLibrary.java  |  264 +-
 48 files changed, 21394 insertions(+), 21394 deletions(-)

diff --git a/api/src/main/java/jakarta/faces/component/_BundleMap.java b/api/src/main/java/jakarta/faces/component/_BundleMap.java
index eb378be..aa9223b 100644
--- a/api/src/main/java/jakarta/faces/component/_BundleMap.java
+++ b/api/src/main/java/jakarta/faces/component/_BundleMap.java
@@ -1,168 +1,168 @@
-/*
- * 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 jakarta.faces.component;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-class _BundleMap implements Map<String, String>
-{
-    private ResourceBundle _bundle;
-    private List<String> _values;
-
-    public _BundleMap(ResourceBundle bundle)
-    {
-        _bundle = bundle;
-    }
-
-    // Optimized methods
-    @Override
-    public String get(Object key)
-    {
-        try
-        {
-            return (String) _bundle.getObject(key.toString());
-        }
-        catch (Exception e)
-        {
-            return "???" + key + "???";
-        }
-    }
-
-    @Override
-    public boolean isEmpty()
-    {
-        return !_bundle.getKeys().hasMoreElements();
-    }
-
-    @Override
-    public boolean containsKey(Object key)
-    {
-        try
-        {
-            return _bundle.getObject(key.toString()) != null;
-        }
-        catch (MissingResourceException e)
-        {
-            return false;
-        }
-    }
-
-    // Unoptimized methods
-    @Override
-    public Collection<String> values()
-    {
-        if (_values == null)
-        {
-            _values = new ArrayList<>();
-            for (Enumeration<String> enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
-            {
-                String v = _bundle.getString(enumer.nextElement());
-                _values.add(v);
-            }
-        }
-        return _values;
-    }
-
-    @Override
-    public int size()
-    {
-        return values().size();
-    }
-
-    @Override
-    public boolean containsValue(Object value)
-    {
-        return values().contains(value);
-    }
-
-    @Override
-    public Set<Map.Entry<String, String>> entrySet()
-    {
-        Set<Map.Entry<String, String>> set = new HashSet<>();
-        for (Enumeration<String> enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
-        {
-            final String k = enumer.nextElement();
-            set.add(new Map.Entry<String, String>()
-            {
-                @Override
-                public String getKey()
-                {
-                    return k;
-                }
-
-                @Override
-                public String getValue()
-                {
-                    return (String) _bundle.getObject(k);
-                }
-
-                @Override
-                public String setValue(String value)
-                {
-                    throw new UnsupportedOperationException();
-                }
-            });
-        }
-
-        return set;
-    }
-
-    @Override
-    public Set<String> keySet()
-    {
-        Set<String> set = new HashSet<>();
-        for (Enumeration<String> enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
-        {
-            set.add(enumer.nextElement());
-        }
-        return set;
-    }
-
-    @Override
-    public String remove(Object key)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void putAll(Map<? extends String, ? extends String> t)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String put(String key, String value)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void clear()
-    {
-        throw new UnsupportedOperationException();
-    }
+/*
+ * 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 jakarta.faces.component;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+class _BundleMap implements Map<String, String>
+{
+    private ResourceBundle _bundle;
+    private List<String> _values;
+
+    public _BundleMap(ResourceBundle bundle)
+    {
+        _bundle = bundle;
+    }
+
+    // Optimized methods
+    @Override
+    public String get(Object key)
+    {
+        try
+        {
+            return (String) _bundle.getObject(key.toString());
+        }
+        catch (Exception e)
+        {
+            return "???" + key + "???";
+        }
+    }
+
+    @Override
+    public boolean isEmpty()
+    {
+        return !_bundle.getKeys().hasMoreElements();
+    }
+
+    @Override
+    public boolean containsKey(Object key)
+    {
+        try
+        {
+            return _bundle.getObject(key.toString()) != null;
+        }
+        catch (MissingResourceException e)
+        {
+            return false;
+        }
+    }
+
+    // Unoptimized methods
+    @Override
+    public Collection<String> values()
+    {
+        if (_values == null)
+        {
+            _values = new ArrayList<>();
+            for (Enumeration<String> enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
+            {
+                String v = _bundle.getString(enumer.nextElement());
+                _values.add(v);
+            }
+        }
+        return _values;
+    }
+
+    @Override
+    public int size()
+    {
+        return values().size();
+    }
+
+    @Override
+    public boolean containsValue(Object value)
+    {
+        return values().contains(value);
+    }
+
+    @Override
+    public Set<Map.Entry<String, String>> entrySet()
+    {
+        Set<Map.Entry<String, String>> set = new HashSet<>();
+        for (Enumeration<String> enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
+        {
+            final String k = enumer.nextElement();
+            set.add(new Map.Entry<String, String>()
+            {
+                @Override
+                public String getKey()
+                {
+                    return k;
+                }
+
+                @Override
+                public String getValue()
+                {
+                    return (String) _bundle.getObject(k);
+                }
+
+                @Override
+                public String setValue(String value)
+                {
+                    throw new UnsupportedOperationException();
+                }
+            });
+        }
+
+        return set;
+    }
+
+    @Override
+    public Set<String> keySet()
+    {
+        Set<String> set = new HashSet<>();
+        for (Enumeration<String> enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
+        {
+            set.add(enumer.nextElement());
+        }
+        return set;
+    }
+
+    @Override
+    public String remove(Object key)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void putAll(Map<? extends String, ? extends String> t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String put(String key, String value)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }
 }
\ No newline at end of file
diff --git a/api/src/main/java/jakarta/faces/component/_EventListenerWrapper.java b/api/src/main/java/jakarta/faces/component/_EventListenerWrapper.java
index a9db26c..333e861 100644
--- a/api/src/main/java/jakarta/faces/component/_EventListenerWrapper.java
+++ b/api/src/main/java/jakarta/faces/component/_EventListenerWrapper.java
@@ -1,341 +1,341 @@
-/*
- * 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 jakarta.faces.component;
-
-import static jakarta.faces.component.UIComponent.getCurrentComponent;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.event.ComponentSystemEvent;
-import jakarta.faces.event.ComponentSystemEventListener;
-import jakarta.faces.event.SystemEvent;
-import jakarta.faces.event.SystemEventListener;
-import jakarta.faces.render.Renderer;
-import jakarta.faces.render.RendererWrapper;
-
-class _EventListenerWrapper implements SystemEventListener, PartialStateHolder
-{
-    static final int LISTENER_SAVE_STATE_HOLDER = 1;
-    static final int LISTENER_SAVE_PARTIAL_STATE_HOLDER = 2;
-    static final int LISTENER_TYPE_COMPONENT = 4;
-    static final int LISTENER_TYPE_RENDERER = 8;
-    static final int LISTENER_TYPE_OTHER = 16;
-    
-    private Class<?> componentClass;
-    private ComponentSystemEventListener listener;
-
-    private boolean _initialStateMarked;
-
-    private int listenerCapability;
-    private transient UIComponent _component;
-
-    public _EventListenerWrapper()
-    {
-        //need a no-arg constructor for state saving purposes
-        super();
-    }
-
-    /**
-     * Note we have two cases:
-     *
-     * 1. listener is an instance of UIComponent. In this case we cannot save and restore
-     *    it because we need to point to the real component, but we can assume the instance
-     *    is the same because UIComponent.subscribeToEvent says so. Also take into account
-     *    this case is the reason why we need a wrapper for UIComponent.subscribeToEvent
-     * 2. listener is an instance of Renderer. In this case we can assume the same renderer
-     *    used by the source component is the one used by the listener (ListenerFor). 
-     * 3. listener is an instance of ComponentSystemEventListener but not from UIComponent.
-     *    In this case, the instance could implement StateHolder, PartialStateHolder or do
-     *    implement anything, so we have to deal with that case as usual.
-     *
-     * @param component
-     * @param listener
-     */
-    public _EventListenerWrapper(UIComponent component, ComponentSystemEventListener listener)
-    {
-        assert component != null;
-        assert listener != null;
-
-        this.componentClass = component.getClass();
-        this.listener = listener;
-        this._component = component;
-        initListenerCapability();
-    }
-
-    private void initListenerCapability()
-    {
-        this.listenerCapability = 0;
-        if (this.listener instanceof UIComponent)
-        {
-            this.listenerCapability = LISTENER_TYPE_COMPONENT;
-        }
-        else if (this.listener instanceof Renderer)
-        {
-            this.listenerCapability = LISTENER_TYPE_RENDERER;
-        }
-        else
-        {
-            if (this.listener instanceof PartialStateHolder)
-            {
-                this.listenerCapability = LISTENER_TYPE_OTHER | LISTENER_SAVE_PARTIAL_STATE_HOLDER;
-            }
-            else if (this.listener instanceof StateHolder)
-            {
-                this.listenerCapability = LISTENER_TYPE_OTHER | LISTENER_SAVE_STATE_HOLDER;
-            }
-            else
-            {
-                this.listenerCapability = LISTENER_TYPE_OTHER;
-            }
-        }
-    }
-
-    @Override
-    public boolean equals(Object o)
-    {
-        if (o == this)
-        {
-            return true;
-        }
-        else if (o instanceof _EventListenerWrapper)
-        {
-            _EventListenerWrapper other = (_EventListenerWrapper) o;
-            return componentClass.equals(other.componentClass) && listener.equals(other.listener);
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return componentClass.hashCode() + listener.hashCode();
-    }
-
-    @Override
-    public boolean isListenerForSource(Object source)
-    {
-        // and its implementation of SystemEventListener.isListenerForSource(java.lang.Object) must return true
-        // if the instance class of this UIComponent is assignable from the argument to isListenerForSource.
-
-        return source.getClass().isAssignableFrom(componentClass);
-    }
-
-    public ComponentSystemEventListener getComponentSystemEventListener()
-    {
-        return listener;
-    }
-
-    @Override
-    public void processEvent(SystemEvent event)
-    {
-        // This inner class must call through to the argument componentListener in its implementation of
-        // SystemEventListener.processEvent(jakarta.faces.event.SystemEvent)
-        assert event instanceof ComponentSystemEvent;
-
-        listener.processEvent((ComponentSystemEvent) event);
-    }
-
-    @Override
-    public void clearInitialState()
-    {
-        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
-        {
-            ((PartialStateHolder) listener).clearInitialState();
-        }
-        _initialStateMarked = false;
-    }
-
-    @Override
-    public boolean initialStateMarked()
-    {
-        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
-        {
-            return ((PartialStateHolder) listener).initialStateMarked();
-        }
-        return _initialStateMarked;
-    }
-
-    @Override
-    public void markInitialState()
-    {
-        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
-        {
-            ((PartialStateHolder) listener).markInitialState();
-        }
-        _initialStateMarked = true;
-    }
-
-    @Override
-    public boolean isTransient()
-    {
-        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0 ||
-                (listenerCapability & LISTENER_SAVE_STATE_HOLDER) != 0)
-        {
-            return ((StateHolder) listener).isTransient();
-        }
-        return false;
-    }
-
-    @Override
-    public void restoreState(FacesContext context, Object state)
-    {
-        if (state == null)
-        {
-            return;
-        }
-        Object[] values = (Object[]) state;
-        componentClass = (Class) values[0];
-        if (values[1] instanceof _AttachedDeltaWrapper)
-        {
-            ((StateHolder) listener).restoreState(context,
-                    ((_AttachedDeltaWrapper) values[1]).getWrappedStateObject());
-        }
-        else
-        {
-            //Full restore
-            listenerCapability = (Integer) values[2];
-
-            _component = UIComponent.getCurrentComponent(context);
-            if ((listenerCapability & LISTENER_TYPE_COMPONENT) != 0)
-            {
-                listener = _component;
-            }
-            else if ((listenerCapability & LISTENER_TYPE_RENDERER) != 0)
-            {
-                Renderer renderer = _component.getRenderer(context);
-                Integer i = (Integer) values[1];
-                if (i != null && i >= 0)
-                {
-                    while (i > 0)
-                    {
-                        renderer = ((RendererWrapper) renderer).getWrapped();
-                        i--;
-                    }
-                }
-                listener = (ComponentSystemEventListener) renderer;
-            }
-            else
-            {
-                listener = (ComponentSystemEventListener)
-                        UIComponentBase.restoreAttachedState(context, values[1]);
-            }
-        }
-    }
-
-    @Override
-    public Object saveState(FacesContext context)
-    {
-        if (!initialStateMarked())
-        {
-            Object[] state = new Object[3];
-            state[0] = componentClass;
-            //If this is not a component or a renderer, save it calling UIComponent.saveAttachedState
-            if (!((listenerCapability & LISTENER_TYPE_COMPONENT) != 0 ||
-                    (listenerCapability & LISTENER_TYPE_RENDERER) != 0))
-            {
-                state[1] = UIComponentBase.saveAttachedState(context, listener);
-            }
-            else
-            {
-                if ( (listenerCapability & LISTENER_TYPE_RENDERER) != 0)
-                {
-                    UIComponent componentRef = _component != null ? _component : getCurrentComponent(context);
-                    Renderer renderer = componentRef.getRenderer(context);
-                    int i = 0;
-                    while (renderer != null && !renderer.getClass().equals(listener.getClass()))
-                    {
-                        if (renderer instanceof RendererWrapper)
-                        {
-                            renderer = ((RendererWrapper) renderer).getWrapped();
-                            i++;
-                        }
-                        else
-                        {
-                            renderer = null;
-                            i = -1;
-                        }
-                    }
-                    if (i != -1)
-                    {
-                        // Store the number so we can get the right wrapper to invoke the method.
-                        state[1] = i;
-                    }
-                    else
-                    {
-                        state[1] = null;
-                    }
-                }
-                else
-                {
-                    state[1] = null;
-                }
-            }
-            state[2] = (Integer) listenerCapability;
-            return state;
-        }
-        else
-        {
-            // If initialStateMarked() == true means two things:
-            // 1. PSS is being used
-            if ((listenerCapability & LISTENER_TYPE_COMPONENT) != 0)
-            {
-                return null;
-            }
-            else if ((listenerCapability & LISTENER_TYPE_RENDERER) != 0)
-            {
-                return null;
-            }
-            else
-            {
-                if ((listenerCapability & LISTENER_SAVE_STATE_HOLDER) != 0 ||
-                        (listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
-                {
-                    Object listenerSaved = ((StateHolder) listener).saveState(context);
-                    if (listenerSaved == null)
-                    {
-                        return null;
-                    }
-                    return new Object[] { componentClass,
-                                        new _AttachedDeltaWrapper(listener.getClass(), listenerSaved) };
-                }
-                else
-                {
-                    //This is not necessary, because the instance is considered serializable!
-                    return null;
-                }
-            }
-        }
-    }
-
-    @Override
-    public void setTransient(boolean newTransientValue)
-    {
-        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0 ||
-                (listenerCapability & LISTENER_SAVE_STATE_HOLDER) != 0)
-        {
-            ((StateHolder) listener).setTransient(newTransientValue);
-        }
-    }
-
-    public int getListenerCapability()
-    {
-        return listenerCapability;
-    }
+/*
+ * 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 jakarta.faces.component;
+
+import static jakarta.faces.component.UIComponent.getCurrentComponent;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.event.ComponentSystemEvent;
+import jakarta.faces.event.ComponentSystemEventListener;
+import jakarta.faces.event.SystemEvent;
+import jakarta.faces.event.SystemEventListener;
+import jakarta.faces.render.Renderer;
+import jakarta.faces.render.RendererWrapper;
+
+class _EventListenerWrapper implements SystemEventListener, PartialStateHolder
+{
+    static final int LISTENER_SAVE_STATE_HOLDER = 1;
+    static final int LISTENER_SAVE_PARTIAL_STATE_HOLDER = 2;
+    static final int LISTENER_TYPE_COMPONENT = 4;
+    static final int LISTENER_TYPE_RENDERER = 8;
+    static final int LISTENER_TYPE_OTHER = 16;
+    
+    private Class<?> componentClass;
+    private ComponentSystemEventListener listener;
+
+    private boolean _initialStateMarked;
+
+    private int listenerCapability;
+    private transient UIComponent _component;
+
+    public _EventListenerWrapper()
+    {
+        //need a no-arg constructor for state saving purposes
+        super();
+    }
+
+    /**
+     * Note we have two cases:
+     *
+     * 1. listener is an instance of UIComponent. In this case we cannot save and restore
+     *    it because we need to point to the real component, but we can assume the instance
+     *    is the same because UIComponent.subscribeToEvent says so. Also take into account
+     *    this case is the reason why we need a wrapper for UIComponent.subscribeToEvent
+     * 2. listener is an instance of Renderer. In this case we can assume the same renderer
+     *    used by the source component is the one used by the listener (ListenerFor). 
+     * 3. listener is an instance of ComponentSystemEventListener but not from UIComponent.
+     *    In this case, the instance could implement StateHolder, PartialStateHolder or do
+     *    implement anything, so we have to deal with that case as usual.
+     *
+     * @param component
+     * @param listener
+     */
+    public _EventListenerWrapper(UIComponent component, ComponentSystemEventListener listener)
+    {
+        assert component != null;
+        assert listener != null;
+
+        this.componentClass = component.getClass();
+        this.listener = listener;
+        this._component = component;
+        initListenerCapability();
+    }
+
+    private void initListenerCapability()
+    {
+        this.listenerCapability = 0;
+        if (this.listener instanceof UIComponent)
+        {
+            this.listenerCapability = LISTENER_TYPE_COMPONENT;
+        }
+        else if (this.listener instanceof Renderer)
+        {
+            this.listenerCapability = LISTENER_TYPE_RENDERER;
+        }
+        else
+        {
+            if (this.listener instanceof PartialStateHolder)
+            {
+                this.listenerCapability = LISTENER_TYPE_OTHER | LISTENER_SAVE_PARTIAL_STATE_HOLDER;
+            }
+            else if (this.listener instanceof StateHolder)
+            {
+                this.listenerCapability = LISTENER_TYPE_OTHER | LISTENER_SAVE_STATE_HOLDER;
+            }
+            else
+            {
+                this.listenerCapability = LISTENER_TYPE_OTHER;
+            }
+        }
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (o == this)
+        {
+            return true;
+        }
+        else if (o instanceof _EventListenerWrapper)
+        {
+            _EventListenerWrapper other = (_EventListenerWrapper) o;
+            return componentClass.equals(other.componentClass) && listener.equals(other.listener);
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return componentClass.hashCode() + listener.hashCode();
+    }
+
+    @Override
+    public boolean isListenerForSource(Object source)
+    {
+        // and its implementation of SystemEventListener.isListenerForSource(java.lang.Object) must return true
+        // if the instance class of this UIComponent is assignable from the argument to isListenerForSource.
+
+        return source.getClass().isAssignableFrom(componentClass);
+    }
+
+    public ComponentSystemEventListener getComponentSystemEventListener()
+    {
+        return listener;
+    }
+
+    @Override
+    public void processEvent(SystemEvent event)
+    {
+        // This inner class must call through to the argument componentListener in its implementation of
+        // SystemEventListener.processEvent(jakarta.faces.event.SystemEvent)
+        assert event instanceof ComponentSystemEvent;
+
+        listener.processEvent((ComponentSystemEvent) event);
+    }
+
+    @Override
+    public void clearInitialState()
+    {
+        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
+        {
+            ((PartialStateHolder) listener).clearInitialState();
+        }
+        _initialStateMarked = false;
+    }
+
+    @Override
+    public boolean initialStateMarked()
+    {
+        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
+        {
+            return ((PartialStateHolder) listener).initialStateMarked();
+        }
+        return _initialStateMarked;
+    }
+
+    @Override
+    public void markInitialState()
+    {
+        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
+        {
+            ((PartialStateHolder) listener).markInitialState();
+        }
+        _initialStateMarked = true;
+    }
+
+    @Override
+    public boolean isTransient()
+    {
+        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0 ||
+                (listenerCapability & LISTENER_SAVE_STATE_HOLDER) != 0)
+        {
+            return ((StateHolder) listener).isTransient();
+        }
+        return false;
+    }
+
+    @Override
+    public void restoreState(FacesContext context, Object state)
+    {
+        if (state == null)
+        {
+            return;
+        }
+        Object[] values = (Object[]) state;
+        componentClass = (Class) values[0];
+        if (values[1] instanceof _AttachedDeltaWrapper)
+        {
+            ((StateHolder) listener).restoreState(context,
+                    ((_AttachedDeltaWrapper) values[1]).getWrappedStateObject());
+        }
+        else
+        {
+            //Full restore
+            listenerCapability = (Integer) values[2];
+
+            _component = UIComponent.getCurrentComponent(context);
+            if ((listenerCapability & LISTENER_TYPE_COMPONENT) != 0)
+            {
+                listener = _component;
+            }
+            else if ((listenerCapability & LISTENER_TYPE_RENDERER) != 0)
+            {
+                Renderer renderer = _component.getRenderer(context);
+                Integer i = (Integer) values[1];
+                if (i != null && i >= 0)
+                {
+                    while (i > 0)
+                    {
+                        renderer = ((RendererWrapper) renderer).getWrapped();
+                        i--;
+                    }
+                }
+                listener = (ComponentSystemEventListener) renderer;
+            }
+            else
+            {
+                listener = (ComponentSystemEventListener)
+                        UIComponentBase.restoreAttachedState(context, values[1]);
+            }
+        }
+    }
+
+    @Override
+    public Object saveState(FacesContext context)
+    {
+        if (!initialStateMarked())
+        {
+            Object[] state = new Object[3];
+            state[0] = componentClass;
+            //If this is not a component or a renderer, save it calling UIComponent.saveAttachedState
+            if (!((listenerCapability & LISTENER_TYPE_COMPONENT) != 0 ||
+                    (listenerCapability & LISTENER_TYPE_RENDERER) != 0))
+            {
+                state[1] = UIComponentBase.saveAttachedState(context, listener);
+            }
+            else
+            {
+                if ( (listenerCapability & LISTENER_TYPE_RENDERER) != 0)
+                {
+                    UIComponent componentRef = _component != null ? _component : getCurrentComponent(context);
+                    Renderer renderer = componentRef.getRenderer(context);
+                    int i = 0;
+                    while (renderer != null && !renderer.getClass().equals(listener.getClass()))
+                    {
+                        if (renderer instanceof RendererWrapper)
+                        {
+                            renderer = ((RendererWrapper) renderer).getWrapped();
+                            i++;
+                        }
+                        else
+                        {
+                            renderer = null;
+                            i = -1;
+                        }
+                    }
+                    if (i != -1)
+                    {
+                        // Store the number so we can get the right wrapper to invoke the method.
+                        state[1] = i;
+                    }
+                    else
+                    {
+                        state[1] = null;
+                    }
+                }
+                else
+                {
+                    state[1] = null;
+                }
+            }
+            state[2] = (Integer) listenerCapability;
+            return state;
+        }
+        else
+        {
+            // If initialStateMarked() == true means two things:
+            // 1. PSS is being used
+            if ((listenerCapability & LISTENER_TYPE_COMPONENT) != 0)
+            {
+                return null;
+            }
+            else if ((listenerCapability & LISTENER_TYPE_RENDERER) != 0)
+            {
+                return null;
+            }
+            else
+            {
+                if ((listenerCapability & LISTENER_SAVE_STATE_HOLDER) != 0 ||
+                        (listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0)
+                {
+                    Object listenerSaved = ((StateHolder) listener).saveState(context);
+                    if (listenerSaved == null)
+                    {
+                        return null;
+                    }
+                    return new Object[] { componentClass,
+                                        new _AttachedDeltaWrapper(listener.getClass(), listenerSaved) };
+                }
+                else
+                {
+                    //This is not necessary, because the instance is considered serializable!
+                    return null;
+                }
+            }
+        }
+    }
+
+    @Override
+    public void setTransient(boolean newTransientValue)
+    {
+        if ((listenerCapability & LISTENER_SAVE_PARTIAL_STATE_HOLDER) != 0 ||
+                (listenerCapability & LISTENER_SAVE_STATE_HOLDER) != 0)
+        {
+            ((StateHolder) listener).setTransient(newTransientValue);
+        }
+    }
+
+    public int getListenerCapability()
+    {
+        return listenerCapability;
+    }
 }
\ No newline at end of file
diff --git a/api/src/main/java/org/apache/myfaces/core/api/shared/AttributeUtils.java b/api/src/main/java/org/apache/myfaces/core/api/shared/AttributeUtils.java
index 364342a..9dcfdf2 100644
--- a/api/src/main/java/org/apache/myfaces/core/api/shared/AttributeUtils.java
+++ b/api/src/main/java/org/apache/myfaces/core/api/shared/AttributeUtils.java
@@ -1,64 +1,64 @@
-/*
- * 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.core.api.shared;
-
-import jakarta.faces.component.UIComponent;
-
-public class AttributeUtils
-{
-    public static boolean getBooleanAttribute(UIComponent component,
-            String attrName, boolean defaultValue)
-    {
-        Object value = component.getAttributes().get(attrName);
-        if (value == null)
-        {
-            return defaultValue;
-        }
-
-        if (value instanceof Boolean)
-        {
-            return (Boolean) value;
-        }
-
-        // If the value is a String, parse it.
-        // This makes the following code work: <tag attribute="true" />,
-        // otherwise you would have to write <tag attribute="#{true}" />.
-        return Boolean.valueOf(value.toString());
-    }
-
-    public static int getIntegerAttribute(UIComponent component,
-            String attrName, int defaultValue)
-    {
-        Object value = component.getAttributes().get(attrName);
-        if (value == null)
-        {
-            return defaultValue;
-        }
-
-        if (value instanceof Integer)
-        {
-            return (Integer) value;
-        }
-
-        // If the value is a String, parse it.
-        // This makes the following code work: <tag attribute="true" />,
-        // otherwise you would have to write <tag attribute="#{true}" />.
-        return Integer.valueOf(value.toString());
-    }
-}
+/*
+ * 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.core.api.shared;
+
+import jakarta.faces.component.UIComponent;
+
+public class AttributeUtils
+{
+    public static boolean getBooleanAttribute(UIComponent component,
+            String attrName, boolean defaultValue)
+    {
+        Object value = component.getAttributes().get(attrName);
+        if (value == null)
+        {
+            return defaultValue;
+        }
+
+        if (value instanceof Boolean)
+        {
+            return (Boolean) value;
+        }
+
+        // If the value is a String, parse it.
+        // This makes the following code work: <tag attribute="true" />,
+        // otherwise you would have to write <tag attribute="#{true}" />.
+        return Boolean.valueOf(value.toString());
+    }
+
+    public static int getIntegerAttribute(UIComponent component,
+            String attrName, int defaultValue)
+    {
+        Object value = component.getAttributes().get(attrName);
+        if (value == null)
+        {
+            return defaultValue;
+        }
+
+        if (value instanceof Integer)
+        {
+            return (Integer) value;
+        }
+
+        // If the value is a String, parse it.
+        // This makes the following code work: <tag attribute="true" />,
+        // otherwise you would have to write <tag attribute="#{true}" />.
+        return Integer.valueOf(value.toString());
+    }
+}
diff --git a/api/src/main/java/org/apache/myfaces/core/api/shared/SelectItemsUtil.java b/api/src/main/java/org/apache/myfaces/core/api/shared/SelectItemsUtil.java
index 15e7a58..2b71c85 100644
--- a/api/src/main/java/org/apache/myfaces/core/api/shared/SelectItemsUtil.java
+++ b/api/src/main/java/org/apache/myfaces/core/api/shared/SelectItemsUtil.java
@@ -1,300 +1,300 @@
-/*
- * 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.core.api.shared;
-
-import jakarta.faces.component.UIComponent;
-import jakarta.faces.component.UISelectItem;
-import jakarta.faces.component.UISelectItems;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.convert.Converter;
-import jakarta.faces.model.SelectItem;
-import jakarta.faces.model.SelectItemGroup;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-import org.apache.myfaces.core.api.shared.lang.ClassUtils;
-import org.apache.myfaces.core.api.shared.lang.CollectionUtils;
-
-public class SelectItemsUtil
-{
-    public static final String ATTR_ITEM_VALUE = "itemValue";
-    public static final String ATTR_ITEM_LABEL = "itemLabel";
-    public static final String ATTR_ITEM_DESCRIPTION = "itemDescription";
-    public static final String ATTR_ITEM_DISABLED = "itemDisabled";
-    public static final String ATTR_ITEM_LABEL_ESCAPED = "itemLabelEscaped";
-    public static final String ATTR_NO_SELECTION_VALUE = "noSelectionValue";
-    public static final String ATTR_VAR = "var";
-    
-    public static <S extends SelectItem> S createSelectItem(UISelectItem uiSelectItem, Supplier<S> supplier)
-    {
-        Object value = uiSelectItem.getItemValue();
- 
-        String label = uiSelectItem.getItemLabel();
-        if (label == null && value != null)
-        {
-            label = value.toString();
-        }
-
-        S selectItem = supplier.get();
-        selectItem.setValue(value);
-        selectItem.setLabel(label);
-        selectItem.setDescription(uiSelectItem.getItemDescription());
-        selectItem.setDisabled(uiSelectItem.isItemDisabled());
-        selectItem.setEscape(uiSelectItem.isItemEscaped());
-        selectItem.setNoSelectionOption(uiSelectItem.isNoSelectionOption());
-        
-        return selectItem;
-    }
-    
-    public static <S extends SelectItem> S createSelectItem(UIComponent component, Object value, Supplier<S> supplier)
-    {
-        // check new params of SelectItems (since 2.0): itemValue, itemLabel, itemDescription,...
-        // Note that according to the spec UISelectItems does not provide Getter and Setter 
-        // methods for this values, so we have to use the attribute map
-        Map<String, Object> attributes = component.getAttributes();
-
-        // check the itemValue attribute
-        Object itemValue = getItemValue(attributes, value);
-
-        // Spec: When iterating over the select items, toString() 
-        // must be called on the string rendered attribute values
-        Object itemLabel = attributes.get(ATTR_ITEM_LABEL);
-        if (itemLabel == null)
-        {
-            if (itemValue != null)
-            {
-                itemLabel = itemValue.toString();
-            }
-        }
-        else
-        {
-            itemLabel = itemLabel.toString();
-        }
-
-        Object itemDescription = attributes.get(ATTR_ITEM_DESCRIPTION);
-        if (itemDescription != null)
-        {
-            itemDescription = itemDescription.toString();
-        }
-
-        Boolean itemDisabled = AttributeUtils.getBooleanAttribute(component,
-                ATTR_ITEM_DISABLED, false);
-        Boolean itemLabelEscaped = AttributeUtils.getBooleanAttribute(component,
-                ATTR_ITEM_LABEL_ESCAPED, true);
-        Object noSelectionValue = attributes.get(ATTR_NO_SELECTION_VALUE);
-
-        S selectItem = supplier.get();
-        selectItem.setValue(itemValue);
-        selectItem.setLabel((String) itemLabel);
-        selectItem.setDescription((String) itemDescription);
-        selectItem.setDisabled(itemDisabled);
-        selectItem.setEscape(itemLabelEscaped);
-        selectItem.setNoSelectionOption(Objects.equals(itemValue, noSelectionValue));
-
-        return selectItem;
-    }
-
-    public static List<SelectItem> collectSelectItems(FacesContext context, UIComponent component)
-    {
-        List<SelectItem> items = new ArrayList<>();
-
-        for (int i = 0; i < component.getChildCount(); i++)
-        {
-            UIComponent child = component.getChildren().get(i);
-            if (child instanceof UISelectItems)
-            {
-                UISelectItems uiSelectItems = (UISelectItems) child;
-                createSelectItems(context, uiSelectItems, uiSelectItems.getValue(), SelectItem::new, items::add);
-            }
-            else if (child instanceof UISelectItem)
-            {
-                items.add(createSelectItem(child, null, SelectItem::new));
-            }
-        }
-        return items;
-    }
-    
-    public static <S extends SelectItem> void createSelectItems(FacesContext context, UISelectItems component,
-            Object values, Supplier<S> supplier, Consumer<S> callback)
-    {
-        Map<String, Object> attributes = component.getAttributes();
-        Object varObject = attributes.get(ATTR_VAR);
-        String var = varObject != null ? (String) varObject : "item";
- 
-        CollectionUtils.forEach(values, value ->
-        {
-            Object oldValue = context.getExternalContext().getRequestMap().put(var, value);
-            
-            callback.accept(
-                    createSelectItem(component, getItemValue(attributes, value), supplier));
-
-            if (oldValue != null)
-            {
-                context.getExternalContext().getRequestMap().put(var, oldValue);
-            }
-            else
-            {
-                context.getExternalContext().getRequestMap().remove(var);
-            }
-        });
-    }
-    
-    private static Object getItemValue(Map<String, Object> attributes, Object defaultValue)
-    {
-        Object itemValue = attributes.get(ATTR_ITEM_VALUE);
-        return itemValue != null || attributes.containsKey(ATTR_ITEM_VALUE) ? itemValue : defaultValue;
-    }
-    
-    /**
-     * @param context the faces context
-     * @param uiComponent the component instance
-     * @param value the value to check
-     * @param converter a converter instance
-     * @param iterator contains instances of SelectItem
-     * @return if the value of a selectitem is equal to the given value
-     */
-    public static boolean matchValue(FacesContext context,
-            UIComponent uiComponent, Object value,
-            Iterator<SelectItem> iterator, Converter converter)
-    {
-        while (iterator.hasNext())
-        {
-            SelectItem item = iterator.next();
-            if (item instanceof SelectItemGroup)
-            {
-                SelectItemGroup itemgroup = (SelectItemGroup) item;
-                SelectItem[] selectItems = itemgroup.getSelectItems();
-                if (selectItems != null
-                        && selectItems.length > 0
-                        && matchValue(context, uiComponent, value, Arrays.asList(selectItems).iterator(), converter))
-                {
-                    return true;
-                }
-            }
-            else
-            {
-                Object itemValue = _convertOrCoerceValue(context, uiComponent, value, item, converter);
-                if (value == itemValue || value.equals(itemValue))
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * @param context the faces context
-     * @param uiComponent the component instance
-     * @param value the value to check
-     * @param converter 
-     * @param iterator contains instances of SelectItem
-     * @return if the value is a SelectItem of selectItemsIter, on which noSelectionOption is true
-     */
-    public static boolean isNoSelectionOption(FacesContext context,
-            UIComponent uiComponent, Object value,
-            Iterator<SelectItem> iterator, Converter converter)
-    {
-        while (iterator.hasNext())
-        {
-            SelectItem item = iterator.next();
-            if (item instanceof SelectItemGroup)
-            {
-                SelectItemGroup itemgroup = (SelectItemGroup) item;
-                SelectItem[] selectItems = itemgroup.getSelectItems();
-                if (selectItems != null
-                        && selectItems.length > 0
-                        && isNoSelectionOption(context, uiComponent, value, Arrays.asList(selectItems).iterator(),
-                                converter))
-                {
-                    return true;
-                }
-            }
-            else if (item.isNoSelectionOption())
-            {
-                Object itemValue = _convertOrCoerceValue(context, uiComponent, value, item, converter);
-                if (value == itemValue || value.equals(itemValue))
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * If converter is available and selectItem.value is String uses getAsObject,
-     * otherwise uses EL type coertion and return result.
-     */
-    private static Object _convertOrCoerceValue(FacesContext facesContext,
-            UIComponent uiComponent, Object value, SelectItem selectItem, Converter converter)
-    {
-        Object itemValue = selectItem.getValue();
-        if (converter != null && itemValue instanceof String)
-        {
-            itemValue = converter.getAsObject(facesContext, uiComponent, (String) itemValue);
-        }
-        else
-        {
-            // The javadoc of UISelectOne/UISelectMany says : 
-            // "... Before comparing each option, coerce the option value type
-            //  to the type of this component's value following the 
-            // Expression Language coercion rules ..."
-            // If the coercion fails, just return the value without coerce,
-            // because it could be still valid the comparison for that value.
-            // and swallow the exception, because its information is no relevant
-            // on this context.
-            try
-            {
-                if (value instanceof java.lang.Enum)
-                {
-                    // Values from an enum are a special case. There is one syntax were the
-                    // particular enumeration is extended using something like
-                    // SOMEVALUE { ... }, usually to override toString() method. In this case,
-                    // value.getClass is not the target enum class, so we need to get the 
-                    // right one from super class.
-                    Class targetClass = value.getClass();
-                    if (targetClass != null && !targetClass.isEnum())
-                    {
-                        targetClass = targetClass.getSuperclass();
-                    }
-                    itemValue = ClassUtils.convertToTypeNoLogging(facesContext, itemValue, targetClass);
-                }
-                else
-                {
-                    itemValue = ClassUtils.convertToTypeNoLogging(facesContext, itemValue, value.getClass());
-                }
-            }
-            catch (IllegalArgumentException e)
-            {
-
-            }
-            catch (Exception e)
-            {
-
-            }
-        }
-        return itemValue;
-    }
-}
+/*
+ * 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.core.api.shared;
+
+import jakarta.faces.component.UIComponent;
+import jakarta.faces.component.UISelectItem;
+import jakarta.faces.component.UISelectItems;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.convert.Converter;
+import jakarta.faces.model.SelectItem;
+import jakarta.faces.model.SelectItemGroup;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import org.apache.myfaces.core.api.shared.lang.ClassUtils;
+import org.apache.myfaces.core.api.shared.lang.CollectionUtils;
+
+public class SelectItemsUtil
+{
+    public static final String ATTR_ITEM_VALUE = "itemValue";
+    public static final String ATTR_ITEM_LABEL = "itemLabel";
+    public static final String ATTR_ITEM_DESCRIPTION = "itemDescription";
+    public static final String ATTR_ITEM_DISABLED = "itemDisabled";
+    public static final String ATTR_ITEM_LABEL_ESCAPED = "itemLabelEscaped";
+    public static final String ATTR_NO_SELECTION_VALUE = "noSelectionValue";
+    public static final String ATTR_VAR = "var";
+    
+    public static <S extends SelectItem> S createSelectItem(UISelectItem uiSelectItem, Supplier<S> supplier)
+    {
+        Object value = uiSelectItem.getItemValue();
+ 
+        String label = uiSelectItem.getItemLabel();
+        if (label == null && value != null)
+        {
+            label = value.toString();
+        }
+
+        S selectItem = supplier.get();
+        selectItem.setValue(value);
+        selectItem.setLabel(label);
+        selectItem.setDescription(uiSelectItem.getItemDescription());
+        selectItem.setDisabled(uiSelectItem.isItemDisabled());
+        selectItem.setEscape(uiSelectItem.isItemEscaped());
+        selectItem.setNoSelectionOption(uiSelectItem.isNoSelectionOption());
+        
+        return selectItem;
+    }
+    
+    public static <S extends SelectItem> S createSelectItem(UIComponent component, Object value, Supplier<S> supplier)
+    {
+        // check new params of SelectItems (since 2.0): itemValue, itemLabel, itemDescription,...
+        // Note that according to the spec UISelectItems does not provide Getter and Setter 
+        // methods for this values, so we have to use the attribute map
+        Map<String, Object> attributes = component.getAttributes();
+
+        // check the itemValue attribute
+        Object itemValue = getItemValue(attributes, value);
+
+        // Spec: When iterating over the select items, toString() 
+        // must be called on the string rendered attribute values
+        Object itemLabel = attributes.get(ATTR_ITEM_LABEL);
+        if (itemLabel == null)
+        {
+            if (itemValue != null)
+            {
+                itemLabel = itemValue.toString();
+            }
+        }
+        else
+        {
+            itemLabel = itemLabel.toString();
+        }
+
+        Object itemDescription = attributes.get(ATTR_ITEM_DESCRIPTION);
+        if (itemDescription != null)
+        {
+            itemDescription = itemDescription.toString();
+        }
+
+        Boolean itemDisabled = AttributeUtils.getBooleanAttribute(component,
+                ATTR_ITEM_DISABLED, false);
+        Boolean itemLabelEscaped = AttributeUtils.getBooleanAttribute(component,
+                ATTR_ITEM_LABEL_ESCAPED, true);
+        Object noSelectionValue = attributes.get(ATTR_NO_SELECTION_VALUE);
+
+        S selectItem = supplier.get();
+        selectItem.setValue(itemValue);
+        selectItem.setLabel((String) itemLabel);
+        selectItem.setDescription((String) itemDescription);
+        selectItem.setDisabled(itemDisabled);
+        selectItem.setEscape(itemLabelEscaped);
+        selectItem.setNoSelectionOption(Objects.equals(itemValue, noSelectionValue));
+
+        return selectItem;
+    }
+
+    public static List<SelectItem> collectSelectItems(FacesContext context, UIComponent component)
+    {
+        List<SelectItem> items = new ArrayList<>();
+
+        for (int i = 0; i < component.getChildCount(); i++)
+        {
+            UIComponent child = component.getChildren().get(i);
+            if (child instanceof UISelectItems)
+            {
+                UISelectItems uiSelectItems = (UISelectItems) child;
+                createSelectItems(context, uiSelectItems, uiSelectItems.getValue(), SelectItem::new, items::add);
+            }
+            else if (child instanceof UISelectItem)
+            {
+                items.add(createSelectItem(child, null, SelectItem::new));
+            }
+        }
+        return items;
+    }
+    
+    public static <S extends SelectItem> void createSelectItems(FacesContext context, UISelectItems component,
+            Object values, Supplier<S> supplier, Consumer<S> callback)
+    {
+        Map<String, Object> attributes = component.getAttributes();
+        Object varObject = attributes.get(ATTR_VAR);
+        String var = varObject != null ? (String) varObject : "item";
+ 
+        CollectionUtils.forEach(values, value ->
+        {
+            Object oldValue = context.getExternalContext().getRequestMap().put(var, value);
+            
+            callback.accept(
+                    createSelectItem(component, getItemValue(attributes, value), supplier));
+
+            if (oldValue != null)
+            {
+                context.getExternalContext().getRequestMap().put(var, oldValue);
+            }
+            else
+            {
+                context.getExternalContext().getRequestMap().remove(var);
+            }
+        });
+    }
+    
+    private static Object getItemValue(Map<String, Object> attributes, Object defaultValue)
+    {
+        Object itemValue = attributes.get(ATTR_ITEM_VALUE);
+        return itemValue != null || attributes.containsKey(ATTR_ITEM_VALUE) ? itemValue : defaultValue;
+    }
+    
+    /**
+     * @param context the faces context
+     * @param uiComponent the component instance
+     * @param value the value to check
+     * @param converter a converter instance
+     * @param iterator contains instances of SelectItem
+     * @return if the value of a selectitem is equal to the given value
+     */
+    public static boolean matchValue(FacesContext context,
+            UIComponent uiComponent, Object value,
+            Iterator<SelectItem> iterator, Converter converter)
+    {
+        while (iterator.hasNext())
+        {
+            SelectItem item = iterator.next();
+            if (item instanceof SelectItemGroup)
+            {
+                SelectItemGroup itemgroup = (SelectItemGroup) item;
+                SelectItem[] selectItems = itemgroup.getSelectItems();
+                if (selectItems != null
+                        && selectItems.length > 0
+                        && matchValue(context, uiComponent, value, Arrays.asList(selectItems).iterator(), converter))
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                Object itemValue = _convertOrCoerceValue(context, uiComponent, value, item, converter);
+                if (value == itemValue || value.equals(itemValue))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * @param context the faces context
+     * @param uiComponent the component instance
+     * @param value the value to check
+     * @param converter 
+     * @param iterator contains instances of SelectItem
+     * @return if the value is a SelectItem of selectItemsIter, on which noSelectionOption is true
+     */
+    public static boolean isNoSelectionOption(FacesContext context,
+            UIComponent uiComponent, Object value,
+            Iterator<SelectItem> iterator, Converter converter)
+    {
+        while (iterator.hasNext())
+        {
+            SelectItem item = iterator.next();
+            if (item instanceof SelectItemGroup)
+            {
+                SelectItemGroup itemgroup = (SelectItemGroup) item;
+                SelectItem[] selectItems = itemgroup.getSelectItems();
+                if (selectItems != null
+                        && selectItems.length > 0
+                        && isNoSelectionOption(context, uiComponent, value, Arrays.asList(selectItems).iterator(),
+                                converter))
+                {
+                    return true;
+                }
+            }
+            else if (item.isNoSelectionOption())
+            {
+                Object itemValue = _convertOrCoerceValue(context, uiComponent, value, item, converter);
+                if (value == itemValue || value.equals(itemValue))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * If converter is available and selectItem.value is String uses getAsObject,
+     * otherwise uses EL type coertion and return result.
+     */
+    private static Object _convertOrCoerceValue(FacesContext facesContext,
+            UIComponent uiComponent, Object value, SelectItem selectItem, Converter converter)
+    {
+        Object itemValue = selectItem.getValue();
+        if (converter != null && itemValue instanceof String)
+        {
+            itemValue = converter.getAsObject(facesContext, uiComponent, (String) itemValue);
+        }
+        else
+        {
+            // The javadoc of UISelectOne/UISelectMany says : 
+            // "... Before comparing each option, coerce the option value type
+            //  to the type of this component's value following the 
+            // Expression Language coercion rules ..."
+            // If the coercion fails, just return the value without coerce,
+            // because it could be still valid the comparison for that value.
+            // and swallow the exception, because its information is no relevant
+            // on this context.
+            try
+            {
+                if (value instanceof java.lang.Enum)
+                {
+                    // Values from an enum are a special case. There is one syntax were the
+                    // particular enumeration is extended using something like
+                    // SOMEVALUE { ... }, usually to override toString() method. In this case,
+                    // value.getClass is not the target enum class, so we need to get the 
+                    // right one from super class.
+                    Class targetClass = value.getClass();
+                    if (targetClass != null && !targetClass.isEnum())
+                    {
+                        targetClass = targetClass.getSuperclass();
+                    }
+                    itemValue = ClassUtils.convertToTypeNoLogging(facesContext, itemValue, targetClass);
+                }
+                else
+                {
+                    itemValue = ClassUtils.convertToTypeNoLogging(facesContext, itemValue, value.getClass());
+                }
+            }
+            catch (IllegalArgumentException e)
+            {
+
+            }
+            catch (Exception e)
+            {
+
+            }
+        }
+        return itemValue;
+    }
+}
diff --git a/api/src/main/java/org/apache/myfaces/core/api/shared/lang/CollectionUtils.java b/api/src/main/java/org/apache/myfaces/core/api/shared/lang/CollectionUtils.java
index 57ec6a0..9c608f1 100644
--- a/api/src/main/java/org/apache/myfaces/core/api/shared/lang/CollectionUtils.java
+++ b/api/src/main/java/org/apache/myfaces/core/api/shared/lang/CollectionUtils.java
@@ -1,74 +1,74 @@
-/*
- * 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.core.api.shared.lang;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-
-public class CollectionUtils
-{
-    public static void forEach(Object value, Consumer<Object> callback)
-    {
-        if (value != null && value.getClass().isArray())
-        {
-            int length = Array.getLength(value);
-            for (int i = 0; i < length; i++)
-            {
-                callback.accept(Array.get(value, i));
-            }
-        }
-        else if (value instanceof ArrayList)
-        {
-            ArrayList<?> arrayList = (ArrayList) value;
-            for (int i = 0; i < arrayList.size(); i++)
-            {
-                callback.accept(arrayList.get(i));
-            }
-        }
-        else if (value instanceof Iterable)
-        {
-            // value is Iterable --> Collection, DataModel,...
-            Iterator<?> iterator = ((Iterable<?>) value).iterator();
-            while (iterator.hasNext())
-            {
-                callback.accept(iterator.next());
-            }
-        }
-        else if (value instanceof Map)
-        {
-            Map<Object, Object> map = ((Map<Object, Object>) value);
-            for (Map.Entry<Object, Object> entry : map.entrySet())
-            {
-                callback.accept(entry);
-            }
-        }
-        else if (value instanceof Stream)
-        {
-            ((Stream<?>) value).forEach(callback);
-        }
-        else
-        {
-            callback.accept(value);
-        }
-    }
-}
+/*
+ * 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.core.api.shared.lang;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+
+public class CollectionUtils
+{
+    public static void forEach(Object value, Consumer<Object> callback)
+    {
+        if (value != null && value.getClass().isArray())
+        {
+            int length = Array.getLength(value);
+            for (int i = 0; i < length; i++)
+            {
+                callback.accept(Array.get(value, i));
+            }
+        }
+        else if (value instanceof ArrayList)
+        {
+            ArrayList<?> arrayList = (ArrayList) value;
+            for (int i = 0; i < arrayList.size(); i++)
+            {
+                callback.accept(arrayList.get(i));
+            }
+        }
+        else if (value instanceof Iterable)
+        {
+            // value is Iterable --> Collection, DataModel,...
+            Iterator<?> iterator = ((Iterable<?>) value).iterator();
+            while (iterator.hasNext())
+            {
+                callback.accept(iterator.next());
+            }
+        }
+        else if (value instanceof Map)
+        {
+            Map<Object, Object> map = ((Map<Object, Object>) value);
+            for (Map.Entry<Object, Object> entry : map.entrySet())
+            {
+                callback.accept(entry);
+            }
+        }
+        else if (value instanceof Stream)
+        {
+            ((Stream<?>) value).forEach(callback);
+        }
+        else
+        {
+            callback.accept(value);
+        }
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java b/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
index 8eababb..141d4a8 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
@@ -1,302 +1,302 @@
-/*
- * 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.application.viewstate;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-import jakarta.faces.context.FacesContext;
-import java.util.function.Consumer;
-import org.apache.myfaces.cdi.view.ViewScopeContext;
-import org.apache.myfaces.config.MyfacesConfig;
-import org.apache.myfaces.util.lang.LRULinkedHashMap;
-
-/**
- *
- */
-class SerializedViewCollection implements Serializable
-{
-    private static final Logger log = Logger.getLogger(SerializedViewCollection.class.getName());
-
-    private static final Object[] EMPTY_STATES = new Object[]{null, null};
-
-    private static final long serialVersionUID = -3734849062185115847L;
-
-    private final List<SerializedViewKey> _keys = new ArrayList<>(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION_DEFAULT);
-    private final Map<SerializedViewKey, Object> _serializedViews = new HashMap<>();
-
-    /**
-     * The viewScopeIds can be shared between multiple entries of the same
-     * view. To store it into session, the best is use two maps, one to 
-     * associate the view key with the view scope id and other to keep track 
-     * of the number of times the id is used. In that way it is possible to
-     * know when a view scope id has been discarded and destroy the view scope
-     * in the right time.
-     */
-    private HashMap<SerializedViewKey, String> _viewScopeIds = null;
-    private HashMap<String, Integer> _viewScopeIdCounts = null;
-
-    private final Map<SerializedViewKey, SerializedViewKey> _precedence = new HashMap<>();
-    private Map<String, SerializedViewKey> _lastWindowKeys = null;
-
-    public void put(FacesContext context, Object state, SerializedViewKey key, SerializedViewKey previousRestoredKey)
-    {
-        put(context, state, key, previousRestoredKey, null,
-                (oldViewScopeId) -> ViewScopeContext.destroyAll(context, oldViewScopeId));
-    }
-    
-    public synchronized void put(FacesContext context, Object state, 
-        SerializedViewKey key, SerializedViewKey previousRestoredKey, String viewScopeId)
-    {
-        put(context, state, key, previousRestoredKey, viewScopeId,
-            (oldViewScopeId) -> ViewScopeContext.destroyAll(context, oldViewScopeId));
-    }
-
-    public synchronized void put(FacesContext context, Object state, 
-        SerializedViewKey key, SerializedViewKey previousRestoredKey, String viewScopeId,
-        Consumer<String> destroyCallback)
-    {
-        if (state == null)
-        {
-            state = EMPTY_STATES;
-        }
-        else if (state instanceof Object[] &&
-            ((Object[])state).length == 2 &&
-            ((Object[])state)[0] == null &&
-            ((Object[])state)[1] == null)
-        {
-            // The generated state can be considered zero, set it as null
-            // into the map.
-            state = null;
-        }
-
-        if (_serializedViews.containsKey(key))
-        {
-            // Update the state, the viewScopeId does not change.
-            _serializedViews.put(key, state);
-            // Make sure the view is at the end of the discard queue
-            while (_keys.remove(key))
-            {
-                // do nothing
-            }
-            _keys.add(key);
-            return;
-        }
-
-        Integer maxCount = getNumberOfSequentialViewsInSession(context);
-        if (maxCount != null)
-        {
-            if (previousRestoredKey != null)
-            {
-                if (!_serializedViews.isEmpty())
-                {
-                    _precedence.put((SerializedViewKey) key, previousRestoredKey);
-                }
-                else
-                {
-                    // Note when the session is invalidated, _serializedViews map is empty,
-                    // but we could have a not null previousRestoredKey (the last one before
-                    // invalidate the session), so we need to check that condition before
-                    // set the precence. In that way, we ensure the precedence map will always
-                    // have valid keys.
-                    previousRestoredKey = null;
-                }
-            }
-        }
-        _serializedViews.put(key, state);
-        
-        if (viewScopeId != null)
-        {
-            if (_viewScopeIds == null)
-            {
-                _viewScopeIds = new HashMap<>();
-            }
-            _viewScopeIds.put(key, viewScopeId);
-            if (_viewScopeIdCounts == null)
-            {
-                _viewScopeIdCounts = new HashMap<>();
-            }
-            Integer vscount = _viewScopeIdCounts.get(viewScopeId);
-            vscount = (vscount == null) ? 1 : vscount + 1;
-            _viewScopeIdCounts.put(viewScopeId, vscount);
-        }
-
-        while (_keys.remove(key))
-        {
-            // do nothing
-        }
-        _keys.add(key);
-
-        if (previousRestoredKey != null && maxCount != null && maxCount > 0)
-        {
-            int count = 0;
-            SerializedViewKey previousKey = (SerializedViewKey) key;
-            do
-            {
-                previousKey = _precedence.get(previousKey);
-                count++;
-            }
-            while (previousKey != null && count < maxCount);
-
-            if (previousKey != null)
-            {
-                SerializedViewKey keyToRemove = (SerializedViewKey) previousKey;
-                // In theory it should be only one key but just to be sure
-                // do it in a loop, but in this case if cache old views is on,
-                // put on that map.
-                do
-                {
-                    while (_keys.remove(keyToRemove))
-                    {
-                        // do nothing
-                    }
-
-                    _serializedViews.remove(keyToRemove);
-                    
-                    if (_viewScopeIds != null)
-                    {
-                        String oldViewScopeId = _viewScopeIds.remove(keyToRemove);
-                        if (oldViewScopeId != null)
-                        {
-                            Integer vscount = _viewScopeIdCounts.get(oldViewScopeId);
-                            vscount = vscount - 1;
-                            if (vscount < 1)
-                            {
-                                _viewScopeIdCounts.remove(oldViewScopeId);
-                                destroyCallback.accept(oldViewScopeId);
-                            }
-                            else
-                            {
-                                _viewScopeIdCounts.put(oldViewScopeId, vscount);
-                            }
-                        }
-                    }
-
-                    keyToRemove = _precedence.remove(keyToRemove);
-                }
-                while (keyToRemove != null);
-            }
-        }
-        int views = getNumberOfViewsInSession(context);
-        while (_keys.size() > views)
-        {
-            key = _keys.remove(0);
-            if (maxCount != null && maxCount > 0)
-            {
-                SerializedViewKey keyToRemove = (SerializedViewKey) key;
-                // Note in this case the key to delete is the oldest one,
-                // so it could be at least one precedence, but to be safe
-                // do it with a loop.
-                do
-                {
-                    keyToRemove = _precedence.remove(keyToRemove);
-                }
-                while (keyToRemove != null);
-            }
-
-            _serializedViews.remove(key);
-            
-            if (_viewScopeIds != null)
-            {
-                String oldViewScopeId = _viewScopeIds.remove(key);
-                if (oldViewScopeId != null)
-                {
-                    Integer vscount = _viewScopeIdCounts.get(oldViewScopeId);
-                    vscount = vscount - 1;
-                    if (vscount < 1)
-                    {
-                        _viewScopeIdCounts.remove(oldViewScopeId);
-                        destroyCallback.accept(oldViewScopeId);
-                    }
-                    else
-                    {
-                        _viewScopeIdCounts.put(oldViewScopeId, vscount);
-                    }
-                }
-            }
-        }
-    }
-
-    protected Integer getNumberOfSequentialViewsInSession(FacesContext context)
-    {
-        return MyfacesConfig.getCurrentInstance(context).getNumberOfSequentialViewsInSession();
-    }
-
-    /**
-     * Reads the amount (default = 20) of views to be stored in session.
-     * @see ServerSideStateCacheImpl#NUMBER_OF_VIEWS_IN_SESSION_PARAM
-     * @param context FacesContext for the current request, we are processing
-     * @return Number vf views stored in the session
-     */
-    protected int getNumberOfViewsInSession(FacesContext context)
-    {
-        return MyfacesConfig.getCurrentInstance(context).getNumberOfViewsInSession();
-    }
-
-    public synchronized void putLastWindowKey(FacesContext context, String id, SerializedViewKey key)
-    {
-        if (_lastWindowKeys == null)
-        {
-            Integer i = getNumberOfSequentialViewsInSession(context);
-            int j = getNumberOfViewsInSession(context);
-            if (i != null && i> 0)
-            {
-                _lastWindowKeys = new LRULinkedHashMap<>((j / i) + 1);
-            }
-            else
-            {
-                _lastWindowKeys = new LRULinkedHashMap(j + 1);
-            }
-        }
-        _lastWindowKeys.put(id, key);
-    }
-
-    public SerializedViewKey getLastWindowKey(FacesContext context, String id)
-    {
-        if (_lastWindowKeys != null)
-        {
-            return _lastWindowKeys.get(id);
-        }
-        return null;
-    }
-
-    public Object get(SerializedViewKey key)
-    {
-        Object value = _serializedViews.get(key);
-        if (value == null)
-        {
-            if (_serializedViews.containsKey(key))
-            {
-                return EMPTY_STATES;
-            }
-        }
-        else if (value instanceof Object[] &&
-            ((Object[])value).length == 2 &&
-            ((Object[])value)[0] == null &&
-            ((Object[])value)[1] == null)
-        {
-            // Remember inside the state map null is stored as an empty array.
-            return null;
-        }
-        return value;
-    }
-}
+/*
+ * 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.application.viewstate;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+import jakarta.faces.context.FacesContext;
+import java.util.function.Consumer;
+import org.apache.myfaces.cdi.view.ViewScopeContext;
+import org.apache.myfaces.config.MyfacesConfig;
+import org.apache.myfaces.util.lang.LRULinkedHashMap;
+
+/**
+ *
+ */
+class SerializedViewCollection implements Serializable
+{
+    private static final Logger log = Logger.getLogger(SerializedViewCollection.class.getName());
+
+    private static final Object[] EMPTY_STATES = new Object[]{null, null};
+
+    private static final long serialVersionUID = -3734849062185115847L;
+
+    private final List<SerializedViewKey> _keys = new ArrayList<>(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION_DEFAULT);
+    private final Map<SerializedViewKey, Object> _serializedViews = new HashMap<>();
+
+    /**
+     * The viewScopeIds can be shared between multiple entries of the same
+     * view. To store it into session, the best is use two maps, one to 
+     * associate the view key with the view scope id and other to keep track 
+     * of the number of times the id is used. In that way it is possible to
+     * know when a view scope id has been discarded and destroy the view scope
+     * in the right time.
+     */
+    private HashMap<SerializedViewKey, String> _viewScopeIds = null;
+    private HashMap<String, Integer> _viewScopeIdCounts = null;
+
+    private final Map<SerializedViewKey, SerializedViewKey> _precedence = new HashMap<>();
+    private Map<String, SerializedViewKey> _lastWindowKeys = null;
+
+    public void put(FacesContext context, Object state, SerializedViewKey key, SerializedViewKey previousRestoredKey)
+    {
+        put(context, state, key, previousRestoredKey, null,
+                (oldViewScopeId) -> ViewScopeContext.destroyAll(context, oldViewScopeId));
+    }
+    
+    public synchronized void put(FacesContext context, Object state, 
+        SerializedViewKey key, SerializedViewKey previousRestoredKey, String viewScopeId)
+    {
+        put(context, state, key, previousRestoredKey, viewScopeId,
+            (oldViewScopeId) -> ViewScopeContext.destroyAll(context, oldViewScopeId));
+    }
+
+    public synchronized void put(FacesContext context, Object state, 
+        SerializedViewKey key, SerializedViewKey previousRestoredKey, String viewScopeId,
+        Consumer<String> destroyCallback)
+    {
+        if (state == null)
+        {
+            state = EMPTY_STATES;
+        }
+        else if (state instanceof Object[] &&
+            ((Object[])state).length == 2 &&
+            ((Object[])state)[0] == null &&
+            ((Object[])state)[1] == null)
+        {
+            // The generated state can be considered zero, set it as null
+            // into the map.
+            state = null;
+        }
+
+        if (_serializedViews.containsKey(key))
+        {
+            // Update the state, the viewScopeId does not change.
+            _serializedViews.put(key, state);
+            // Make sure the view is at the end of the discard queue
+            while (_keys.remove(key))
+            {
+                // do nothing
+            }
+            _keys.add(key);
+            return;
+        }
+
+        Integer maxCount = getNumberOfSequentialViewsInSession(context);
+        if (maxCount != null)
+        {
+            if (previousRestoredKey != null)
+            {
+                if (!_serializedViews.isEmpty())
+                {
+                    _precedence.put((SerializedViewKey) key, previousRestoredKey);
+                }
+                else
+                {
+                    // Note when the session is invalidated, _serializedViews map is empty,
+                    // but we could have a not null previousRestoredKey (the last one before
+                    // invalidate the session), so we need to check that condition before
+                    // set the precence. In that way, we ensure the precedence map will always
+                    // have valid keys.
+                    previousRestoredKey = null;
+                }
+            }
+        }
+        _serializedViews.put(key, state);
+        
+        if (viewScopeId != null)
+        {
+            if (_viewScopeIds == null)
+            {
+                _viewScopeIds = new HashMap<>();
+            }
+            _viewScopeIds.put(key, viewScopeId);
+            if (_viewScopeIdCounts == null)
+            {
+                _viewScopeIdCounts = new HashMap<>();
+            }
+            Integer vscount = _viewScopeIdCounts.get(viewScopeId);
+            vscount = (vscount == null) ? 1 : vscount + 1;
+            _viewScopeIdCounts.put(viewScopeId, vscount);
+        }
+
+        while (_keys.remove(key))
+        {
+            // do nothing
+        }
+        _keys.add(key);
+
+        if (previousRestoredKey != null && maxCount != null && maxCount > 0)
+        {
+            int count = 0;
+            SerializedViewKey previousKey = (SerializedViewKey) key;
+            do
+            {
+                previousKey = _precedence.get(previousKey);
+                count++;
+            }
+            while (previousKey != null && count < maxCount);
+
+            if (previousKey != null)
+            {
+                SerializedViewKey keyToRemove = (SerializedViewKey) previousKey;
+                // In theory it should be only one key but just to be sure
+                // do it in a loop, but in this case if cache old views is on,
+                // put on that map.
+                do
+                {
+                    while (_keys.remove(keyToRemove))
+                    {
+                        // do nothing
+                    }
+
+                    _serializedViews.remove(keyToRemove);
+                    
+                    if (_viewScopeIds != null)
+                    {
+                        String oldViewScopeId = _viewScopeIds.remove(keyToRemove);
+                        if (oldViewScopeId != null)
+                        {
+                            Integer vscount = _viewScopeIdCounts.get(oldViewScopeId);
+                            vscount = vscount - 1;
+                            if (vscount < 1)
+                            {
+                                _viewScopeIdCounts.remove(oldViewScopeId);
+                                destroyCallback.accept(oldViewScopeId);
+                            }
+                            else
+                            {
+                                _viewScopeIdCounts.put(oldViewScopeId, vscount);
+                            }
+                        }
+                    }
+
+                    keyToRemove = _precedence.remove(keyToRemove);
+                }
+                while (keyToRemove != null);
+            }
+        }
+        int views = getNumberOfViewsInSession(context);
+        while (_keys.size() > views)
+        {
+            key = _keys.remove(0);
+            if (maxCount != null && maxCount > 0)
+            {
+                SerializedViewKey keyToRemove = (SerializedViewKey) key;
+                // Note in this case the key to delete is the oldest one,
+                // so it could be at least one precedence, but to be safe
+                // do it with a loop.
+                do
+                {
+                    keyToRemove = _precedence.remove(keyToRemove);
+                }
+                while (keyToRemove != null);
+            }
+
+            _serializedViews.remove(key);
+            
+            if (_viewScopeIds != null)
+            {
+                String oldViewScopeId = _viewScopeIds.remove(key);
+                if (oldViewScopeId != null)
+                {
+                    Integer vscount = _viewScopeIdCounts.get(oldViewScopeId);
+                    vscount = vscount - 1;
+                    if (vscount < 1)
+                    {
+                        _viewScopeIdCounts.remove(oldViewScopeId);
+                        destroyCallback.accept(oldViewScopeId);
+                    }
+                    else
+                    {
+                        _viewScopeIdCounts.put(oldViewScopeId, vscount);
+                    }
+                }
+            }
+        }
+    }
+
+    protected Integer getNumberOfSequentialViewsInSession(FacesContext context)
+    {
+        return MyfacesConfig.getCurrentInstance(context).getNumberOfSequentialViewsInSession();
+    }
+
+    /**
+     * Reads the amount (default = 20) of views to be stored in session.
+     * @see ServerSideStateCacheImpl#NUMBER_OF_VIEWS_IN_SESSION_PARAM
+     * @param context FacesContext for the current request, we are processing
+     * @return Number vf views stored in the session
+     */
+    protected int getNumberOfViewsInSession(FacesContext context)
+    {
+        return MyfacesConfig.getCurrentInstance(context).getNumberOfViewsInSession();
+    }
+
+    public synchronized void putLastWindowKey(FacesContext context, String id, SerializedViewKey key)
+    {
+        if (_lastWindowKeys == null)
+        {
+            Integer i = getNumberOfSequentialViewsInSession(context);
+            int j = getNumberOfViewsInSession(context);
+            if (i != null && i> 0)
+            {
+                _lastWindowKeys = new LRULinkedHashMap<>((j / i) + 1);
+            }
+            else
+            {
+                _lastWindowKeys = new LRULinkedHashMap(j + 1);
+            }
+        }
+        _lastWindowKeys.put(id, key);
+    }
+
+    public SerializedViewKey getLastWindowKey(FacesContext context, String id)
+    {
+        if (_lastWindowKeys != null)
+        {
+            return _lastWindowKeys.get(id);
+        }
+        return null;
+    }
+
+    public Object get(SerializedViewKey key)
+    {
+        Object value = _serializedViews.get(key);
+        if (value == null)
+        {
+            if (_serializedViews.containsKey(key))
+            {
+                return EMPTY_STATES;
+            }
+        }
+        else if (value instanceof Object[] &&
+            ((Object[])value).length == 2 &&
+            ((Object[])value)[0] == null &&
+            ((Object[])value)[1] == null)
+        {
+            // Remember inside the state map null is stored as an empty array.
+            return null;
+        }
+        return value;
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContext.java b/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContext.java
index 3540b84..23a93c5 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContext.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContext.java
@@ -1,175 +1,175 @@
-/*
- * 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.cdi.clientwindow;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import jakarta.enterprise.context.ContextNotActiveException;
-import jakarta.enterprise.context.spi.Context;
-import jakarta.enterprise.context.spi.Contextual;
-import jakarta.enterprise.context.spi.CreationalContext;
-import jakarta.enterprise.inject.Typed;
-import jakarta.enterprise.inject.spi.BeanManager;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.lifecycle.ClientWindow;
-import jakarta.faces.lifecycle.ClientWindowScoped;
-import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
-import org.apache.myfaces.cdi.util.ContextualStorage;
-
-/**
- * Minimal implementation of ClientWindowScope.
- */
-@Typed()
-public class ClientWindowScopeContext implements Context
-{
-    private BeanManager beanManager;
-    
-    public ClientWindowScopeContext(BeanManager beanManager)
-    {
-        this.beanManager = beanManager;
-    }
-
-    @Override
-    public Class<? extends Annotation> getScope()
-    {
-        return ClientWindowScoped.class;
-    }
-
-    @Override
-    public boolean isActive()
-    {
-        return isActive(FacesContext.getCurrentInstance());
-    }
-
-    public boolean isActive(FacesContext facesContext)
-    {
-        if (facesContext == null || facesContext.getExternalContext().getClientWindow() == null)
-        {
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public <T> T get(Contextual<T> bean)
-    {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-
-        checkActive(facesContext);
-
-        if (facesContext != null)
-        {
-            ContextualStorage storage = getStorageHolder(facesContext).getContextualStorage(
-                    getCurrentClientWindowId(facesContext), false);
-            if (storage != null)
-            {
-                Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-                ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-
-                if (contextualInstanceInfo != null)
-                {
-                    return (T) contextualInstanceInfo.getContextualInstance();
-                }
-            }
-        }
-        else
-        {
-            throw new IllegalStateException("FacesContext cannot be found when resolving bean " + bean.toString());
-        }
-        return null;
-    }
-
-    @Override
-    public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
-    {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        
-        checkActive(facesContext);
-
-        ContextualStorage storage = getStorageHolder(facesContext).getContextualStorage(
-                getCurrentClientWindowId(facesContext), true);
-
-        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-
-        if (contextualInstanceInfo != null)
-        {
-            @SuppressWarnings("unchecked")
-            final T instance = (T) contextualInstanceInfo.getContextualInstance();
-
-            if (instance != null)
-            {
-                return instance;
-            }
-        }
-
-        return storage.createContextualInstance(bean, creationalContext);
-    }
-
-    protected void checkActive(FacesContext facesContext)
-    {
-        if (!isActive(facesContext))
-        {
-            throw new ContextNotActiveException("CDI context with scope annotation @"
-                + getScope().getName() + " is not active with respect to the current thread");
-        }
-    }
-
-    protected ClientWindowScopeContextualStorageHolder getStorageHolder(FacesContext context)
-    {
-        return ClientWindowScopeContextualStorageHolder.getInstance(context, true);
-    }
-
-    protected String getCurrentClientWindowId(FacesContext context)
-    {
-        return context.getExternalContext().getClientWindow().getId();
-    }
-
-
-    public static void destroyAll(FacesContext facesContext)
-    {
-        ClientWindowScopeContextualStorageHolder manager =
-                ClientWindowScopeContextualStorageHolder.getInstance(facesContext);
-        if (manager != null)
-        {
-            manager.destroyAll(facesContext);
-        }
-    }
-    
-    public static void destroyAll(FacesContext context, String clientWindowId)
-    {
-        ClientWindowScopeContextualStorageHolder manager = ClientWindowScopeContextualStorageHolder
-                .getInstance(context);
-        if (manager != null)
-        {
-            manager.destroyAll(context, clientWindowId);
-        }
-    }
-
-    public static void pushClientWindow(FacesContext context, ClientWindow clientWindow)
-    {
-        ClientWindowScopeContextualStorageHolder manager = ClientWindowScopeContextualStorageHolder
-                .getInstance(context, true);
-        if (manager != null)
-        {
-            manager.pushClientWindow(context, clientWindow);
-        }
-    }
-}
+/*
+ * 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.cdi.clientwindow;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import jakarta.enterprise.context.ContextNotActiveException;
+import jakarta.enterprise.context.spi.Context;
+import jakarta.enterprise.context.spi.Contextual;
+import jakarta.enterprise.context.spi.CreationalContext;
+import jakarta.enterprise.inject.Typed;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.lifecycle.ClientWindow;
+import jakarta.faces.lifecycle.ClientWindowScoped;
+import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
+import org.apache.myfaces.cdi.util.ContextualStorage;
+
+/**
+ * Minimal implementation of ClientWindowScope.
+ */
+@Typed()
+public class ClientWindowScopeContext implements Context
+{
+    private BeanManager beanManager;
+    
+    public ClientWindowScopeContext(BeanManager beanManager)
+    {
+        this.beanManager = beanManager;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return ClientWindowScoped.class;
+    }
+
+    @Override
+    public boolean isActive()
+    {
+        return isActive(FacesContext.getCurrentInstance());
+    }
+
+    public boolean isActive(FacesContext facesContext)
+    {
+        if (facesContext == null || facesContext.getExternalContext().getClientWindow() == null)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public <T> T get(Contextual<T> bean)
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        checkActive(facesContext);
+
+        if (facesContext != null)
+        {
+            ContextualStorage storage = getStorageHolder(facesContext).getContextualStorage(
+                    getCurrentClientWindowId(facesContext), false);
+            if (storage != null)
+            {
+                Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
+                ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
+
+                if (contextualInstanceInfo != null)
+                {
+                    return (T) contextualInstanceInfo.getContextualInstance();
+                }
+            }
+        }
+        else
+        {
+            throw new IllegalStateException("FacesContext cannot be found when resolving bean " + bean.toString());
+        }
+        return null;
+    }
+
+    @Override
+    public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        
+        checkActive(facesContext);
+
+        ContextualStorage storage = getStorageHolder(facesContext).getContextualStorage(
+                getCurrentClientWindowId(facesContext), true);
+
+        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
+        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
+
+        if (contextualInstanceInfo != null)
+        {
+            @SuppressWarnings("unchecked")
+            final T instance = (T) contextualInstanceInfo.getContextualInstance();
+
+            if (instance != null)
+            {
+                return instance;
+            }
+        }
+
+        return storage.createContextualInstance(bean, creationalContext);
+    }
+
+    protected void checkActive(FacesContext facesContext)
+    {
+        if (!isActive(facesContext))
+        {
+            throw new ContextNotActiveException("CDI context with scope annotation @"
+                + getScope().getName() + " is not active with respect to the current thread");
+        }
+    }
+
+    protected ClientWindowScopeContextualStorageHolder getStorageHolder(FacesContext context)
+    {
+        return ClientWindowScopeContextualStorageHolder.getInstance(context, true);
+    }
+
+    protected String getCurrentClientWindowId(FacesContext context)
+    {
+        return context.getExternalContext().getClientWindow().getId();
+    }
+
+
+    public static void destroyAll(FacesContext facesContext)
+    {
+        ClientWindowScopeContextualStorageHolder manager =
+                ClientWindowScopeContextualStorageHolder.getInstance(facesContext);
+        if (manager != null)
+        {
+            manager.destroyAll(facesContext);
+        }
+    }
+    
+    public static void destroyAll(FacesContext context, String clientWindowId)
+    {
+        ClientWindowScopeContextualStorageHolder manager = ClientWindowScopeContextualStorageHolder
+                .getInstance(context);
+        if (manager != null)
+        {
+            manager.destroyAll(context, clientWindowId);
+        }
+    }
+
+    public static void pushClientWindow(FacesContext context, ClientWindow clientWindow)
+    {
+        ClientWindowScopeContextualStorageHolder manager = ClientWindowScopeContextualStorageHolder
+                .getInstance(context, true);
+        if (manager != null)
+        {
+            manager.pushClientWindow(context, clientWindow);
+        }
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java
index 14b3db2..be4a3b8 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java
@@ -1,107 +1,107 @@
-/*
- * 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.cdi.clientwindow;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.enterprise.context.SessionScoped;
-import jakarta.enterprise.context.spi.Contextual;
-import jakarta.enterprise.inject.Typed;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.lifecycle.ClientWindow;
-import java.io.Serializable;
-import java.util.Map;
-import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
-import org.apache.myfaces.cdi.util.ContextualStorage;
-import org.apache.myfaces.cdi.util.AbstractContextualStorageHolder;
-import org.apache.myfaces.config.MyfacesConfig;
-import org.apache.myfaces.util.lang.LRULinkedHashMap;
-
-@Typed(ClientWindowScopeContextualStorageHolder.class)
-@SessionScoped
-public class ClientWindowScopeContextualStorageHolder
-        extends AbstractContextualStorageHolder<ContextualStorage>
-        implements Serializable
-{
-    private LRULinkedHashMap<String, String> clientWindowExpirationStack;
-
-    @PostConstruct
-    @Override
-    public void init()
-    {
-        super.init();
-
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-
-        Integer numberOfClientWindowsInSession =
-                MyfacesConfig.getCurrentInstance(facesContext).getNumberOfClientWindows();
-        clientWindowExpirationStack = new LRULinkedHashMap<>(numberOfClientWindowsInSession, (eldest) ->
-        {
-            destroyAll(FacesContext.getCurrentInstance(), eldest.getKey());
-        });
-
-        pushClientWindow(facesContext, facesContext.getExternalContext().getClientWindow());
-    }
-    
-    @Override
-    public void destroyAll(ContextualStorage contextualStorage, FacesContext facesContext)
-    {
-        if (contextualStorage == null)
-        {
-            return;
-        }
-        
-        Map<Object, ContextualInstanceInfo<?>> contextMap = contextualStorage.getStorage();
-        for (Map.Entry<Object, ContextualInstanceInfo<?>> entry : contextMap.entrySet())
-        {
-            Contextual bean = contextualStorage.getBean(entry.getKey());
-
-            ContextualInstanceInfo<?> contextualInstanceInfo = entry.getValue();
-            bean.destroy(contextualInstanceInfo.getContextualInstance(), 
-                contextualInstanceInfo.getCreationalContext());
-        }
-    }
-
-    @Override
-    protected ContextualStorage newContextualStorage(String slotId)
-    {
-        return new ContextualStorage(beanManager, true);
-    }
-
-    public void pushClientWindow(FacesContext facesContext, ClientWindow clientWindow)
-    {
-        if (clientWindow != null && clientWindow.getId() != null)
-        {
-            synchronized (clientWindowExpirationStack)
-            {
-                clientWindowExpirationStack.remove(clientWindow.getId());
-                clientWindowExpirationStack.put(clientWindow.getId(), "");
-            }
-        }
-    }
-
-    public static ClientWindowScopeContextualStorageHolder getInstance(FacesContext facesContext)
-    {
-        return getInstance(facesContext, false);
-    }
-    
-    public static ClientWindowScopeContextualStorageHolder getInstance(FacesContext facesContext, boolean create)
-    {
-        return getInstance(facesContext, ClientWindowScopeContextualStorageHolder.class, create);
-    }
-}
+/*
+ * 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.cdi.clientwindow;
+
+import jakarta.annotation.PostConstruct;
+import jakarta.enterprise.context.SessionScoped;
+import jakarta.enterprise.context.spi.Contextual;
+import jakarta.enterprise.inject.Typed;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.lifecycle.ClientWindow;
+import java.io.Serializable;
+import java.util.Map;
+import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
+import org.apache.myfaces.cdi.util.ContextualStorage;
+import org.apache.myfaces.cdi.util.AbstractContextualStorageHolder;
+import org.apache.myfaces.config.MyfacesConfig;
+import org.apache.myfaces.util.lang.LRULinkedHashMap;
+
+@Typed(ClientWindowScopeContextualStorageHolder.class)
+@SessionScoped
+public class ClientWindowScopeContextualStorageHolder
+        extends AbstractContextualStorageHolder<ContextualStorage>
+        implements Serializable
+{
+    private LRULinkedHashMap<String, String> clientWindowExpirationStack;
+
+    @PostConstruct
+    @Override
+    public void init()
+    {
+        super.init();
+
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        Integer numberOfClientWindowsInSession =
+                MyfacesConfig.getCurrentInstance(facesContext).getNumberOfClientWindows();
+        clientWindowExpirationStack = new LRULinkedHashMap<>(numberOfClientWindowsInSession, (eldest) ->
+        {
+            destroyAll(FacesContext.getCurrentInstance(), eldest.getKey());
+        });
+
+        pushClientWindow(facesContext, facesContext.getExternalContext().getClientWindow());
+    }
+    
+    @Override
+    public void destroyAll(ContextualStorage contextualStorage, FacesContext facesContext)
+    {
+        if (contextualStorage == null)
+        {
+            return;
+        }
+        
+        Map<Object, ContextualInstanceInfo<?>> contextMap = contextualStorage.getStorage();
+        for (Map.Entry<Object, ContextualInstanceInfo<?>> entry : contextMap.entrySet())
+        {
+            Contextual bean = contextualStorage.getBean(entry.getKey());
+
+            ContextualInstanceInfo<?> contextualInstanceInfo = entry.getValue();
+            bean.destroy(contextualInstanceInfo.getContextualInstance(), 
+                contextualInstanceInfo.getCreationalContext());
+        }
+    }
+
+    @Override
+    protected ContextualStorage newContextualStorage(String slotId)
+    {
+        return new ContextualStorage(beanManager, true);
+    }
+
+    public void pushClientWindow(FacesContext facesContext, ClientWindow clientWindow)
+    {
+        if (clientWindow != null && clientWindow.getId() != null)
+        {
+            synchronized (clientWindowExpirationStack)
+            {
+                clientWindowExpirationStack.remove(clientWindow.getId());
+                clientWindowExpirationStack.put(clientWindow.getId(), "");
+            }
+        }
+    }
+
+    public static ClientWindowScopeContextualStorageHolder getInstance(FacesContext facesContext)
+    {
+        return getInstance(facesContext, false);
+    }
+    
+    public static ClientWindowScopeContextualStorageHolder getInstance(FacesContext facesContext, boolean create)
+    {
+        return getInstance(facesContext, ClientWindowScopeContextualStorageHolder.class, create);
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java
index 9a749a8..5b24dee 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java
@@ -1,293 +1,293 @@
-/*
- * 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.cdi.util;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.PreDestroy;
-import jakarta.enterprise.context.spi.Contextual;
-import jakarta.enterprise.inject.spi.BeanManager;
-import jakarta.faces.context.ExceptionHandler;
-import jakarta.faces.context.ExternalContext;
-import jakarta.faces.context.FacesContext;
-import jakarta.inject.Inject;
-import jakarta.servlet.ServletContext;
-import java.io.Serializable;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.myfaces.cdi.FacesApplicationArtifactHolder;
-import org.apache.myfaces.context.ExceptionHandlerImpl;
-import org.apache.myfaces.context.servlet.StartupFacesContextImpl;
-import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
-
-public abstract class AbstractContextualStorageHolder<T extends ContextualStorage> implements Serializable
-{
-    @Inject
-    protected FacesApplicationArtifactHolder applicationContextBean;
-    
-    @Inject
-    protected BeanManager beanManager;
-    
-    protected Map<String, T> storageMap;
-
-    public AbstractContextualStorageHolder()
-    {
-    }
-
-    @PostConstruct
-    public void init()
-    {
-        storageMap = new ConcurrentHashMap<>();
-        
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-
-        Object context = facesContext.getExternalContext().getContext();
-        if (context instanceof ServletContext)
-        {
-            FacesApplicationArtifactHolder appBean = CDIUtils.get(beanManager, FacesApplicationArtifactHolder.class);
-            if (appBean.getServletContext() != null)
-            {
-                appBean.setServletContext((ServletContext) context);
-            }
-        }
-    }
-
-    /**
-     *
-     * This method will replace the storageMap and with a new empty one.
-     * This method can be used to properly destroy the BeanHolder beans without having to sync heavily.
-     * Any {@link jakarta.enterprise.inject.spi.Bean#destroy(Object, jakarta.enterprise.context.spi.CreationalContext)}
-     * should be performed on the returned old storage map.
-     *
-     * @return the old storageMap.
-     */
-    public Map<String, T> forceNewStorage()
-    {
-        Map<String, T> oldStorageMap = storageMap;
-        storageMap = new ConcurrentHashMap<>();
-        return oldStorageMap;
-    }
-
-    public Map<String, T> getStorageMap()
-    {
-        return storageMap;
-    }
-    
-    public T getContextualStorage(String slotId)
-    {
-        return getContextualStorage(slotId, true);
-    }
-    
-    public T getContextualStorage(String slotId, boolean create)
-    {
-        if (storageMap == null)
-        {
-            if (!create)
-            {
-                return null;
-            }
-            
-            storageMap = new ConcurrentHashMap<>();
-        }
-
-        T storage = storageMap.get(slotId);
-        if (storage == null && create)
-        {
-            storage = newContextualStorage(slotId);
-            storageMap.put(slotId, storage);
-        }
-        return storage;
-    }
-
-    protected abstract T newContextualStorage(String slotId);
-    
-    @PreDestroy
-    public void preDestroy()
-    {
-        // After some testing done two things are clear:
-        // 1. jetty +  weld call @PreDestroy at the end of the request
-        // 2. use a HttpServletListener in tomcat + owb does not work, because
-        //    CDI listener is executed first.
-        // So we need a mixed approach using both a listener and @PreDestroy annotations.
-        // When the first one in being called replace the storages with a new map 
-        // and call PreDestroy, when the second one is called, it founds an empty map
-        // and the process stops. A hack to get ServletContext from CDI is required to
-        // provide a valid FacesContext instance.
-        Map<String, T> oldContextStorages = forceNewStorage();
-        if (!oldContextStorages.isEmpty())
-        {
-            FacesContext facesContext = FacesContext.getCurrentInstance();
-            if (facesContext == null && applicationContextBean.getServletContext() != null)
-            {
-                try
-                {
-                    ServletContext servletContext = applicationContextBean.getServletContext();
-                    ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
-                    ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
-                    facesContext = new StartupFacesContextImpl(externalContext, 
-                            externalContext, exceptionHandler, false);
-                    for (T contextualStorage : oldContextStorages.values())
-                    {
-                        destroyAll(contextualStorage, facesContext);
-                    }
-                }
-                finally
-                {
-                    facesContext.release();
-                }
-            }
-            else
-            {
-                for (T contextualStorage : oldContextStorages.values())
-                {
-                    destroyAll(contextualStorage, facesContext);
-                }
-            }
-        }
-    }
-
-    public void destroyAll(FacesContext facesContext)
-    {
-        if (storageMap == null || storageMap.isEmpty())
-        {
-            return;
-        }
-
-        // we replace the old BeanHolder beans with a new storage Map
-        // an afterwards destroy the old Beans without having to care about any syncs.
-        // This behavior also helps as a check to avoid destroy the same beans twice.
-        Map<String, T> oldContextStorages = forceNewStorage();
-
-        for (T contextualStorage : oldContextStorages.values())
-        {
-            destroyAll(contextualStorage, facesContext);
-        }
-    }
-
-    public void destroyAll(T contextualStorage, FacesContext facesContext)
-    {
-        if (facesContext == null)
-        {
-            facesContext = FacesContext.getCurrentInstance();
-        }
-        
-        boolean tempFacesContext = false;
-        if (facesContext == null && applicationContextBean.getServletContext() != null)
-        {
-            ServletContext servletContext = applicationContextBean.getServletContext();
-            ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
-            ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
-            facesContext = new StartupFacesContextImpl(externalContext, externalContext, exceptionHandler, false);
-            tempFacesContext = true;
-        }
-
-        try
-        {
-            Map<Object, ContextualInstanceInfo<?>> contextMap = contextualStorage.getStorage();
-
-            for (Map.Entry<Object, ContextualInstanceInfo<?>> entry : contextMap.entrySet())
-            {  
-                boolean skip = isSkipDestroy(entry);
-                if (!skip)
-                {
-                    Contextual bean = contextualStorage.getBean(entry.getKey());
-
-                    ContextualInstanceInfo<?> contextualInstanceInfo = entry.getValue();
-                    bean.destroy(contextualInstanceInfo.getContextualInstance(), 
-                        contextualInstanceInfo.getCreationalContext());
-                }
-            }
-
-            contextMap.clear();
-
-            contextualStorage.deactivate();
-        }
-        finally
-        {
-            if (tempFacesContext)
-            {
-                facesContext.release();
-            }
-        }
-    }
-    
-    protected boolean isSkipDestroy(Map.Entry<Object, ContextualInstanceInfo<?>> entry)
-    {
-        return false;
-    }
-
-    public void destroyAll(FacesContext context, String slotId)
-    {
-        if (storageMap == null || storageMap.isEmpty())
-        {
-            return;
-        }
-
-        T contextualStorage = storageMap.remove(slotId);
-        destroyAll(contextualStorage, context);
-    }
-
-    protected static <T extends AbstractContextualStorageHolder> T getInstance(FacesContext facesContext,
-            Class<T> contextManagerClass)
-    {
-        return getInstance(facesContext, contextManagerClass, false);
-    }
-    
-    protected static <T extends AbstractContextualStorageHolder> T getInstance(FacesContext facesContext,
-            Class<T> contextManagerClass, boolean create)
-    {
-        if (facesContext == null
-                || facesContext.getExternalContext() == null
-                || facesContext.getExternalContext().getSession(false) == null)
-        {
-            return null;
-        }
-
-        BeanManager beanManager = CDIUtils.getBeanManager(facesContext);
-        if (beanManager == null)
-        {
-            return null;
-        }
-
-        if (!CDIUtils.isSessionScopeActive(beanManager))
-        {
-            return null;
-        }
-
-        T cached = (T) facesContext.getExternalContext().getSessionMap().get(contextManagerClass.getName());
-        if (cached == null)
-        {
-            if (create)
-            {
-                cached = CDIUtils.get(beanManager, contextManagerClass);
-            }
-            else
-            {
-                cached = CDIUtils.getOptional(beanManager, contextManagerClass);
-            }
-            if (cached != null)
-            {
-                facesContext.getExternalContext().getSessionMap().put(contextManagerClass.getName(),
-                        cached);
-            }
-        }
-
-        return cached;
-    }
-
-}
+/*
+ * 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.cdi.util;
+
+import jakarta.annotation.PostConstruct;
+import jakarta.annotation.PreDestroy;
+import jakarta.enterprise.context.spi.Contextual;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.faces.context.ExceptionHandler;
+import jakarta.faces.context.ExternalContext;
+import jakarta.faces.context.FacesContext;
+import jakarta.inject.Inject;
+import jakarta.servlet.ServletContext;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.myfaces.cdi.FacesApplicationArtifactHolder;
+import org.apache.myfaces.context.ExceptionHandlerImpl;
+import org.apache.myfaces.context.servlet.StartupFacesContextImpl;
+import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
+
+public abstract class AbstractContextualStorageHolder<T extends ContextualStorage> implements Serializable
+{
+    @Inject
+    protected FacesApplicationArtifactHolder applicationContextBean;
+    
+    @Inject
+    protected BeanManager beanManager;
+    
+    protected Map<String, T> storageMap;
+
+    public AbstractContextualStorageHolder()
+    {
+    }
+
+    @PostConstruct
+    public void init()
+    {
+        storageMap = new ConcurrentHashMap<>();
+        
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        Object context = facesContext.getExternalContext().getContext();
+        if (context instanceof ServletContext)
+        {
+            FacesApplicationArtifactHolder appBean = CDIUtils.get(beanManager, FacesApplicationArtifactHolder.class);
+            if (appBean.getServletContext() != null)
+            {
+                appBean.setServletContext((ServletContext) context);
+            }
+        }
+    }
+
+    /**
+     *
+     * This method will replace the storageMap and with a new empty one.
+     * This method can be used to properly destroy the BeanHolder beans without having to sync heavily.
+     * Any {@link jakarta.enterprise.inject.spi.Bean#destroy(Object, jakarta.enterprise.context.spi.CreationalContext)}
+     * should be performed on the returned old storage map.
+     *
+     * @return the old storageMap.
+     */
+    public Map<String, T> forceNewStorage()
+    {
+        Map<String, T> oldStorageMap = storageMap;
+        storageMap = new ConcurrentHashMap<>();
+        return oldStorageMap;
+    }
+
+    public Map<String, T> getStorageMap()
+    {
+        return storageMap;
+    }
+    
+    public T getContextualStorage(String slotId)
+    {
+        return getContextualStorage(slotId, true);
+    }
+    
+    public T getContextualStorage(String slotId, boolean create)
+    {
+        if (storageMap == null)
+        {
+            if (!create)
+            {
+                return null;
+            }
+            
+            storageMap = new ConcurrentHashMap<>();
+        }
+
+        T storage = storageMap.get(slotId);
+        if (storage == null && create)
+        {
+            storage = newContextualStorage(slotId);
+            storageMap.put(slotId, storage);
+        }
+        return storage;
+    }
+
+    protected abstract T newContextualStorage(String slotId);
+    
+    @PreDestroy
+    public void preDestroy()
+    {
+        // After some testing done two things are clear:
+        // 1. jetty +  weld call @PreDestroy at the end of the request
+        // 2. use a HttpServletListener in tomcat + owb does not work, because
+        //    CDI listener is executed first.
+        // So we need a mixed approach using both a listener and @PreDestroy annotations.
+        // When the first one in being called replace the storages with a new map 
+        // and call PreDestroy, when the second one is called, it founds an empty map
+        // and the process stops. A hack to get ServletContext from CDI is required to
+        // provide a valid FacesContext instance.
+        Map<String, T> oldContextStorages = forceNewStorage();
+        if (!oldContextStorages.isEmpty())
+        {
+            FacesContext facesContext = FacesContext.getCurrentInstance();
+            if (facesContext == null && applicationContextBean.getServletContext() != null)
+            {
+                try
+                {
+                    ServletContext servletContext = applicationContextBean.getServletContext();
+                    ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
+                    ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
+                    facesContext = new StartupFacesContextImpl(externalContext, 
+                            externalContext, exceptionHandler, false);
+                    for (T contextualStorage : oldContextStorages.values())
+                    {
+                        destroyAll(contextualStorage, facesContext);
+                    }
+                }
+                finally
+                {
+                    facesContext.release();
+                }
+            }
+            else
+            {
+                for (T contextualStorage : oldContextStorages.values())
+                {
+                    destroyAll(contextualStorage, facesContext);
+                }
+            }
+        }
+    }
+
+    public void destroyAll(FacesContext facesContext)
+    {
+        if (storageMap == null || storageMap.isEmpty())
+        {
+            return;
+        }
+
+        // we replace the old BeanHolder beans with a new storage Map
+        // an afterwards destroy the old Beans without having to care about any syncs.
+        // This behavior also helps as a check to avoid destroy the same beans twice.
+        Map<String, T> oldContextStorages = forceNewStorage();
+
+        for (T contextualStorage : oldContextStorages.values())
+        {
+            destroyAll(contextualStorage, facesContext);
+        }
+    }
+
+    public void destroyAll(T contextualStorage, FacesContext facesContext)
+    {
+        if (facesContext == null)
+        {
+            facesContext = FacesContext.getCurrentInstance();
+        }
+        
+        boolean tempFacesContext = false;
+        if (facesContext == null && applicationContextBean.getServletContext() != null)
+        {
+            ServletContext servletContext = applicationContextBean.getServletContext();
+            ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
+            ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
+            facesContext = new StartupFacesContextImpl(externalContext, externalContext, exceptionHandler, false);
+            tempFacesContext = true;
+        }
+
+        try
+        {
+            Map<Object, ContextualInstanceInfo<?>> contextMap = contextualStorage.getStorage();
+
+            for (Map.Entry<Object, ContextualInstanceInfo<?>> entry : contextMap.entrySet())
+            {  
+                boolean skip = isSkipDestroy(entry);
+                if (!skip)
+                {
+                    Contextual bean = contextualStorage.getBean(entry.getKey());
+
+                    ContextualInstanceInfo<?> contextualInstanceInfo = entry.getValue();
+                    bean.destroy(contextualInstanceInfo.getContextualInstance(), 
+                        contextualInstanceInfo.getCreationalContext());
+                }
+            }
+
+            contextMap.clear();
+
+            contextualStorage.deactivate();
+        }
+        finally
+        {
+            if (tempFacesContext)
+            {
+                facesContext.release();
+            }
+        }
+    }
+    
+    protected boolean isSkipDestroy(Map.Entry<Object, ContextualInstanceInfo<?>> entry)
+    {
+        return false;
+    }
+
+    public void destroyAll(FacesContext context, String slotId)
+    {
+        if (storageMap == null || storageMap.isEmpty())
+        {
+            return;
+        }
+
+        T contextualStorage = storageMap.remove(slotId);
+        destroyAll(contextualStorage, context);
+    }
+
+    protected static <T extends AbstractContextualStorageHolder> T getInstance(FacesContext facesContext,
+            Class<T> contextManagerClass)
+    {
+        return getInstance(facesContext, contextManagerClass, false);
+    }
+    
+    protected static <T extends AbstractContextualStorageHolder> T getInstance(FacesContext facesContext,
+            Class<T> contextManagerClass, boolean create)
+    {
+        if (facesContext == null
+                || facesContext.getExternalContext() == null
+                || facesContext.getExternalContext().getSession(false) == null)
+        {
+            return null;
+        }
+
+        BeanManager beanManager = CDIUtils.getBeanManager(facesContext);
+        if (beanManager == null)
+        {
+            return null;
+        }
+
+        if (!CDIUtils.isSessionScopeActive(beanManager))
+        {
+            return null;
+        }
+
+        T cached = (T) facesContext.getExternalContext().getSessionMap().get(contextManagerClass.getName());
+        if (cached == null)
+        {
+            if (create)
+            {
+                cached = CDIUtils.get(beanManager, contextManagerClass);
+            }
+            else
+            {
+                cached = CDIUtils.getOptional(beanManager, contextManagerClass);
+            }
+            if (cached != null)
+            {
+                facesContext.getExternalContext().getSessionMap().put(contextManagerClass.getName(),
+                        cached);
+            }
+        }
+
+        return cached;
+    }
+
+}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java
index 5eb0ad4..fa24c93 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java
@@ -1,205 +1,205 @@
-/*
- * 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.cdi.view;
-
-import jakarta.enterprise.context.ContextNotActiveException;
-import jakarta.enterprise.inject.Typed;
-import jakarta.enterprise.inject.spi.BeanManager;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import jakarta.enterprise.context.spi.Context;
-import jakarta.enterprise.context.spi.Contextual;
-import jakarta.enterprise.context.spi.CreationalContext;
-import jakarta.enterprise.inject.spi.PassivationCapable;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.view.ViewScoped;
-
-import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
-import org.apache.myfaces.view.ViewScopeProxyMap;
-
-/**
- * CDI Context to handle &#064;{@link ViewScoped} beans.
- * 
- * @author Leonardo Uribe
- */
-@Typed()
-public class ViewScopeContext implements Context
-{
-
-    /**
-     * needed for serialisation and passivationId
-     */
-    private BeanManager beanManager;
-    
-    private boolean passivatingScope;
-
-    public ViewScopeContext(BeanManager beanManager)
-    {
-        this.beanManager = beanManager;
-        this.passivatingScope = beanManager.isPassivatingScope(getScope());
-    }
-
-    protected ViewScopeContextualStorageHolder getStorageHolder(FacesContext facesContext)
-    {
-        return ViewScopeContextualStorageHolder.getInstance(facesContext, true);
-    }
-
-    public String getCurrentViewScopeId(boolean create)
-    {        
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        ViewScopeProxyMap map = (ViewScopeProxyMap) facesContext.getViewRoot().getViewMap(create);
-        if (map != null)
-        {
-            String id = map.getViewScopeId();
-            if (id == null && create)
-            {
-                // Force create
-                map.forceDelegateCreation(facesContext);
-                id = map.getViewScopeId();
-            }
-            return id;
-        }
-        return null;
-    }
-
-    protected ViewScopeContextualStorage getContextualStorage(FacesContext facesContext, boolean createIfNotExist)
-    {
-        String viewScopeId = getCurrentViewScopeId(createIfNotExist);
-        if (createIfNotExist && viewScopeId == null)
-        {
-            throw new ContextNotActiveException(
-                this.getClass().getSimpleName() + ": no viewScopeId set for the current view yet!");
-        }
-        if (viewScopeId != null)
-        {
-            return getStorageHolder(facesContext).getContextualStorage(viewScopeId, createIfNotExist);
-        }
-        return null;
-    }
-
-    @Override
-    public Class<? extends Annotation> getScope()
-    {
-        return ViewScoped.class;
-    }
-
-    @Override
-    public boolean isActive()
-    {
-        return isActive(FacesContext.getCurrentInstance());
-    }
-
-    public boolean isActive(FacesContext facesContext)
-    {
-        if (facesContext == null || facesContext.getViewRoot() == null)
-        {
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public <T> T get(Contextual<T> bean)
-    {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        
-        checkActive(facesContext);
-
-        // force session creation if ViewScoped is used
-        facesContext.getExternalContext().getSession(true);
-        
-        ViewScopeContextualStorage storage = getContextualStorage(facesContext, false);
-        if (storage == null)
-        {
-            return null;
-        }
-
-        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-        if (contextualInstanceInfo == null)
-        {
-            return null;
-        }
-
-        return (T) contextualInstanceInfo.getContextualInstance();
-    }
-
-    @Override
-    public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
-    {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        
-        checkActive(facesContext);
-
-        if (passivatingScope && !(bean instanceof PassivationCapable))
-        {
-            throw new IllegalStateException(bean.toString() +
-                    " doesn't implement " + PassivationCapable.class.getName());
-        }
-
-        // force session creation if ViewScoped is used
-        facesContext.getExternalContext().getSession(true);
-        
-        ViewScopeContextualStorage storage = getContextualStorage(facesContext, true);
-
-        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-
-        if (contextualInstanceInfo != null)
-        {
-            @SuppressWarnings("unchecked")
-            final T instance = (T) contextualInstanceInfo.getContextualInstance();
-            if (instance != null)
-            {
-                return instance;
-            }
-        }
-
-        return storage.createContextualInstance(bean, creationalContext);
-    }
-
-    protected void checkActive(FacesContext facesContext)
-    {
-        if (!isActive(facesContext))
-        {
-            throw new ContextNotActiveException("CDI context with scope annotation @"
-                + getScope().getName() + " is not active with respect to the current thread");
-        }
-    }
-
-    public static void destroyAll(FacesContext facesContext)
-    {
-        ViewScopeContextualStorageHolder manager = ViewScopeContextualStorageHolder.getInstance(facesContext);
-        if (manager != null)
-        {
-            manager.destroyAll(facesContext);
-        }
-    }
-
-    public static void destroyAll(FacesContext facesContext, String viewScopeId)
-    {
-        ViewScopeContextualStorageHolder manager = ViewScopeContextualStorageHolder.getInstance(facesContext);
-        if (manager != null)
-        {
-            manager.destroyAll(facesContext, viewScopeId);
-        }
-    }
+/*
+ * 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.cdi.view;
+
+import jakarta.enterprise.context.ContextNotActiveException;
+import jakarta.enterprise.inject.Typed;
+import jakarta.enterprise.inject.spi.BeanManager;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import jakarta.enterprise.context.spi.Context;
+import jakarta.enterprise.context.spi.Contextual;
+import jakarta.enterprise.context.spi.CreationalContext;
+import jakarta.enterprise.inject.spi.PassivationCapable;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.view.ViewScoped;
+
+import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
+import org.apache.myfaces.view.ViewScopeProxyMap;
+
+/**
+ * CDI Context to handle &#064;{@link ViewScoped} beans.
+ * 
+ * @author Leonardo Uribe
+ */
+@Typed()
+public class ViewScopeContext implements Context
+{
+
+    /**
+     * needed for serialisation and passivationId
+     */
+    private BeanManager beanManager;
+    
+    private boolean passivatingScope;
+
+    public ViewScopeContext(BeanManager beanManager)
+    {
+        this.beanManager = beanManager;
+        this.passivatingScope = beanManager.isPassivatingScope(getScope());
+    }
+
+    protected ViewScopeContextualStorageHolder getStorageHolder(FacesContext facesContext)
+    {
+        return ViewScopeContextualStorageHolder.getInstance(facesContext, true);
+    }
+
+    public String getCurrentViewScopeId(boolean create)
+    {        
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        ViewScopeProxyMap map = (ViewScopeProxyMap) facesContext.getViewRoot().getViewMap(create);
+        if (map != null)
+        {
+            String id = map.getViewScopeId();
+            if (id == null && create)
+            {
+                // Force create
+                map.forceDelegateCreation(facesContext);
+                id = map.getViewScopeId();
+            }
+            return id;
+        }
+        return null;
+    }
+
+    protected ViewScopeContextualStorage getContextualStorage(FacesContext facesContext, boolean createIfNotExist)
+    {
+        String viewScopeId = getCurrentViewScopeId(createIfNotExist);
+        if (createIfNotExist && viewScopeId == null)
+        {
+            throw new ContextNotActiveException(
+                this.getClass().getSimpleName() + ": no viewScopeId set for the current view yet!");
+        }
+        if (viewScopeId != null)
+        {
+            return getStorageHolder(facesContext).getContextualStorage(viewScopeId, createIfNotExist);
+        }
+        return null;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return ViewScoped.class;
+    }
+
+    @Override
+    public boolean isActive()
+    {
+        return isActive(FacesContext.getCurrentInstance());
+    }
+
+    public boolean isActive(FacesContext facesContext)
+    {
+        if (facesContext == null || facesContext.getViewRoot() == null)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public <T> T get(Contextual<T> bean)
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        
+        checkActive(facesContext);
+
+        // force session creation if ViewScoped is used
+        facesContext.getExternalContext().getSession(true);
+        
+        ViewScopeContextualStorage storage = getContextualStorage(facesContext, false);
+        if (storage == null)
+        {
+            return null;
+        }
+
+        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
+        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
+        if (contextualInstanceInfo == null)
+        {
+            return null;
+        }
+
+        return (T) contextualInstanceInfo.getContextualInstance();
+    }
+
+    @Override
+    public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        
+        checkActive(facesContext);
+
+        if (passivatingScope && !(bean instanceof PassivationCapable))
+        {
+            throw new IllegalStateException(bean.toString() +
+                    " doesn't implement " + PassivationCapable.class.getName());
+        }
+
+        // force session creation if ViewScoped is used
+        facesContext.getExternalContext().getSession(true);
+        
+        ViewScopeContextualStorage storage = getContextualStorage(facesContext, true);
+
+        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
+        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
+
+        if (contextualInstanceInfo != null)
+        {
+            @SuppressWarnings("unchecked")
+            final T instance = (T) contextualInstanceInfo.getContextualInstance();
+            if (instance != null)
+            {
+                return instance;
+            }
+        }
+
+        return storage.createContextualInstance(bean, creationalContext);
+    }
+
+    protected void checkActive(FacesContext facesContext)
+    {
+        if (!isActive(facesContext))
+        {
+            throw new ContextNotActiveException("CDI context with scope annotation @"
+                + getScope().getName() + " is not active with respect to the current thread");
+        }
+    }
+
+    public static void destroyAll(FacesContext facesContext)
+    {
+        ViewScopeContextualStorageHolder manager = ViewScopeContextualStorageHolder.getInstance(facesContext);
+        if (manager != null)
+        {
+            manager.destroyAll(facesContext);
+        }
+    }
+
+    public static void destroyAll(FacesContext facesContext, String viewScopeId)
+    {
+        ViewScopeContextualStorageHolder manager = ViewScopeContextualStorageHolder.getInstance(facesContext);
+        if (manager != null)
+        {
+            manager.destroyAll(facesContext, viewScopeId);
+        }
+    }
 }
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java
index 726b88c..1a4ad78 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java
@@ -1,71 +1,71 @@
-/*
- * 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.cdi.view;
-
-import java.io.Serializable;
-import java.util.Random;
-import jakarta.enterprise.context.SessionScoped;
-import jakarta.enterprise.inject.Typed;
-import jakarta.faces.context.FacesContext;
-import org.apache.myfaces.cdi.util.AbstractContextualStorageHolder;
-
-/**
- *
- * @author Leonardo Uribe
- */
-@Typed(ViewScopeContextualStorageHolder.class)
-@SessionScoped
-public class ViewScopeContextualStorageHolder
-        extends AbstractContextualStorageHolder<ViewScopeContextualStorage>
-        implements Serializable
-{    
-    private static final Random RANDOM_GENERATOR = new Random();
-
-    public ViewScopeContextualStorageHolder()
-    {
-    }
-
-    public String generateUniqueViewScopeId()
-    {
-        // To ensure uniqueness we just use a random generator and we check
-        // if the key is already used.
-        String key;
-        do 
-        {
-            key = Integer.toString(RANDOM_GENERATOR.nextInt());
-        } while (storageMap.containsKey(key));
-        return key;
-    }
-
-    @Override
-    protected ViewScopeContextualStorage newContextualStorage(String slotId)
-    {
-        return new ViewScopeContextualStorage(beanManager);
-    }
-
-    protected static ViewScopeContextualStorageHolder getInstance(FacesContext facesContext)
-    {
-        return getInstance(facesContext, false);
-    }
-    
-    protected static ViewScopeContextualStorageHolder getInstance(FacesContext facesContext, boolean create)
-    {
-        return getInstance(facesContext, ViewScopeContextualStorageHolder.class, create);
-    }
-}
+/*
+ * 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.cdi.view;
+
+import java.io.Serializable;
+import java.util.Random;
+import jakarta.enterprise.context.SessionScoped;
+import jakarta.enterprise.inject.Typed;
+import jakarta.faces.context.FacesContext;
+import org.apache.myfaces.cdi.util.AbstractContextualStorageHolder;
+
+/**
+ *
+ * @author Leonardo Uribe
+ */
+@Typed(ViewScopeContextualStorageHolder.class)
+@SessionScoped
+public class ViewScopeContextualStorageHolder
+        extends AbstractContextualStorageHolder<ViewScopeContextualStorage>
+        implements Serializable
+{    
+    private static final Random RANDOM_GENERATOR = new Random();
+
+    public ViewScopeContextualStorageHolder()
+    {
+    }
+
+    public String generateUniqueViewScopeId()
+    {
+        // To ensure uniqueness we just use a random generator and we check
+        // if the key is already used.
+        String key;
+        do 
+        {
+            key = Integer.toString(RANDOM_GENERATOR.nextInt());
+        } while (storageMap.containsKey(key));
+        return key;
+    }
+
+    @Override
+    protected ViewScopeContextualStorage newContextualStorage(String slotId)
+    {
+        return new ViewScopeContextualStorage(beanManager);
+    }
+
+    protected static ViewScopeContextualStorageHolder getInstance(FacesContext facesContext)
+    {
+        return getInstance(facesContext, false);
+    }
+    
+    protected static ViewScopeContextualStorageHolder getInstance(FacesContext facesContext, boolean create)
+    {
+        return getInstance(facesContext, ViewScopeContextualStorageHolder.class, create);
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
index 1c162d7..f2515bb 100755
--- a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
+++ b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
@@ -1,1513 +1,1513 @@
-/*
- * 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.config;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.function.Predicate;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import jakarta.el.ELResolver;
-import jakarta.faces.FacesException;
-import jakarta.faces.FacesWrapper;
-import jakarta.faces.FactoryFinder;
-import jakarta.faces.application.Application;
-import jakarta.faces.application.ApplicationFactory;
-import jakarta.faces.application.ConfigurableNavigationHandler;
-import jakarta.faces.application.NavigationHandler;
-import jakarta.faces.application.ProjectStage;
-import jakarta.faces.application.ResourceHandler;
-import jakarta.faces.application.StateManager;
-import jakarta.faces.application.ViewHandler;
-import jakarta.faces.component.search.SearchExpressionHandler;
-import jakarta.faces.component.search.SearchKeywordResolver;
-import jakarta.faces.context.ExternalContext;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.event.ActionListener;
-import jakarta.faces.event.ComponentSystemEvent;
-import jakarta.faces.event.PhaseListener;
-import jakarta.faces.event.PostConstructApplicationEvent;
-import jakarta.faces.event.SystemEvent;
-import jakarta.faces.flow.Flow;
-import jakarta.faces.flow.FlowHandler;
-import jakarta.faces.flow.FlowHandlerFactory;
-import jakarta.faces.lifecycle.ClientWindow;
-import jakarta.faces.lifecycle.Lifecycle;
-import jakarta.faces.lifecycle.LifecycleFactory;
-import jakarta.faces.render.RenderKit;
-import jakarta.faces.render.RenderKitFactory;
-import jakarta.faces.validator.BeanValidator;
-import jakarta.faces.webapp.FacesServlet;
-
-import org.apache.myfaces.application.ApplicationFactoryImpl;
-import org.apache.myfaces.application.BackwardsCompatibleNavigationHandlerWrapper;
-import org.apache.myfaces.component.visit.VisitContextFactoryImpl;
-import org.apache.myfaces.config.element.Behavior;
-import org.apache.myfaces.config.element.ClientBehaviorRenderer;
-import org.apache.myfaces.config.element.ComponentTagDeclaration;
-import org.apache.myfaces.config.element.ContractMapping;
-import org.apache.myfaces.config.element.FaceletsProcessing;
-import org.apache.myfaces.config.element.FacesConfig;
-import org.apache.myfaces.config.element.FacesConfigData;
-import org.apache.myfaces.config.element.FacesFlowCall;
-import org.apache.myfaces.config.element.FacesFlowDefinition;
-import org.apache.myfaces.config.element.FacesFlowMethodCall;
-import org.apache.myfaces.config.element.FacesFlowMethodParameter;
-import org.apache.myfaces.config.element.FacesFlowParameter;
-import org.apache.myfaces.config.element.FacesFlowReturn;
-import org.apache.myfaces.config.element.FacesFlowSwitch;
-import org.apache.myfaces.config.element.FacesFlowView;
-import org.apache.myfaces.config.element.NamedEvent;
-import org.apache.myfaces.config.element.NavigationCase;
-import org.apache.myfaces.config.element.NavigationRule;
-import org.apache.myfaces.config.element.Renderer;
-import org.apache.myfaces.config.element.ResourceBundle;
-import org.apache.myfaces.config.element.SystemEventListener;
-import org.apache.myfaces.config.impl.FacesConfigDispenserImpl;
-import org.apache.myfaces.context.ExceptionHandlerFactoryImpl;
-import org.apache.myfaces.context.ExternalContextFactoryImpl;
-import org.apache.myfaces.context.FacesContextFactoryImpl;
-import org.apache.myfaces.context.PartialViewContextFactoryImpl;
-import org.apache.myfaces.context.servlet.ServletFlashFactoryImpl;
-import org.apache.myfaces.lifecycle.clientwindow.ClientWindowFactoryImpl;
-import org.apache.myfaces.flow.FlowCallNodeImpl;
-import org.apache.myfaces.flow.FlowHandlerFactoryImpl;
-import org.apache.myfaces.flow.FlowImpl;
-import org.apache.myfaces.flow.MethodCallNodeImpl;
-import org.apache.myfaces.flow.ParameterImpl;
-import org.apache.myfaces.flow.ReturnNodeImpl;
-import org.apache.myfaces.flow.SwitchCaseImpl;
-import org.apache.myfaces.flow.SwitchNodeImpl;
-import org.apache.myfaces.flow.ViewNodeImpl;
-import org.apache.myfaces.lifecycle.LifecycleFactoryImpl;
-import org.apache.myfaces.renderkit.RenderKitFactoryImpl;
-import org.apache.myfaces.renderkit.html.HtmlRenderKitImpl;
-import org.apache.myfaces.resource.ResourceLoaderUtils;
-import org.apache.myfaces.util.lang.ClassUtils;
-import org.apache.myfaces.util.LocaleUtils;
-import org.apache.myfaces.application.viewstate.StateUtils;
-import org.apache.myfaces.util.lang.StringUtils;
-import org.apache.myfaces.util.WebConfigParamUtils;
-import org.apache.myfaces.cdi.util.BeanEntry;
-import org.apache.myfaces.component.search.SearchExpressionContextFactoryImpl;
-import org.apache.myfaces.config.element.FaceletsTemplateMapping;
-import org.apache.myfaces.config.element.ViewPoolMapping;
-import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
-import org.apache.myfaces.config.impl.FacesConfigUnmarshallerImpl;
-import org.apache.myfaces.lifecycle.LifecycleImpl;
-import org.apache.myfaces.renderkit.LazyRenderKit;
-import org.apache.myfaces.spi.impl.DefaultSerialFactory;
-import org.apache.myfaces.spi.SerialFactory;
-import org.apache.myfaces.spi.FacesConfigurationMerger;
-import org.apache.myfaces.spi.FacesConfigurationMergerFactory;
-import org.apache.myfaces.spi.FacesFlowProvider;
-import org.apache.myfaces.spi.FacesFlowProviderFactory;
-import org.apache.myfaces.spi.InjectionProvider;
-import org.apache.myfaces.spi.InjectionProviderException;
-import org.apache.myfaces.spi.InjectionProviderFactory;
-import org.apache.myfaces.spi.ResourceLibraryContractsProvider;
-import org.apache.myfaces.spi.ResourceLibraryContractsProviderFactory;
-import org.apache.myfaces.util.ExternalSpecifications;
-import org.apache.myfaces.util.NavigationUtils;
-import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl;
-import org.apache.myfaces.view.facelets.el.ELText;
-import org.apache.myfaces.view.facelets.impl.FaceletCacheFactoryImpl;
-import org.apache.myfaces.view.facelets.tag.faces.TagHandlerDelegateFactoryImpl;
-import org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener;
-import org.apache.myfaces.webapp.FacesInitializerImpl;
-
-/**
- * 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$
- */
-@SuppressWarnings("deprecation")
-public class FacesConfigurator
-{
-    private final Class<?>[] NO_PARAMETER_TYPES = new Class[]{};
-    private final Object[] NO_PARAMETERS = new Object[]{};
-
-    private static final Logger log = Logger.getLogger(FacesConfigurator.class.getName());
-
-    private static final String DEFAULT_RENDER_KIT_CLASS = HtmlRenderKitImpl.class.getName();
-    private static final String DEFAULT_APPLICATION_FACTORY = ApplicationFactoryImpl.class.getName();
-    private static final String DEFAULT_EXTERNAL_CONTEXT_FACTORY = ExternalContextFactoryImpl.class.getName();
-    private static final String DEFAULT_FACES_CONTEXT_FACTORY = FacesContextFactoryImpl.class.getName();
-    private static final String DEFAULT_LIFECYCLE_FACTORY = LifecycleFactoryImpl.class.getName();
-    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_EXCEPTION_HANDLER_FACTORY = ExceptionHandlerFactoryImpl.class.getName();
-    private static final String DEFAULT_TAG_HANDLER_DELEGATE_FACTORY = TagHandlerDelegateFactoryImpl.class.getName();
-    private static final String DEFAULT_FACELET_CACHE_FACTORY = FaceletCacheFactoryImpl.class.getName();
-    private static final String DEFAULT_FLASH_FACTORY = ServletFlashFactoryImpl.class.getName();
-    private static final String DEFAULT_CLIENT_WINDOW_FACTORY = ClientWindowFactoryImpl.class.getName();
-    private static final String DEFAULT_FLOW_FACTORY = FlowHandlerFactoryImpl.class.getName();
-    private static final String DEFAULT_SEARCH_EXPRESSION_CONTEXT_FACTORY = 
-            SearchExpressionContextFactoryImpl.class.getName();
-    private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";
-
-    /**
-     * Set this attribute if the current configuration requires enable window mode
-     */
-    public static final String ENABLE_DEFAULT_WINDOW_MODE = 
-        "org.apache.myfaces.ENABLE_DEFAULT_WINDOW_MODE";
-
-    private final ExternalContext _externalContext;
-    private FacesContext _facesContext;
-    private FacesConfigUnmarshaller<? extends FacesConfig> _unmarshaller;
-    private FacesConfigData _dispenser;
-
-    private RuntimeConfig _runtimeConfig;
-    private MyfacesConfig _myfacesConfig;
-    
-    private Application _application;
-    
-    private InjectionProvider _injectionProvider;
-
-    private static long lastUpdate;
-
-    public FacesConfigurator(ExternalContext externalContext)
-    {
-        if (externalContext == null)
-        {
-            throw new IllegalArgumentException("external context must not be null");
-        }
-        _externalContext = externalContext;
-
-        // In dev mode a new Faces Configurator is created for every request so only
-        // create a new bean storage list if we don't already have one which will be
-        // the case first time through during init.
-        if (_externalContext.getApplicationMap().get(FacesInitializerImpl.INJECTED_BEAN_STORAGE_KEY) == null)
-        {
-            _externalContext.getApplicationMap().put(FacesInitializerImpl.INJECTED_BEAN_STORAGE_KEY,
-                    new CopyOnWriteArrayList());
-        }
-        
-        _myfacesConfig = MyfacesConfig.getCurrentInstance(_externalContext);
-        _runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
-    }
-
-    /**
-     * @param unmarshaller
-     *            the unmarshaller to set
-     */
-    public void setUnmarshaller(FacesConfigUnmarshaller<? extends FacesConfig> unmarshaller)
-    {
-        _unmarshaller = unmarshaller;
-    }
-
-    /**
-     * @return the unmarshaller
-     */
-    protected FacesConfigUnmarshaller<? extends FacesConfig> getUnmarshaller()
-    {
-        if (_unmarshaller == null)
-        {
-            _unmarshaller = new FacesConfigUnmarshallerImpl(_externalContext);
-        }
-
-        return _unmarshaller;
-    }
-
-    /**
-     * @param dispenser
-     *            the dispenser to set
-     */
-    public void setDispenser(FacesConfigData dispenser)
-    {
-        _dispenser = dispenser;
-    }
-
-    /**
-     * @return the dispenser
-     */
-    protected FacesConfigData getDispenser()
-    {
-        if (_dispenser == null)
-        {
-            _dispenser = new FacesConfigDispenserImpl();
-        }
-
-        return _dispenser;
-    }
-
-    private long getResourceLastModified(String resource)
-    {
-        try
-        {
-            URL url = _externalContext.getResource(resource);
-            if (url != null)
-            {
-                return ResourceLoaderUtils.getResourceLastModified(url);
-            }
-        }
-        catch (IOException e)
-        {
-            log.log(Level.SEVERE, "Could not read lastModified " + resource, e);
-        }
-        return 0;
-    }
-
-    private long getLastModifiedTime()
-    {
-        long lastModified = 0;
-        long resModified;
-
-        resModified = getResourceLastModified(DEFAULT_FACES_CONFIG);
-        if (resModified > lastModified)
-        {
-            lastModified = resModified;
-        }
-
-        // perf: method getConfigFilesList() creates a ArrayList    
-        List<String> configFilesList = getConfigFilesList();
-        for (int i = 0, size = configFilesList.size(); i < size; i++)
-        {
-            String systemId = configFilesList.get(i);
-            resModified = getResourceLastModified(systemId);
-            if (resModified > lastModified)
-            {
-                lastModified = resModified;
-            }
-        }
-        
-        // get last modified from .taglib.xml
-        String faceletsFiles = WebConfigParamUtils.getStringInitParameter(_externalContext,
-                ViewHandler.FACELETS_LIBRARIES_PARAM_NAME);
-        if (faceletsFiles != null)
-        {
-            String[] faceletFilesList = StringUtils.trim(faceletsFiles.split(";"));
-            for (int i = 0, size = faceletFilesList.length; i < size; i++)
-            {
-                String systemId = faceletFilesList[i];
-                resModified = getResourceLastModified(systemId);
-                if (resModified > lastModified)
-                {
-                    lastModified = resModified;
-                }
-            }
-        }
-        
-        // get last modified from -flow.xml
-        Set<String> directoryPaths = _externalContext.getResourcePaths("/");
-        if (directoryPaths != null)
-        {
-            List<String> contextSpecifiedList = configFilesList;
-            for (String dirPath : directoryPaths)
-            {
-                if (dirPath.equals("/WEB-INF/"))
-                {
-                    // Look on /WEB-INF/<flow-Name>/<flowName>-flow.xml
-                    Set<String> webDirectoryPaths = _externalContext.getResourcePaths(dirPath);
-                    for (String webDirPath : webDirectoryPaths)
-                    {
-                        if (webDirPath.endsWith("/") && 
-                            !webDirPath.equals("/WEB-INF/classes/"))
-                        {
-                            String flowName = webDirPath.substring(9, webDirPath.length() - 1);
-                            String filePath = webDirPath+flowName+"-flow.xml";
-                            if (!contextSpecifiedList.contains(filePath))
-                            {
-                                resModified = getResourceLastModified(filePath);
-                                if (resModified > lastModified)
-                                {
-                                    lastModified = resModified;
-                                }
-                            }
-                        }
-                    }
-                }
-                else if (!dirPath.startsWith("/META-INF") && dirPath.endsWith("/"))
-                {
-                    // Look on /<flowName>/<flowName>-flow.xml
-                    String flowName = dirPath.substring(1, dirPath.length() - 1);
-                    String filePath = dirPath+flowName+"-flow.xml";
-                    if (!contextSpecifiedList.contains(filePath))
-                    {
-                        resModified = getResourceLastModified(filePath);
-                        if (resModified > lastModified)
-                        {
-                            lastModified = resModified;
-                        }
-                    }
-                }                
-            }
-        }
-        
-        return lastModified;
-    }
-
-    public void update()
-    {
-        long refreshPeriod = (MyfacesConfig.getCurrentInstance(_externalContext).getConfigRefreshPeriod()) * 1000;
-        if (refreshPeriod > 0)
-        {
-            long ttl = lastUpdate + refreshPeriod;
-            if ((System.currentTimeMillis() > ttl) && (getLastModifiedTime() > ttl))
-            {
-                boolean purged = false;
-                try
-                {
-                    purged = purgeConfiguration();
-                }
-                catch (NoSuchMethodException e)
-                {
-                    log.severe("Configuration objects do not support clean-up. Update aborted");
-
-                    // We still want to update the timestamp to avoid running purge on every subsequent
-                    // request after this one.
-                    //
-                    lastUpdate = System.currentTimeMillis();
-
-                    return;
-                }
-                catch (IllegalAccessException | InvocationTargetException e)
-                {
-                    log.severe("Error during configuration clean-up" + e.getMessage());
-                }
-                if (purged)
-                {
-                    configure();
-                    
-                    // JSF 2.0 Publish PostConstructApplicationEvent after all configuration resources
-                    // has been parsed and processed
-                    FacesContext facesContext = getFacesContext();
-                    Application application = facesContext.getApplication();
-
-                    application.publishEvent(facesContext, PostConstructApplicationEvent.class,
-                            Application.class, application);
-                }
-            }
-        }
-    }
-
-    private boolean purgeConfiguration() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
-    {
-
-        Method appFactoryPurgeMethod;
-        Method renderKitPurgeMethod;
-        Method lifecyclePurgeMethod;
-        Method facesContextPurgeMethod;
-
-        // Check that we have access to all of the necessary purge methods before purging anything
-        //
-        ApplicationFactory applicationFactory
-                = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
-        appFactoryPurgeMethod = getPurgeMethod(applicationFactory, "purgeApplication", NO_PARAMETER_TYPES);
-
-        RenderKitFactory renderKitFactory
-                = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-        renderKitPurgeMethod = getPurgeMethod(renderKitFactory, "purgeRenderKit", NO_PARAMETER_TYPES);
-
-        LifecycleFactory lifecycleFactory
-                = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
-        lifecyclePurgeMethod = getPurgeMethod(lifecycleFactory, "purgeLifecycle", NO_PARAMETER_TYPES);
-
-        FacesContext facesContext = getFacesContext();
-        facesContextPurgeMethod = getPurgeMethod(facesContext, "purgeFacesContext", NO_PARAMETER_TYPES);
-        
-        // If there was no exception so far, now we can purge
-        //
-        if (appFactoryPurgeMethod != null && renderKitPurgeMethod != null && lifecyclePurgeMethod != null && 
-            facesContextPurgeMethod != null)
-        {
-            appFactoryPurgeMethod.invoke(applicationFactory, NO_PARAMETERS);
-            renderKitPurgeMethod.invoke(renderKitFactory, NO_PARAMETERS);
-            RuntimeConfig.getCurrentInstance(_externalContext).purge();
-            lifecyclePurgeMethod.invoke(lifecycleFactory, NO_PARAMETERS);
-            facesContextPurgeMethod.invoke(facesContext, NO_PARAMETERS);
-
-            // factories and serial factory need not be purged...
-
-            // Remove first request processed so we can initialize it again
-            _externalContext.getApplicationMap().remove(LifecycleImpl.FIRST_REQUEST_PROCESSED_PARAM);
-            return true;
-        }
-        return false;
-    }
-    
-    private Method getPurgeMethod(Object instance, String methodName, Class<?>[] parameters)
-    {
-        while (instance != null)
-        {
-            Method purgeMethod = null;
-            try
-            {
-                purgeMethod = instance.getClass().getMethod(methodName, parameters);
-            }
-            catch (NoSuchMethodException e)
-            {
-                // No op, it is expected to found this case, so in that case
-                // look for the parent to do the purge
-            }
-            if (purgeMethod != null)
-            {
-                return purgeMethod;
-            }
-            if (instance instanceof FacesWrapper)
-            {
-                instance = ((FacesWrapper)instance).getWrapped();
-            }
-        }
-        return null;
-    }
-
-    public void configure() throws FacesException
-    {
-        // get FacesConfigurationMerger SPI implementation
-        FacesConfigurationMerger facesConfigurationMerger = FacesConfigurationMergerFactory
-                .getFacesConfigurationMergerFactory(_externalContext).getFacesConfigurationMerger(_externalContext);
-
-        // get all faces-config data, merge it and set it as Dispenser
-        setDispenser(facesConfigurationMerger.getFacesConfigData(_externalContext));
-
-        configureFactories();
-        configureApplication();
-        configureRenderKits();
-
-        configureRuntimeConfig();
-        configureLifecycle();
-        handleSerialFactory();
-        configureFlowHandler();
-
-        configureProtectedViews();
-        
-        // record the time of update
-        lastUpdate = System.currentTimeMillis();
-    }
-
-    private List<String> getConfigFilesList()
-    {
-        String configFiles = _externalContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
-        List<String> configFilesList = new ArrayList<>();
-        if (configFiles != null)
-        {
-            StringTokenizer st = new StringTokenizer(configFiles, ",", false);
-            while (st.hasMoreTokens())
-            {
-                String systemId = st.nextToken().trim();
-
-                if (DEFAULT_FACES_CONFIG.equals(systemId))
-                {
-                    if (log.isLoggable(Level.WARNING))
-                    {
-                        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");
-                    }
-                }
-                else
-                {
-                    configFilesList.add(systemId);
-                }
-            }
-        }
-        return configFilesList;
-    }
-
-    private void configureFactories()
-    {
-        FacesConfigData dispenser = getDispenser();
-        setFactories(FactoryFinder.APPLICATION_FACTORY, dispenser.getApplicationFactoryIterator(),
-                DEFAULT_APPLICATION_FACTORY);
-        setFactories(FactoryFinder.EXCEPTION_HANDLER_FACTORY, dispenser.getExceptionHandlerFactoryIterator(),
-                DEFAULT_EXCEPTION_HANDLER_FACTORY);
-        setFactories(FactoryFinder.EXTERNAL_CONTEXT_FACTORY, dispenser.getExternalContextFactoryIterator(),
-                DEFAULT_EXTERNAL_CONTEXT_FACTORY);
-        setFactories(FactoryFinder.FACES_CONTEXT_FACTORY, dispenser.getFacesContextFactoryIterator(),
-                DEFAULT_FACES_CONTEXT_FACTORY);
-        setFactories(FactoryFinder.LIFECYCLE_FACTORY, dispenser.getLifecycleFactoryIterator(),
-                DEFAULT_LIFECYCLE_FACTORY);
-        setFactories(FactoryFinder.RENDER_KIT_FACTORY, dispenser.getRenderKitFactoryIterator(),
-                DEFAULT_RENDER_KIT_FACTORY);
-        setFactories(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY, dispenser.getTagHandlerDelegateFactoryIterator(),
-                DEFAULT_TAG_HANDLER_DELEGATE_FACTORY);
-        setFactories(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, dispenser.getPartialViewContextFactoryIterator(),
-                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);
-        setFactories(FactoryFinder.FACELET_CACHE_FACTORY, dispenser.getFaceletCacheFactoryIterator(),
-                DEFAULT_FACELET_CACHE_FACTORY);
-        setFactories(FactoryFinder.FLASH_FACTORY, dispenser.getFlashFactoryIterator(),
-                DEFAULT_FLASH_FACTORY);
-        setFactories(FactoryFinder.CLIENT_WINDOW_FACTORY, dispenser.getClientWindowFactoryIterator(),
-                DEFAULT_CLIENT_WINDOW_FACTORY);
-        setFactories(FactoryFinder.FLOW_HANDLER_FACTORY, dispenser.getFlowHandlerFactoryIterator(),
-                DEFAULT_FLOW_FACTORY);
-        setFactories(FactoryFinder.SEARCH_EXPRESSION_CONTEXT_FACTORY, 
-                dispenser.getSearchExpressionContextFactoryIterator(),
-                DEFAULT_SEARCH_EXPRESSION_CONTEXT_FACTORY);
-    }
-
-    private void setFactories(String factoryName, Collection<String> factories, String defaultFactory)
-    {
-        FactoryFinder.setFactory(factoryName, defaultFactory);
-        for (String factory : factories)
-        {
-            if (!factory.equals(defaultFactory))
-            {
-                FactoryFinder.setFactory(factoryName, factory);
-            }
-        }
-    }
-
-    private void configureApplication()
-    {
-        Application application = ((ApplicationFactory)
-                FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
-
-        FacesConfigData dispenser = getDispenser();
-        ActionListener actionListener = ClassUtils.buildApplicationObject(ActionListener.class,
-                dispenser.getActionListenerIterator(), null);
-        _callInjectAndPostConstruct(actionListener);
-        application.setActionListener(actionListener);
-
-        if (dispenser.getDefaultLocale() != null)
-        {
-            application.setDefaultLocale(LocaleUtils.toLocale(dispenser.getDefaultLocale()));
-        }
-
-        if (dispenser.getDefaultRenderKitId() != null)
-        {
-            application.setDefaultRenderKitId(dispenser.getDefaultRenderKitId());
-        }
-
-        if (dispenser.getMessageBundle() != null)
-        {
-            application.setMessageBundle(dispenser.getMessageBundle());
-        }
-        
-        // First build the object
-        NavigationHandler navigationHandler = ClassUtils.buildApplicationObject(NavigationHandler.class,
-                ConfigurableNavigationHandler.class, null,
-                dispenser.getNavigationHandlerIterator(),
-                application.getNavigationHandler());
-        // Invoke inject and post construct
-        _callInjectAndPostConstruct(navigationHandler);
-        // Finally wrap the object with the BackwardsCompatibleNavigationHandlerWrapper if it is not assignable
-        // from ConfigurableNavigationHandler
-        navigationHandler = ClassUtils.wrapBackwardCompatible(NavigationHandler.class,
-                ConfigurableNavigationHandler.class,
-                BackwardsCompatibleNavigationHandlerWrapper.class,
-                application.getNavigationHandler(),
-                navigationHandler);
-        application.setNavigationHandler(navigationHandler);
-
-        StateManager stateManager = ClassUtils.buildApplicationObject(StateManager.class,
-                dispenser.getStateManagerIterator(),
-                application.getStateManager());
-        _callInjectAndPostConstruct(stateManager);
-        application.setStateManager(stateManager);
-
-        ResourceHandler resourceHandler = ClassUtils.buildApplicationObject(ResourceHandler.class,
-                dispenser.getResourceHandlerIterator(),
-                application.getResourceHandler());
-        _callInjectAndPostConstruct(resourceHandler);
-        application.setResourceHandler(resourceHandler);
-
-        List<Locale> locales = new ArrayList<>();
-        for (String locale : dispenser.getSupportedLocalesIterator())
-        {
-            locales.add(LocaleUtils.toLocale(locale));
-        }
-
-        application.setSupportedLocales(locales);
-
-        application.setViewHandler(ClassUtils.buildApplicationObject(ViewHandler.class,
-                dispenser.getViewHandlerIterator(),
-                application.getViewHandler()));
-        
-        application.setSearchExpressionHandler(ClassUtils.buildApplicationObject(SearchExpressionHandler.class,
-                dispenser.getSearchExpressionHandlerIterator(),
-                application.getSearchExpressionHandler()));
-                
-        for (SystemEventListener systemEventListener : dispenser.getSystemEventListeners())
-        {
-            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());
-
-                jakarta.faces.event.SystemEventListener listener = (jakarta.faces.event.SystemEventListener) 
-                        ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass());
-                _callInjectAndPostConstruct(listener);
-                if (systemEventListener.getSourceClass() != null && systemEventListener.getSourceClass().length() > 0)
-                {
-                    application.subscribeToEvent(
-                            (Class<? extends SystemEvent>) eventClass,
-                            ClassUtils.classForName(systemEventListener.getSourceClass()),
-                                    listener);
-                }
-                else
-                {
-                    application.subscribeToEvent((Class<? extends SystemEvent>) eventClass, listener);
-                }
-            }
-            catch (ClassNotFoundException e)
-            {
-                log.log(Level.SEVERE, "System event listener could not be initialized, reason:", e);
-            }
-        }
-
-        for (Map.Entry<String, String> entry : dispenser.getComponentClassesByType().entrySet())
-        {
-            application.addComponent(entry.getKey(), entry.getValue());
-        }
-
-        for (Map.Entry<String, String> entry : dispenser.getConverterClassesById().entrySet())
-        {
-            application.addConverter(entry.getKey(), entry.getValue());
-        }
-
-        for (Map.Entry<String, String> entry : dispenser.getConverterClassesByClass().entrySet())
-        {
-            try
-            {
-                application.addConverter(ClassUtils.classForName(entry.getKey()),
-                        entry.getValue());
-            }
-            catch (Exception ex)
-            {
-                log.log(Level.SEVERE, "Converter could not be added. Reason:", ex);
-            }
-        }
-
-        for (Map.Entry<String, String> entry : dispenser.getValidatorClassesById().entrySet())
-        {
-            application.addValidator(entry.getKey(), entry.getValue());
-        }
-
-        // programmatically add the BeanValidator if the following requirements are met:
-        //     - bean validation has not been disabled
-        //     - bean validation is available in the classpath
-        String beanValidatorDisabled = _externalContext.getInitParameter(
-                BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME);
-        final boolean defaultBeanValidatorDisabled = (beanValidatorDisabled != null
-                && beanValidatorDisabled.toLowerCase().equals("true"));
-        boolean beanValidatorInstalledProgrammatically = false;
-        if (!defaultBeanValidatorDisabled
-                && ExternalSpecifications.isBeanValidationAvailable())
-        {
-            // add the BeanValidator as default validator
-            application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID);
-            beanValidatorInstalledProgrammatically = true;
-        }
-
-        // add the default-validators from the config files
-        for (String validatorId : dispenser.getDefaultValidatorIds())
-        {
-            application.addDefaultValidatorId(validatorId);
-        }
-
-        // do some checks if the BeanValidator was not installed as a
-        // default-validator programmatically, but via a config file.
-        if (!beanValidatorInstalledProgrammatically
-                && application.getDefaultValidatorInfo()
-                .containsKey(BeanValidator.VALIDATOR_ID))
-        {
-            if (!ExternalSpecifications.isBeanValidationAvailable())
-            {
-                // the BeanValidator was installed via a config file,
-                // but bean validation is not available
-                log.log(Level.WARNING, "The BeanValidator was installed as a " +
-                        "default-validator from a faces-config file, but bean " +
-                        "validation is not available on the classpath, " +
-                        "thus it will not work!");
-            }
-            else if (defaultBeanValidatorDisabled)
-            {
-                // the user disabled the default bean validator in web.xml,
-                // but a config file added it, which is ok with the spec
-                // (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 " +
-                        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())
-        {
-            application.addBehavior(behavior.getBehaviorId(), behavior.getBehaviorClass());
-        }
-        
-        //JSF 2.2 set FlowHandler from factory. 
-        FlowHandlerFactory flowHandlerFactory = (FlowHandlerFactory) 
-            FactoryFinder.getFactory(FactoryFinder.FLOW_HANDLER_FACTORY);
-        FlowHandler flowHandler = flowHandlerFactory.createFlowHandler(
-            getFacesContext());
-        application.setFlowHandler(flowHandler);
-        
-        for (ContractMapping mapping : dispenser.getResourceLibraryContractMappings())
-        {
-            List<String> urlMappingsList = mapping.getUrlPatternList();
-            for (String urlPattern: urlMappingsList)
-            {
-                for (String contract : mapping.getContractList())
-                {
-                    String[] contracts = StringUtils.trim(StringUtils.splitShortString(contract, ' '));
-                    _runtimeConfig.addContractMapping(urlPattern, contracts);
-                }
-            }
-        }
-        
-        this.setApplication(application);
-    }
-
-    private void _callInjectAndPostConstruct(Object instance)
-    {
-        try
-        {
-            //invoke the injection over the inner one first
-            if (instance instanceof FacesWrapper)
-            {
-                Object innerInstance = ((FacesWrapper) instance).getWrapped();
-                if (innerInstance != null)
-                {
-                    _callInjectAndPostConstruct(innerInstance);
-                }
-            }
-            List<BeanEntry> injectedBeanStorage = (List<BeanEntry>) _externalContext.getApplicationMap()
-                    .get(FacesInitializerImpl.INJECTED_BEAN_STORAGE_KEY);
-
-            Object creationMetaData = getInjectionProvider().inject(instance);
-
-            injectedBeanStorage.add(new BeanEntry(instance, creationMetaData));
-
-            getInjectionProvider().postConstruct(instance, creationMetaData);
-        }
-        catch (InjectionProviderException ex)
-        {
-            log.log(Level.INFO, "Exception on Injection or PostConstruct", ex);
-        }
-    }
-
-    private void configureRuntimeConfig()
-    {
-        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
-        FacesConfigData dispenser = getDispenser();
-        List<String> knownNamespaces = new ArrayList<>();
-        
-        for (ComponentTagDeclaration declaration : dispenser.getComponentTagDeclarations())
-        {
-            runtimeConfig.addComponentTagDeclaration(declaration);
-            if (declaration.getNamespace() != null)
-            {
-                knownNamespaces.add(declaration.getNamespace());
-            }
-        }
-
-        for (NavigationRule rule : dispenser.getNavigationRules())
-        {
-            runtimeConfig.addNavigationRule(rule);
-        }
-
-        for (String converterClassName : dispenser.getConverterConfigurationByClassName())
-        {
-            runtimeConfig.addConverterConfiguration(converterClassName,
-                    _dispenser.getConverterConfiguration(converterClassName));
-        }
-
-        for (ResourceBundle bundle : dispenser.getResourceBundles())
-        {
-            runtimeConfig.addResourceBundle(bundle);
-        }
-
-        for (String className : dispenser.getElResolvers())
-        {
-            ELResolver elResolver = (ELResolver) ClassUtils.newInstance(className, ELResolver.class);
-            _callInjectAndPostConstruct(elResolver);
-            runtimeConfig.addFacesConfigElResolver(elResolver);
-        }
-        
-        for (String className : dispenser.getSearchKeywordResolvers())
-        {
-            SearchKeywordResolver searchKeywordResolver = (SearchKeywordResolver) ClassUtils.newInstance(
-                    className, SearchKeywordResolver.class);
-            
-            runtimeConfig.addApplicationSearchExpressionResolver(searchKeywordResolver);
-        }
-
-        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);
-            }
-        }
-
-        String elResolverComparatorClass = _myfacesConfig.getElResolverComparator();
-        if (elResolverComparatorClass != null && !elResolverComparatorClass.isEmpty())
-        {
-            try
-            {
-                Class<Comparator<ELResolver>> clazz = ClassUtils.classForName(elResolverComparatorClass);
-                Comparator<ELResolver> comparator = ClassUtils.newInstance(clazz);
-                runtimeConfig.setELResolverComparator(comparator);
-            }
-            catch (Exception e)
-            {
-                if (log.isLoggable(Level.SEVERE))
-                {
-                    log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator " + elResolverComparatorClass
-                            + " . Check " + MyfacesConfig.EL_RESOLVER_COMPARATOR + " web config param. "
-                            + "Initialization continues with no comparator used.", e);
-                }
-            }
-        }
-        else
-        {
-            runtimeConfig.setELResolverComparator(null);
-        }
-
-        String elResolverPredicateClass = _myfacesConfig.getElResolverPredicate();
-        if (elResolverPredicateClass != null && !elResolverPredicateClass.isEmpty())
-        {
-            try
-            {
-                Class<?> clazz = ClassUtils.classForName(elResolverPredicateClass);
-                Object elResolverPredicate = ClassUtils.newInstance(clazz);
-                if (elResolverPredicate instanceof Predicate)
-                {
-                    runtimeConfig.setELResolverPredicate((Predicate) elResolverPredicate);
-                }
-                else
-                {
-                    if (log.isLoggable(Level.SEVERE))
-                    {
-                        log.log(Level.SEVERE, "EL Resolver Predicate " + elResolverPredicateClass
-                                + " must implement " + Predicate.class.getName()
-                                + " . Check " + MyfacesConfig.EL_RESOLVER_PREDICATE + " web config param. "
-                                + "Initialization continues with no predicate used.");
-                    }
-                }
-            }
-            catch (Exception e)
-            {
-                if (log.isLoggable(Level.SEVERE))
-                {
-                    log.log(Level.SEVERE, "Cannot instantiate EL Resolver Predicate " + elResolverPredicateClass
-                            + " . Check " + MyfacesConfig.EL_RESOLVER_PREDICATE + " web config param. "
-                            + "Initialization continues with no predicate used.", e);
-                }
-            }
-        }
-        else
-        {
-            runtimeConfig.setELResolverPredicate(null);
-        }
-
-        for (FaceletsProcessing faceletsProcessing : dispenser.getFaceletsProcessing())
-        {
-            runtimeConfig.addFaceletProcessingConfiguration(faceletsProcessing.getFileExtension(), faceletsProcessing);
-        }
-        
-        ResourceLibraryContractsProvider rlcp = ResourceLibraryContractsProviderFactory.
-            getFacesConfigResourceProviderFactory(_externalContext).
-            createResourceLibraryContractsProvider(_externalContext);
-        
-        try
-        {
-            // JSF 2.2 section 11.4.2.1 scan for available resource library contracts
-            // and store the result in a internal data structure, so it can be used 
-            // later in ViewDeclarationLanguage.calculateResourceLibraryContracts(
-            //   FacesContext context, String viewId)
-            runtimeConfig.setExternalContextResourceLibraryContracts(
-                rlcp.getExternalContextResourceLibraryContracts(_externalContext));
-            runtimeConfig.setClassLoaderResourceLibraryContracts(
-                rlcp.getClassloaderResourceLibraryContracts(_externalContext));
-        }
-        catch (Exception e)
-        {
-            if (log.isLoggable(Level.SEVERE))
-            {
-                log.log(Level.SEVERE, 
-                    "An error was found when scanning for resource library contracts", e);
-            }
-        }
-        
-        
-        // JSF 2.2 section 11.4.2.1 check all contracts are loaded
-        if (log.isLoggable(Level.INFO))
-        {
-            for (List<String> list : runtimeConfig.getContractMappings().values())
-            {
-                for (String contract : list)
-                {
-                    if (!runtimeConfig.getResourceLibraryContracts().contains(contract))
-                    {
-                        log.log(Level.INFO, 
-                            "Resource Library Contract "+ contract + " was not found while scanning for "
-                            + "available contracts.");
-                    }
-                }
-            }
-        }
-        
-        // JSF 2.2 section 11.4.2.1 if no contractMappings set, all available contracts applies
-        // to all views.
-        if (runtimeConfig.getContractMappings().isEmpty())
-        {
-            String[] contracts = runtimeConfig.getResourceLibraryContracts().toArray(
-                new String[runtimeConfig.getResourceLibraryContracts().size()]);
-            runtimeConfig.addContractMapping("*", contracts);
-        }
-        
-        for (String resourceResolver : dispenser.getResourceResolvers())
-        {
-            runtimeConfig.addResourceResolver(resourceResolver);
-        }
-        
-        for (FaceletTagLibrary faceletTagLibrary : dispenser.getTagLibraries())
-        {
-            runtimeConfig.addFaceletTagLibrary(faceletTagLibrary);
-            if (faceletTagLibrary.getNamespace() != null)
-            {
-                knownNamespaces.add(faceletTagLibrary.getNamespace());
-            }
-        }
-        
-        // Add default namespaces to the known namespaces
-        knownNamespaces.add("http://xmlns.jcp.org/jsf/core");
-        knownNamespaces.add("http://java.sun.com/jsf/core");
-        knownNamespaces.add("http://xmlns.jcp.org/jsf/html");
-        knownNamespaces.add("http://java.sun.com/jsf/html");
-        knownNamespaces.add("http://xmlns.jcp.org/jsf/facelets");
-        knownNamespaces.add("http://java.sun.com/jsf/facelets");
-        knownNamespaces.add("http://xmlns.jcp.org/jsp/jstl/core");
-        knownNamespaces.add("http://java.sun.com/jsp/jstl/core");
-        knownNamespaces.add("http://java.sun.com/jstl/core");
-        knownNamespaces.add("http://xmlns.jcp.org/jsp/jstl/functions");
-        knownNamespaces.add("http://java.sun.com/jsp/jstl/functions");
-        knownNamespaces.add("http://xmlns.jcp.org/jsf/composite");
-        knownNamespaces.add("http://java.sun.com/jsf/composite");
-        knownNamespaces.add("http://xmlns.jcp.org/jsf");
-        knownNamespaces.add("http://java.sun.com/jsf");
-        knownNamespaces.add("http://xmlns.jcp.org/jsf/passthrough");
-        knownNamespaces.add("http://java.sun.com/jsf/passthrough");
-        
-        Map<Integer, String> namespaceById = new HashMap<>();
-        Map<String, Integer> idByNamespace = new HashMap<>();
-        // Sort them to ensure the same id 
-        Collections.sort(knownNamespaces);
-        for (int i = 0; i < knownNamespaces.size(); i++)
-        {
-            namespaceById.put(i, knownNamespaces.get(i));
-            idByNamespace.put(knownNamespaces.get(i), i);
-        }
-        runtimeConfig.setNamespaceById(Collections.unmodifiableMap(namespaceById));
-        runtimeConfig.setIdByNamespace(Collections.unmodifiableMap(idByNamespace));
-        
-        for (ViewPoolMapping viewPoolMapping : dispenser.getViewPoolMappings())
-        {
-            runtimeConfig.addViewPoolMapping(viewPoolMapping);
-        }
-        
-        for (FaceletsTemplateMapping faceletsTemplateMapping : dispenser.getFaceletsTemplateMappings())
-        {
-            runtimeConfig.addFaceletsTemplateMapping(faceletsTemplateMapping);
-        }
-    }
-
-    private void configureRenderKits()
-    {
-        RenderKitFactory renderKitFactory
-                = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-
-        FacesConfigData dispenser = getDispenser();
-        for (String renderKitId : dispenser.getRenderKitIds())
-        {
-            Collection<String> renderKitClass = dispenser.getRenderKitClasses(renderKitId);
-
-            if (renderKitClass.isEmpty())
-            {
-                renderKitClass = new ArrayList<>(1);
-                renderKitClass.add(DEFAULT_RENDER_KIT_CLASS);
-            }
-
-            RenderKit renderKit = (RenderKit) ClassUtils.buildApplicationObject(RenderKit.class, renderKitClass, null);
-            // If the default html RenderKit instance is wrapped, the top level object will not implement
-            // LazyRenderKit and all renderers will be added using the standard form.
-            boolean lazyRenderKit = renderKit instanceof LazyRenderKit;
-
-            for (Renderer element : dispenser.getRenderers(renderKitId))
-            {
-                jakarta.faces.render.Renderer renderer;
-                
-                if (element.getRendererClass() != null)
-                {
-                    if (lazyRenderKit)
-                    {
-                        // Add renderer using LazyRenderKit interface. This will have the effect of improve startup
-                        // time avoiding load renderer classes that are not used.
-                        ((LazyRenderKit) renderKit).addRenderer(element.getComponentFamily(), 
-                            element.getRendererType(), element.getRendererClass());
-                    }
-                    else
-                    {
-                        // Use standard form
-                        try
-                        {
-                            renderer = (jakarta.faces.render.Renderer) ClassUtils.newInstance(
-                                element.getRendererClass());
-                        }
-                        catch (Throwable e)
-                        {
-                            // ignore the failure so that the render kit is configured
-                            log.log(Level.SEVERE, "failed to configure class " + element.getRendererClass(), e);
-                            continue;
-                        }
-                        if (renderer != null)
-                        {
-                            renderKit.addRenderer(element.getComponentFamily(), element.getRendererType(), renderer);
-                        }
-                        else
-                        {
-                            log.log(Level.INFO, "Renderer instance cannot be created for "+
-                                    element.getRendererClass()+ ", ignoring..." + 
-                                    element.getRendererClass());
-                        }
-                    }
-                }
-                else
-                {
-                        log.log(Level.INFO, "Renderer element with no rendererClass found, ignoring..." +
-                                element.getRendererClass());
-                }
-
-            }
-            
-            Collection<ClientBehaviorRenderer> clientBehaviorRenderers
-                    = dispenser.getClientBehaviorRenderers(renderKitId);
-
-            // Add in client behavior renderers.
-
-            for (ClientBehaviorRenderer clientBehaviorRenderer : clientBehaviorRenderers)
-            {
-                try
-                {
-                    jakarta.faces.render.ClientBehaviorRenderer behaviorRenderer
-                            = (jakarta.faces.render.ClientBehaviorRenderer)
-                            ClassUtils.newInstance(clientBehaviorRenderer.getRendererClass());
-
-                    renderKit.addClientBehaviorRenderer(clientBehaviorRenderer.getRendererType(), behaviorRenderer);
-                }
-
-                catch (Throwable e)
-                {
-                    // Ignore.
-
-                    if (log.isLoggable(Level.SEVERE))
-                    {
-                        log.log(Level.SEVERE, "failed to configure client behavior renderer class " +
-                                clientBehaviorRenderer.getRendererClass(), e);
-                    }
-                }
-            }
-
-            renderKitFactory.addRenderKit(renderKitId, renderKit);
-        }
-    }
-
-    private void configureLifecycle()
-    {
-        // create the lifecycle used by the app
-        LifecycleFactory lifecycleFactory
-                = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
-
-        for (Iterator<String> it = lifecycleFactory.getLifecycleIds(); it.hasNext();)
-        {
-            Lifecycle lifecycle = lifecycleFactory.getLifecycle(it.next());
-            
-            // add phase listeners
-            for (String listenerClassName : getDispenser().getLifecyclePhaseListeners())
-            {
-                try
-                {
-                    PhaseListener listener = (PhaseListener)
-                            ClassUtils.newInstance(listenerClassName, PhaseListener.class);
-                    _callInjectAndPostConstruct(listener);
-                    lifecycle.addPhaseListener(listener);
-                }
-                catch (ClassCastException e)
-                {
-                    log.severe("Class " + listenerClassName + " does not implement PhaseListener");
-                }
-            }
-
-            // if ProjectStage is Development, install the DebugPhaseListener
-            FacesContext facesContext = getFacesContext();
-            if (facesContext.isProjectStage(ProjectStage.Development)
-                    && _myfacesConfig.isDebugPhaseListenerEnabled())
-            {
-                lifecycle.addPhaseListener(new DebugPhaseListener());
-            }
-        }
-    }
-
-
-    private void handleSerialFactory()
-    {
-        String serialProvider = _externalContext.getInitParameter(StateUtils.SERIAL_FACTORY);
-        SerialFactory serialFactory = null;
-
-        if (serialProvider == null)
-        {
-            serialFactory = new DefaultSerialFactory();
-        }
-        else
-        {
-            try
-            {
-                serialFactory = (SerialFactory) ClassUtils.newInstance(serialProvider);
-
-            }
-            catch (ClassCastException e)
-            {
-                log.log(Level.SEVERE, "Make sure '" + serialProvider + "' implements the correct interface", e);
-            }
-            catch (Exception e)
-            {
-                log.log(Level.SEVERE, "", e);
-            }
-            finally
-            {
-                if (serialFactory == null)
-                {
-                    serialFactory = new DefaultSerialFactory();
-                    log.severe("Using default serialization provider");
-                }
-            }
-
-        }
-
-        log.fine("Serialization provider : " + serialFactory.getClass());
-        _externalContext.getApplicationMap().put(StateUtils.SERIAL_FACTORY, serialFactory);
-    }
-
-    private void configureFlowHandler()
-    {
-        FacesContext facesContext = getFacesContext();
-        Application application = getApplication();
-        
-        FacesConfigData dispenser = getDispenser();
-        
-        if (!dispenser.getFacesFlowDefinitions().isEmpty())
-        {
-            // Faces Flow require client window enabled to work.
-            FacesConfigurator.enableDefaultWindowMode(facesContext);
-        }
-        
-        for (FacesFlowDefinition flowDefinition : dispenser.getFacesFlowDefinitions())
-        {
-            FlowImpl flow = new FlowImpl();
-            
-            // TODO: configure flow object
-            flow.setId(flowDefinition.getId());
-            flow.setDefiningDocumentId(flowDefinition.getDefiningDocumentId());
-            
-            flow.setStartNodeId(flowDefinition.getStartNode());
-            
-            if (StringUtils.isNotEmpty(flowDefinition.getInitializer()))
-            {
-                flow.setInitializer(application.getExpressionFactory().createMethodExpression(
-                    facesContext.getELContext(), flowDefinition.getInitializer(), null, NO_PARAMETER_TYPES));
-            }
-            if (StringUtils.isNotEmpty(flowDefinition.getFinalizer()))
-            {
-                flow.setFinalizer(application.getExpressionFactory().createMethodExpression(
-                    facesContext.getELContext(), flowDefinition.getFinalizer(), null, NO_PARAMETER_TYPES));
-            }
-            
-            for (FacesFlowCall call : flowDefinition.getFlowCallList())
-            {
-                FlowCallNodeImpl node = new FlowCallNodeImpl(call.getId());
-                if (call.getFlowReference() != null)
-                {
-                    node.setCalledFlowId(call.getFlowReference().getFlowId());
-                    node.setCalledFlowDocumentId(call.getFlowReference().getFlowDocumentId());
-                }
-
-                for (FacesFlowParameter parameter : call.getOutboundParameterList())
-                {
-                    node.putOutboundParameter( parameter.getName(),
-                        new ParameterImpl(parameter.getName(),
-                        application.getExpressionFactory().createValueExpression(
-                            facesContext.getELContext(), parameter.getValue(), Object.class)) );
-                }
-                flow.putFlowCall(node.getId(), node);
-            }
-
-            for (FacesFlowMethodCall methodCall : flowDefinition.getMethodCallList())
-            {
-                MethodCallNodeImpl node = new MethodCallNodeImpl(methodCall.getId());
-                if (StringUtils.isNotEmpty(methodCall.getMethod()))
-                {
-                    node.setMethodExpression(
-                        application.getExpressionFactory().createMethodExpression(
-                            facesContext.getELContext(), methodCall.getMethod(), null, NO_PARAMETER_TYPES));
-                }
-                if (StringUtils.isNotEmpty(methodCall.getDefaultOutcome()))
-                {
-                    node.setOutcome(
-                        application.getExpressionFactory().createValueExpression(
-                                facesContext.getELContext(), methodCall.getDefaultOutcome(), Object.class));
-                }
-                for (FacesFlowMethodParameter parameter : methodCall.getParameterList())
-                {
-                    node.addParameter(
-                        new ParameterImpl(parameter.getClassName(),
-                        application.getExpressionFactory().createValueExpression(
-                            facesContext.getELContext(), parameter.getValue(), Object.class)) );
-                }
-                flow.addMethodCall(node);
-            }
-            
-            for (FacesFlowParameter parameter : flowDefinition.getInboundParameterList())
-            {
-                flow.putInboundParameter(parameter.getName(),
-                    new ParameterImpl(parameter.getName(),
-                    application.getExpressionFactory().createValueExpression(
-                        facesContext.getELContext(), parameter.getValue(), Object.class)) );
-            }
-            
-            for (NavigationRule rule : flowDefinition.getNavigationRuleList())
-            {
-                flow.addNavigationCases(rule.getFromViewId(), NavigationUtils.convertNavigationCasesToAPI(rule));
-            }
-            
-            for (FacesFlowSwitch flowSwitch : flowDefinition.getSwitchList())
-            {
-                SwitchNodeImpl node = new SwitchNodeImpl(flowSwitch.getId());
-                
-                if (flowSwitch.getDefaultOutcome() != null &&
-                    StringUtils.isNotEmpty(flowSwitch.getDefaultOutcome().getFromOutcome()))
-                {
-                    if (ELText.isLiteral(flowSwitch.getDefaultOutcome().getFromOutcome()))
-                    {
-                        node.setDefaultOutcome(flowSwitch.getDefaultOutcome().getFromOutcome());
-                    }
-                    else
-                    {
-                        node.setDefaultOutcome(
-                            application.getExpressionFactory().createValueExpression(
-                                facesContext.getELContext(), flowSwitch.getDefaultOutcome().getFromOutcome(),
-                                Object.class));
-                    }
-                }
-                
-                for (NavigationCase navCase : flowSwitch.getNavigationCaseList())
-                {
-                    SwitchCaseImpl nodeCase = new SwitchCaseImpl();
-                    nodeCase.setFromOutcome(navCase.getFromOutcome());
-                    if (StringUtils.isNotEmpty(navCase.getIf()))
-                    {
-                        nodeCase.setCondition(
-                            application.getExpressionFactory().createValueExpression(
-                                facesContext.getELContext(), navCase.getIf(),
-                                Object.class));
-                    }
-                    node.addCase(nodeCase);
-                }
-                
-                flow.putSwitch(node.getId(), node);
-            }
-            
-            for (FacesFlowView view : flowDefinition.getViewList())
-            {
-                ViewNodeImpl node = new ViewNodeImpl(view.getId(), view.getVdlDocument());
-                flow.addView(node);
-            }
-
-            for (FacesFlowReturn flowReturn : flowDefinition.getReturnList())
-            {
-                ReturnNodeImpl node = new ReturnNodeImpl(flowReturn.getId());
-                if (flowReturn.getNavigationCase() != null &&
-                    StringUtils.isNotEmpty(flowReturn.getNavigationCase().getFromOutcome()))
-                {
-                    if (ELText.isLiteral(flowReturn.getNavigationCase().getFromOutcome()))
-                    {
-                        node.setFromOutcome(flowReturn.getNavigationCase().getFromOutcome());
-                    }
-                    else
-                    {
-                        node.setFromOutcome(
-                            application.getExpressionFactory().createValueExpression(
-                                facesContext.getELContext(), flowReturn.getNavigationCase().getFromOutcome(),
-                                Object.class));
-                    }
-                }
-                flow.putReturn(node.getId(), node);
-            }
-            
-            flow.freeze();
-            
-            // Add the flow, so the config can be processed by the flow system and the
-            // navigation system.
-            application.getFlowHandler().addFlow(facesContext, flow);
-        }
-        
-        configureAnnotatedFlows(facesContext);
-    }
-    
-    public static void configureAnnotatedFlows(FacesContext facesContext)
-    {
-        FacesFlowProviderFactory factory = 
-            FacesFlowProviderFactory.getFacesFlowProviderFactory(facesContext.getExternalContext());
-        FacesFlowProvider provider = factory.getFacesFlowProvider(facesContext.getExternalContext());
-        
-        Iterator<Flow> it = provider.getAnnotatedFlows(facesContext);
-        if (it == null)
-        {
-            return;
-        }
-
-        if (it.hasNext())
-        {
-            enableDefaultWindowMode(facesContext);
-        }
-        while (it.hasNext())
-        {
-            Flow flow = it.next();
-            if (flow instanceof FlowImpl)
-            {
-                ((FlowImpl) flow).freeze();
-            }
-            facesContext.getApplication().getFlowHandler().addFlow(facesContext, flow);
-        }
-    }
-    
-    public static void enableDefaultWindowMode(FacesContext facesContext)
-    {
-        if (!isEnableDefaultWindowMode(facesContext))
-        {
-            String windowMode = WebConfigParamUtils.getStringInitParameter(
-                    facesContext.getExternalContext(), 
-                    ClientWindow.CLIENT_WINDOW_MODE_PARAM_NAME, null);
-            
-            if (windowMode == null)
-            {
-                //No window mode set, force window mode to url
-                String defaultWindowMode = WebConfigParamUtils.getStringInitParameter(
-                    facesContext.getExternalContext(), 
-                    ClientWindowFactoryImpl.INIT_PARAM_DEFAULT_WINDOW_MODE, 
-                    ClientWindowFactoryImpl.WINDOW_MODE_URL);
-                
-                log.info("The current configuration requires client window enabled, setting it to '"+
-                    defaultWindowMode+ '\'');
-                
-                facesContext.getExternalContext().getApplicationMap().put(
-                    ENABLE_DEFAULT_WINDOW_MODE, Boolean.TRUE);
-            }
-        }
-    }
-    
-    public static boolean isEnableDefaultWindowMode(FacesContext facesContext)
-    {
-        return Boolean.TRUE.equals(facesContext.getExternalContext().
-            getApplicationMap().get(ENABLE_DEFAULT_WINDOW_MODE));
-    }
-
-    public void configureProtectedViews()
-    {
-        Application application = getApplication();
-
-        FacesConfigData dispenser = getDispenser();
-        //Protected Views
-        ViewHandler viewHandler = application.getViewHandler();
-        for (String urlPattern : dispenser.getProtectedViewUrlPatterns())
-        {
-            viewHandler.addProtectedView(urlPattern);
-        }
-    }
-    
-    protected InjectionProvider getInjectionProvider()
-    {
-        if (_injectionProvider == null)
-        {
-            _injectionProvider = InjectionProviderFactory.getInjectionProviderFactory(
-                _externalContext).getInjectionProvider(_externalContext);
-        }
-        return _injectionProvider;
-    }
-    
-    protected FacesContext getFacesContext()
-    {
-        if (_facesContext == null)
-        {
-            _facesContext = FacesContext.getCurrentInstance();
-        }
-        return _facesContext;
-    }
-    
-    protected Application getApplication()
-    {
-        if (_application == null)
-        {
-            return getFacesContext().getApplication();
-        }
-        return _application;
-    }
-    
-    protected void setApplication(Application application)
-    {
-        this._application = application;
-    }
-}
+/*
+ * 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.config;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.function.Predicate;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import jakarta.el.ELResolver;
+import jakarta.faces.FacesException;
+import jakarta.faces.FacesWrapper;
+import jakarta.faces.FactoryFinder;
+import jakarta.faces.application.Application;
+import jakarta.faces.application.ApplicationFactory;
+import jakarta.faces.application.ConfigurableNavigationHandler;
+import jakarta.faces.application.NavigationHandler;
+import jakarta.faces.application.ProjectStage;
+import jakarta.faces.application.ResourceHandler;
+import jakarta.faces.application.StateManager;
+import jakarta.faces.application.ViewHandler;
+import jakarta.faces.component.search.SearchExpressionHandler;
+import jakarta.faces.component.search.SearchKeywordResolver;
+import jakarta.faces.context.ExternalContext;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.event.ActionListener;
+import jakarta.faces.event.ComponentSystemEvent;
+import jakarta.faces.event.PhaseListener;
+import jakarta.faces.event.PostConstructApplicationEvent;
+import jakarta.faces.event.SystemEvent;
+import jakarta.faces.flow.Flow;
+import jakarta.faces.flow.FlowHandler;
+import jakarta.faces.flow.FlowHandlerFactory;
+import jakarta.faces.lifecycle.ClientWindow;
+import jakarta.faces.lifecycle.Lifecycle;
+import jakarta.faces.lifecycle.LifecycleFactory;
+import jakarta.faces.render.RenderKit;
+import jakarta.faces.render.RenderKitFactory;
+import jakarta.faces.validator.BeanValidator;
+import jakarta.faces.webapp.FacesServlet;
+
+import org.apache.myfaces.application.ApplicationFactoryImpl;
+import org.apache.myfaces.application.BackwardsCompatibleNavigationHandlerWrapper;
+import org.apache.myfaces.component.visit.VisitContextFactoryImpl;
+import org.apache.myfaces.config.element.Behavior;
+import org.apache.myfaces.config.element.ClientBehaviorRenderer;
+import org.apache.myfaces.config.element.ComponentTagDeclaration;
+import org.apache.myfaces.config.element.ContractMapping;
+import org.apache.myfaces.config.element.FaceletsProcessing;
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.config.element.FacesConfigData;
+import org.apache.myfaces.config.element.FacesFlowCall;
+import org.apache.myfaces.config.element.FacesFlowDefinition;
+import org.apache.myfaces.config.element.FacesFlowMethodCall;
+import org.apache.myfaces.config.element.FacesFlowMethodParameter;
+import org.apache.myfaces.config.element.FacesFlowParameter;
+import org.apache.myfaces.config.element.FacesFlowReturn;
+import org.apache.myfaces.config.element.FacesFlowSwitch;
+import org.apache.myfaces.config.element.FacesFlowView;
+import org.apache.myfaces.config.element.NamedEvent;
+import org.apache.myfaces.config.element.NavigationCase;
+import org.apache.myfaces.config.element.NavigationRule;
+import org.apache.myfaces.config.element.Renderer;
+import org.apache.myfaces.config.element.ResourceBundle;
+import org.apache.myfaces.config.element.SystemEventListener;
+import org.apache.myfaces.config.impl.FacesConfigDispenserImpl;
+import org.apache.myfaces.context.ExceptionHandlerFactoryImpl;
+import org.apache.myfaces.context.ExternalContextFactoryImpl;
+import org.apache.myfaces.context.FacesContextFactoryImpl;
+import org.apache.myfaces.context.PartialViewContextFactoryImpl;
+import org.apache.myfaces.context.servlet.ServletFlashFactoryImpl;
+import org.apache.myfaces.lifecycle.clientwindow.ClientWindowFactoryImpl;
+import org.apache.myfaces.flow.FlowCallNodeImpl;
+import org.apache.myfaces.flow.FlowHandlerFactoryImpl;
+import org.apache.myfaces.flow.FlowImpl;
+import org.apache.myfaces.flow.MethodCallNodeImpl;
+import org.apache.myfaces.flow.ParameterImpl;
+import org.apache.myfaces.flow.ReturnNodeImpl;
+import org.apache.myfaces.flow.SwitchCaseImpl;
+import org.apache.myfaces.flow.SwitchNodeImpl;
+import org.apache.myfaces.flow.ViewNodeImpl;
+import org.apache.myfaces.lifecycle.LifecycleFactoryImpl;
+import org.apache.myfaces.renderkit.RenderKitFactoryImpl;
+import org.apache.myfaces.renderkit.html.HtmlRenderKitImpl;
+import org.apache.myfaces.resource.ResourceLoaderUtils;
+import org.apache.myfaces.util.lang.ClassUtils;
+import org.apache.myfaces.util.LocaleUtils;
+import org.apache.myfaces.application.viewstate.StateUtils;
+import org.apache.myfaces.util.lang.StringUtils;
+import org.apache.myfaces.util.WebConfigParamUtils;
+import org.apache.myfaces.cdi.util.BeanEntry;
+import org.apache.myfaces.component.search.SearchExpressionContextFactoryImpl;
+import org.apache.myfaces.config.element.FaceletsTemplateMapping;
+import org.apache.myfaces.config.element.ViewPoolMapping;
+import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
+import org.apache.myfaces.config.impl.FacesConfigUnmarshallerImpl;
+import org.apache.myfaces.lifecycle.LifecycleImpl;
+import org.apache.myfaces.renderkit.LazyRenderKit;
+import org.apache.myfaces.spi.impl.DefaultSerialFactory;
+import org.apache.myfaces.spi.SerialFactory;
+import org.apache.myfaces.spi.FacesConfigurationMerger;
+import org.apache.myfaces.spi.FacesConfigurationMergerFactory;
+import org.apache.myfaces.spi.FacesFlowProvider;
+import org.apache.myfaces.spi.FacesFlowProviderFactory;
+import org.apache.myfaces.spi.InjectionProvider;
+import org.apache.myfaces.spi.InjectionProviderException;
+import org.apache.myfaces.spi.InjectionProviderFactory;
+import org.apache.myfaces.spi.ResourceLibraryContractsProvider;
+import org.apache.myfaces.spi.ResourceLibraryContractsProviderFactory;
+import org.apache.myfaces.util.ExternalSpecifications;
+import org.apache.myfaces.util.NavigationUtils;
+import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl;
+import org.apache.myfaces.view.facelets.el.ELText;
+import org.apache.myfaces.view.facelets.impl.FaceletCacheFactoryImpl;
+import org.apache.myfaces.view.facelets.tag.faces.TagHandlerDelegateFactoryImpl;
+import org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener;
+import org.apache.myfaces.webapp.FacesInitializerImpl;
+
+/**
+ * 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$
+ */
+@SuppressWarnings("deprecation")
+public class FacesConfigurator
+{
+    private final Class<?>[] NO_PARAMETER_TYPES = new Class[]{};
+    private final Object[] NO_PARAMETERS = new Object[]{};
+
+    private static final Logger log = Logger.getLogger(FacesConfigurator.class.getName());
+
+    private static final String DEFAULT_RENDER_KIT_CLASS = HtmlRenderKitImpl.class.getName();
+    private static final String DEFAULT_APPLICATION_FACTORY = ApplicationFactoryImpl.class.getName();
+    private static final String DEFAULT_EXTERNAL_CONTEXT_FACTORY = ExternalContextFactoryImpl.class.getName();
+    private static final String DEFAULT_FACES_CONTEXT_FACTORY = FacesContextFactoryImpl.class.getName();
+    private static final String DEFAULT_LIFECYCLE_FACTORY = LifecycleFactoryImpl.class.getName();
+    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_EXCEPTION_HANDLER_FACTORY = ExceptionHandlerFactoryImpl.class.getName();
+    private static final String DEFAULT_TAG_HANDLER_DELEGATE_FACTORY = TagHandlerDelegateFactoryImpl.class.getName();
+    private static final String DEFAULT_FACELET_CACHE_FACTORY = FaceletCacheFactoryImpl.class.getName();
+    private static final String DEFAULT_FLASH_FACTORY = ServletFlashFactoryImpl.class.getName();
+    private static final String DEFAULT_CLIENT_WINDOW_FACTORY = ClientWindowFactoryImpl.class.getName();
+    private static final String DEFAULT_FLOW_FACTORY = FlowHandlerFactoryImpl.class.getName();
+    private static final String DEFAULT_SEARCH_EXPRESSION_CONTEXT_FACTORY = 
+            SearchExpressionContextFactoryImpl.class.getName();
+    private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";
+
+    /**
+     * Set this attribute if the current configuration requires enable window mode
+     */
+    public static final String ENABLE_DEFAULT_WINDOW_MODE = 
+        "org.apache.myfaces.ENABLE_DEFAULT_WINDOW_MODE";
+
+    private final ExternalContext _externalContext;
+    private FacesContext _facesContext;
+    private FacesConfigUnmarshaller<? extends FacesConfig> _unmarshaller;
+    private FacesConfigData _dispenser;
+
+    private RuntimeConfig _runtimeConfig;
+    private MyfacesConfig _myfacesConfig;
+    
+    private Application _application;
+    
+    private InjectionProvider _injectionProvider;
+
+    private static long lastUpdate;
+
+    public FacesConfigurator(ExternalContext externalContext)
+    {
+        if (externalContext == null)
+        {
+            throw new IllegalArgumentException("external context must not be null");
+        }
+        _externalContext = externalContext;
+
+        // In dev mode a new Faces Configurator is created for every request so only
+        // create a new bean storage list if we don't already have one which will be
+        // the case first time through during init.
+        if (_externalContext.getApplicationMap().get(FacesInitializerImpl.INJECTED_BEAN_STORAGE_KEY) == null)
+        {
+            _externalContext.getApplicationMap().put(FacesInitializerImpl.INJECTED_BEAN_STORAGE_KEY,
+                    new CopyOnWriteArrayList());
+        }
+        
+        _myfacesConfig = MyfacesConfig.getCurrentInstance(_externalContext);
+        _runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
+    }
+
+    /**
+     * @param unmarshaller
+     *            the unmarshaller to set
+     */
+    public void setUnmarshaller(FacesConfigUnmarshaller<? extends FacesConfig> unmarshaller)
+    {
+        _unmarshaller = unmarshaller;
+    }
+
+    /**
+     * @return the unmarshaller
+     */
+    protected FacesConfigUnmarshaller<? extends FacesConfig> getUnmarshaller()
+    {
+        if (_unmarshaller == null)
+        {
+            _unmarshaller = new FacesConfigUnmarshallerImpl(_externalContext);
+        }
+
+        return _unmarshaller;
+    }
+
+    /**
+     * @param dispenser
+     *            the dispenser to set
+     */
+    public void setDispenser(FacesConfigData dispenser)
+    {
+        _dispenser = dispenser;
+    }
+
+    /**
+     * @return the dispenser
+     */
+    protected FacesConfigData getDispenser()
+    {
+        if (_dispenser == null)
+        {
+            _dispenser = new FacesConfigDispenserImpl();
+        }
+
+        return _dispenser;
+    }
+
+    private long getResourceLastModified(String resource)
+    {
+        try
+        {
+            URL url = _externalContext.getResource(resource);
+            if (url != null)
+            {
+                return ResourceLoaderUtils.getResourceLastModified(url);
+            }
+        }
+        catch (IOException e)
+        {
+            log.log(Level.SEVERE, "Could not read lastModified " + resource, e);
+        }
+        return 0;
+    }
+
+    private long getLastModifiedTime()
+    {
+        long lastModified = 0;
+        long resModified;
+
+        resModified = getResourceLastModified(DEFAULT_FACES_CONFIG);
+        if (resModified > lastModified)
+        {
+            lastModified = resModified;
+        }
+
+        // perf: method getConfigFilesList() creates a ArrayList    
+        List<String> configFilesList = getConfigFilesList();
+        for (int i = 0, size = configFilesList.size(); i < size; i++)
+        {
+            String systemId = configFilesList.get(i);
+            resModified = getResourceLastModified(systemId);
+            if (resModified > lastModified)
+            {
+                lastModified = resModified;
+            }
+        }
+        
+        // get last modified from .taglib.xml
+        String faceletsFiles = WebConfigParamUtils.getStringInitParameter(_externalContext,
+                ViewHandler.FACELETS_LIBRARIES_PARAM_NAME);
+        if (faceletsFiles != null)
+        {
+            String[] faceletFilesList = StringUtils.trim(faceletsFiles.split(";"));
+            for (int i = 0, size = faceletFilesList.length; i < size; i++)
+            {
+                String systemId = faceletFilesList[i];
+                resModified = getResourceLastModified(systemId);
+                if (resModified > lastModified)
+                {
+                    lastModified = resModified;
+                }
+            }
+        }
+        
+        // get last modified from -flow.xml
+        Set<String> directoryPaths = _externalContext.getResourcePaths("/");
+        if (directoryPaths != null)
+        {
+            List<String> contextSpecifiedList = configFilesList;
+            for (String dirPath : directoryPaths)
+            {
+                if (dirPath.equals("/WEB-INF/"))
+                {
+                    // Look on /WEB-INF/<flow-Name>/<flowName>-flow.xml
+                    Set<String> webDirectoryPaths = _externalContext.getResourcePaths(dirPath);
+                    for (String webDirPath : webDirectoryPaths)
+                    {
+                        if (webDirPath.endsWith("/") && 
+                            !webDirPath.equals("/WEB-INF/classes/"))
+                        {
+                            String flowName = webDirPath.substring(9, webDirPath.length() - 1);
+                            String filePath = webDirPath+flowName+"-flow.xml";
+                            if (!contextSpecifiedList.contains(filePath))
+                            {
+                                resModified = getResourceLastModified(filePath);
+                                if (resModified > lastModified)
+                                {
+                                    lastModified = resModified;
+                                }
+                            }
+                        }
+                    }
+                }
+                else if (!dirPath.startsWith("/META-INF") && dirPath.endsWith("/"))
+                {
+                    // Look on /<flowName>/<flowName>-flow.xml
+                    String flowName = dirPath.substring(1, dirPath.length() - 1);
+                    String filePath = dirPath+flowName+"-flow.xml";
+                    if (!contextSpecifiedList.contains(filePath))
+                    {
+                        resModified = getResourceLastModified(filePath);
+                        if (resModified > lastModified)
+                        {
+                            lastModified = resModified;
+                        }
+                    }
+                }                
+            }
+        }
+        
+        return lastModified;
+    }
+
+    public void update()
+    {
+        long refreshPeriod = (MyfacesConfig.getCurrentInstance(_externalContext).getConfigRefreshPeriod()) * 1000;
+        if (refreshPeriod > 0)
+        {
+            long ttl = lastUpdate + refreshPeriod;
+            if ((System.currentTimeMillis() > ttl) && (getLastModifiedTime() > ttl))
+            {
+                boolean purged = false;
+                try
+                {
+                    purged = purgeConfiguration();
+                }
+                catch (NoSuchMethodException e)
+                {
+                    log.severe("Configuration objects do not support clean-up. Update aborted");
+
+                    // We still want to update the timestamp to avoid running purge on every subsequent
+                    // request after this one.
+                    //
+                    lastUpdate = System.currentTimeMillis();
+
+                    return;
+                }
+                catch (IllegalAccessException | InvocationTargetException e)
+                {
+                    log.severe("Error during configuration clean-up" + e.getMessage());
+                }
+                if (purged)
+                {
+                    configure();
+                    
+                    // JSF 2.0 Publish PostConstructApplicationEvent after all configuration resources
+                    // has been parsed and processed
+                    FacesContext facesContext = getFacesContext();
+                    Application application = facesContext.getApplication();
+
+                    application.publishEvent(facesContext, PostConstructApplicationEvent.class,
+                            Application.class, application);
+                }
+            }
+        }
+    }
+
+    private boolean purgeConfiguration() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
+    {
+
+        Method appFactoryPurgeMethod;
+        Method renderKitPurgeMethod;
+        Method lifecyclePurgeMethod;
+        Method facesContextPurgeMethod;
+
+        // Check that we have access to all of the necessary purge methods before purging anything
+        //
+        ApplicationFactory applicationFactory
+                = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        appFactoryPurgeMethod = getPurgeMethod(applicationFactory, "purgeApplication", NO_PARAMETER_TYPES);
+
+        RenderKitFactory renderKitFactory
+                = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+        renderKitPurgeMethod = getPurgeMethod(renderKitFactory, "purgeRenderKit", NO_PARAMETER_TYPES);
+
+        LifecycleFactory lifecycleFactory
+                = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+        lifecyclePurgeMethod = getPurgeMethod(lifecycleFactory, "purgeLifecycle", NO_PARAMETER_TYPES);
+
+        FacesContext facesContext = getFacesContext();
+        facesContextPurgeMethod = getPurgeMethod(facesContext, "purgeFacesContext", NO_PARAMETER_TYPES);
+        
+        // If there was no exception so far, now we can purge
+        //
+        if (appFactoryPurgeMethod != null && renderKitPurgeMethod != null && lifecyclePurgeMethod != null && 
+            facesContextPurgeMethod != null)
+        {
+            appFactoryPurgeMethod.invoke(applicationFactory, NO_PARAMETERS);
+            renderKitPurgeMethod.invoke(renderKitFactory, NO_PARAMETERS);
+            RuntimeConfig.getCurrentInstance(_externalContext).purge();
+            lifecyclePurgeMethod.invoke(lifecycleFactory, NO_PARAMETERS);
+            facesContextPurgeMethod.invoke(facesContext, NO_PARAMETERS);
+
+            // factories and serial factory need not be purged...
+
+            // Remove first request processed so we can initialize it again
+            _externalContext.getApplicationMap().remove(LifecycleImpl.FIRST_REQUEST_PROCESSED_PARAM);
+            return true;
+        }
+        return false;
+    }
+    
+    private Method getPurgeMethod(Object instance, String methodName, Class<?>[] parameters)
+    {
+        while (instance != null)
+        {
+            Method purgeMethod = null;
+            try
+            {
+                purgeMethod = instance.getClass().getMethod(methodName, parameters);
+            }
+            catch (NoSuchMethodException e)
+            {
+                // No op, it is expected to found this case, so in that case
+                // look for the parent to do the purge
+            }
+            if (purgeMethod != null)
+            {
+                return purgeMethod;
+            }
+            if (instance instanceof FacesWrapper)
+            {
+                instance = ((FacesWrapper)instance).getWrapped();
+            }
+        }
+        return null;
+    }
+
+    public void configure() throws FacesException
+    {
+        // get FacesConfigurationMerger SPI implementation
+        FacesConfigurationMerger facesConfigurationMerger = FacesConfigurationMergerFactory
+                .getFacesConfigurationMergerFactory(_externalContext).getFacesConfigurationMerger(_externalContext);
+
+        // get all faces-config data, merge it and set it as Dispenser
+        setDispenser(facesConfigurationMerger.getFacesConfigData(_externalContext));
+
+        configureFactories();
+        configureApplication();
+        configureRenderKits();
+
+        configureRuntimeConfig();
+        configureLifecycle();
+        handleSerialFactory();
+        configureFlowHandler();
+
+        configureProtectedViews();
+        
+        // record the time of update
+        lastUpdate = System.currentTimeMillis();
+    }
+
+    private List<String> getConfigFilesList()
+    {
+        String configFiles = _externalContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
+        List<String> configFilesList = new ArrayList<>();
+        if (configFiles != null)
+        {
+            StringTokenizer st = new StringTokenizer(configFiles, ",", false);
+            while (st.hasMoreTokens())
+            {
+                String systemId = st.nextToken().trim();
+
+                if (DEFAULT_FACES_CONFIG.equals(systemId))
+                {
+                    if (log.isLoggable(Level.WARNING))
+                    {
+                        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");
+                    }
+                }
+                else
+                {
+                    configFilesList.add(systemId);
+                }
+            }
+        }
+        return configFilesList;
+    }
+
+    private void configureFactories()
+    {
+        FacesConfigData dispenser = getDispenser();
+        setFactories(FactoryFinder.APPLICATION_FACTORY, dispenser.getApplicationFactoryIterator(),
+                DEFAULT_APPLICATION_FACTORY);
+        setFactories(FactoryFinder.EXCEPTION_HANDLER_FACTORY, dispenser.getExceptionHandlerFactoryIterator(),
+                DEFAULT_EXCEPTION_HANDLER_FACTORY);
+        setFactories(FactoryFinder.EXTERNAL_CONTEXT_FACTORY, dispenser.getExternalContextFactoryIterator(),
+                DEFAULT_EXTERNAL_CONTEXT_FACTORY);
+        setFactories(FactoryFinder.FACES_CONTEXT_FACTORY, dispenser.getFacesContextFactoryIterator(),
+                DEFAULT_FACES_CONTEXT_FACTORY);
+        setFactories(FactoryFinder.LIFECYCLE_FACTORY, dispenser.getLifecycleFactoryIterator(),
+                DEFAULT_LIFECYCLE_FACTORY);
+        setFactories(FactoryFinder.RENDER_KIT_FACTORY, dispenser.getRenderKitFactoryIterator(),
+                DEFAULT_RENDER_KIT_FACTORY);
+        setFactories(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY, dispenser.getTagHandlerDelegateFactoryIterator(),
+                DEFAULT_TAG_HANDLER_DELEGATE_FACTORY);
+        setFactories(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, dispenser.getPartialViewContextFactoryIterator(),
+                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);
+        setFactories(FactoryFinder.FACELET_CACHE_FACTORY, dispenser.getFaceletCacheFactoryIterator(),
+                DEFAULT_FACELET_CACHE_FACTORY);
+        setFactories(FactoryFinder.FLASH_FACTORY, dispenser.getFlashFactoryIterator(),
+                DEFAULT_FLASH_FACTORY);
+        setFactories(FactoryFinder.CLIENT_WINDOW_FACTORY, dispenser.getClientWindowFactoryIterator(),
+                DEFAULT_CLIENT_WINDOW_FACTORY);
+        setFactories(FactoryFinder.FLOW_HANDLER_FACTORY, dispenser.getFlowHandlerFactoryIterator(),
+                DEFAULT_FLOW_FACTORY);
+        setFactories(FactoryFinder.SEARCH_EXPRESSION_CONTEXT_FACTORY, 
+                dispenser.getSearchExpressionContextFactoryIterator(),
+                DEFAULT_SEARCH_EXPRESSION_CONTEXT_FACTORY);
+    }
+
+    private void setFactories(String factoryName, Collection<String> factories, String defaultFactory)
+    {
+        FactoryFinder.setFactory(factoryName, defaultFactory);
+        for (String factory : factories)
+        {
+            if (!factory.equals(defaultFactory))
+            {
+                FactoryFinder.setFactory(factoryName, factory);
+            }
+        }
+    }
+
+    private void configureApplication()
+    {
+        Application application = ((ApplicationFactory)
+                FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+
+        FacesConfigData dispenser = getDispenser();
+        ActionListener actionListener = ClassUtils.buildApplicationObject(ActionListener.class,
+                dispenser.getActionListenerIterator(), null);
+        _callInjectAndPostConstruct(actionListener);
+        application.setActionListener(actionListener);
+
+        if (dispenser.getDefaultLocale() != null)
+        {
+            application.setDefaultLocale(LocaleUtils.toLocale(dispenser.getDefaultLocale()));
+        }
+
+        if (dispenser.getDefaultRenderKitId() != null)
+        {
+            application.setDefaultRenderKitId(dispenser.getDefaultRenderKitId());
+        }
+
+        if (dispenser.getMessageBundle() != null)
+        {
+            application.setMessageBundle(dispenser.getMessageBundle());
+        }
+        
+        // First build the object
+        NavigationHandler navigationHandler = ClassUtils.buildApplicationObject(NavigationHandler.class,
+                ConfigurableNavigationHandler.class, null,
+                dispenser.getNavigationHandlerIterator(),
+                application.getNavigationHandler());
+        // Invoke inject and post construct
+        _callInjectAndPostConstruct(navigationHandler);
+        // Finally wrap the object with the BackwardsCompatibleNavigationHandlerWrapper if it is not assignable
+        // from ConfigurableNavigationHandler
+        navigationHandler = ClassUtils.wrapBackwardCompatible(NavigationHandler.class,
+                ConfigurableNavigationHandler.class,
+                BackwardsCompatibleNavigationHandlerWrapper.class,
+                application.getNavigationHandler(),
+                navigationHandler);
+        application.setNavigationHandler(navigationHandler);
+
+        StateManager stateManager = ClassUtils.buildApplicationObject(StateManager.class,
+                dispenser.getStateManagerIterator(),
+                application.getStateManager());
+        _callInjectAndPostConstruct(stateManager);
+        application.setStateManager(stateManager);
+
+        ResourceHandler resourceHandler = ClassUtils.buildApplicationObject(ResourceHandler.class,
+                dispenser.getResourceHandlerIterator(),
+                application.getResourceHandler());
+        _callInjectAndPostConstruct(resourceHandler);
+        application.setResourceHandler(resourceHandler);
+
+        List<Locale> locales = new ArrayList<>();
+        for (String locale : dispenser.getSupportedLocalesIterator())
+        {
+            locales.add(LocaleUtils.toLocale(locale));
+        }
+
+        application.setSupportedLocales(locales);
+
+        application.setViewHandler(ClassUtils.buildApplicationObject(ViewHandler.class,
+                dispenser.getViewHandlerIterator(),
+                application.getViewHandler()));
+        
+        application.setSearchExpressionHandler(ClassUtils.buildApplicationObject(SearchExpressionHandler.class,
+                dispenser.getSearchExpressionHandlerIterator(),
+                application.getSearchExpressionHandler()));
+                
+        for (SystemEventListener systemEventListener : dispenser.getSystemEventListeners())
+        {
+            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());
+
+                jakarta.faces.event.SystemEventListener listener = (jakarta.faces.event.SystemEventListener) 
+                        ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass());
+                _callInjectAndPostConstruct(listener);
+                if (systemEventListener.getSourceClass() != null && systemEventListener.getSourceClass().length() > 0)
+                {
+                    application.subscribeToEvent(
+                            (Class<? extends SystemEvent>) eventClass,
+                            ClassUtils.classForName(systemEventListener.getSourceClass()),
+                                    listener);
+                }
+                else
+                {
+                    application.subscribeToEvent((Class<? extends SystemEvent>) eventClass, listener);
+                }
+            }
+            catch (ClassNotFoundException e)
+            {
+                log.log(Level.SEVERE, "System event listener could not be initialized, reason:", e);
+            }
+        }
+
+        for (Map.Entry<String, String> entry : dispenser.getComponentClassesByType().entrySet())
+        {
+            application.addComponent(entry.getKey(), entry.getValue());
+        }
+
+        for (Map.Entry<String, String> entry : dispenser.getConverterClassesById().entrySet())
+        {
+            application.addConverter(entry.getKey(), entry.getValue());
+        }
+
+        for (Map.Entry<String, String> entry : dispenser.getConverterClassesByClass().entrySet())
+        {
+            try
+            {
+                application.addConverter(ClassUtils.classForName(entry.getKey()),
+                        entry.getValue());
+            }
+            catch (Exception ex)
+            {
+                log.log(Level.SEVERE, "Converter could not be added. Reason:", ex);
+            }
+        }
+
+        for (Map.Entry<String, String> entry : dispenser.getValidatorClassesById().entrySet())
+        {
+            application.addValidator(entry.getKey(), entry.getValue());
+        }
+
+        // programmatically add the BeanValidator if the following requirements are met:
+        //     - bean validation has not been disabled
+        //     - bean validation is available in the classpath
+        String beanValidatorDisabled = _externalContext.getInitParameter(
+                BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME);
+        final boolean defaultBeanValidatorDisabled = (beanValidatorDisabled != null
+                && beanValidatorDisabled.toLowerCase().equals("true"));
+        boolean beanValidatorInstalledProgrammatically = false;
+        if (!defaultBeanValidatorDisabled
+                && ExternalSpecifications.isBeanValidationAvailable())
+        {
+            // add the BeanValidator as default validator
+            application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID);
+            beanValidatorInstalledProgrammatically = true;
+        }
+
+        // add the default-validators from the config files
+        for (String validatorId : dispenser.getDefaultValidatorIds())
+        {
+            application.addDefaultValidatorId(validatorId);
+        }
+
+        // do some checks if the BeanValidator was not installed as a
+        // default-validator programmatically, but via a config file.
+        if (!beanValidatorInstalledProgrammatically
+                && application.getDefaultValidatorInfo()
+                .containsKey(BeanValidator.VALIDATOR_ID))
+        {
+            if (!ExternalSpecifications.isBeanValidationAvailable())
+            {
+                // the BeanValidator was installed via a config file,
+                // but bean validation is not available
+                log.log(Level.WARNING, "The BeanValidator was installed as a " +
+                        "default-validator from a faces-config file, but bean " +
+                        "validation is not available on the classpath, " +
+                        "thus it will not work!");
+            }
+            else if (defaultBeanValidatorDisabled)
+            {
+                // the user disabled the default bean validator in web.xml,
+                // but a config file added it, which is ok with the spec
+                // (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 " +
+                        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())
+        {
+            application.addBehavior(behavior.getBehaviorId(), behavior.getBehaviorClass());
+        }
+        
+        //JSF 2.2 set FlowHandler from factory. 
+        FlowHandlerFactory flowHandlerFactory = (FlowHandlerFactory) 
+            FactoryFinder.getFactory(FactoryFinder.FLOW_HANDLER_FACTORY);
+        FlowHandler flowHandler = flowHandlerFactory.createFlowHandler(
+            getFacesContext());
+        application.setFlowHandler(flowHandler);
+        
+        for (ContractMapping mapping : dispenser.getResourceLibraryContractMappings())
+        {
+            List<String> urlMappingsList = mapping.getUrlPatternList();
+            for (String urlPattern: urlMappingsList)
+            {
+                for (String contract : mapping.getContractList())
+                {
+                    String[] contracts = StringUtils.trim(StringUtils.splitShortString(contract, ' '));
+                    _runtimeConfig.addContractMapping(urlPattern, contracts);
+                }
+            }
+        }
+        
+        this.setApplication(application);
+    }
+
+    private void _callInjectAndPostConstruct(Object instance)
+    {
+        try
+        {
+            //invoke the injection over the inner one first
+            if (instance instanceof FacesWrapper)
+            {
+                Object innerInstance = ((FacesWrapper) instance).getWrapped();
+                if (innerInstance != null)
+                {
+                    _callInjectAndPostConstruct(innerInstance);
+                }
+            }
+            List<BeanEntry> injectedBeanStorage = (List<BeanEntry>) _externalContext.getApplicationMap()
+                    .get(FacesInitializerImpl.INJECTED_BEAN_STORAGE_KEY);
+
+            Object creationMetaData = getInjectionProvider().inject(instance);
+
+            injectedBeanStorage.add(new BeanEntry(instance, creationMetaData));
+
+            getInjectionProvider().postConstruct(instance, creationMetaData);
+        }
+        catch (InjectionProviderException ex)
+        {
+            log.log(Level.INFO, "Exception on Injection or PostConstruct", ex);
+        }
+    }
+
+    private void configureRuntimeConfig()
+    {
+        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
+        FacesConfigData dispenser = getDispenser();
+        List<String> knownNamespaces = new ArrayList<>();
+        
+        for (ComponentTagDeclaration declaration : dispenser.getComponentTagDeclarations())
+        {
+            runtimeConfig.addComponentTagDeclaration(declaration);
+            if (declaration.getNamespace() != null)
+            {
+                knownNamespaces.add(declaration.getNamespace());
+            }
+        }
+
+        for (NavigationRule rule : dispenser.getNavigationRules())
+        {
+            runtimeConfig.addNavigationRule(rule);
+        }
+
+        for (String converterClassName : dispenser.getConverterConfigurationByClassName())
+        {
+            runtimeConfig.addConverterConfiguration(converterClassName,
+                    _dispenser.getConverterConfiguration(converterClassName));
+        }
+
+        for (ResourceBundle bundle : dispenser.getResourceBundles())
+        {
+            runtimeConfig.addResourceBundle(bundle);
+        }
+
+        for (String className : dispenser.getElResolvers())
+        {
+            ELResolver elResolver = (ELResolver) ClassUtils.newInstance(className, ELResolver.class);
+            _callInjectAndPostConstruct(elResolver);
+            runtimeConfig.addFacesConfigElResolver(elResolver);
+        }
+        
+        for (String className : dispenser.getSearchKeywordResolvers())
+        {
+            SearchKeywordResolver searchKeywordResolver = (SearchKeywordResolver) ClassUtils.newInstance(
+                    className, SearchKeywordResolver.class);
+            
+            runtimeConfig.addApplicationSearchExpressionResolver(searchKeywordResolver);
+        }
+
+        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);
+            }
+        }
+
+        String elResolverComparatorClass = _myfacesConfig.getElResolverComparator();
+        if (elResolverComparatorClass != null && !elResolverComparatorClass.isEmpty())
+        {
+            try
+            {
+                Class<Comparator<ELResolver>> clazz = ClassUtils.classForName(elResolverComparatorClass);
+                Comparator<ELResolver> comparator = ClassUtils.newInstance(clazz);
+                runtimeConfig.setELResolverComparator(comparator);
+            }
+            catch (Exception e)
+            {
+                if (log.isLoggable(Level.SEVERE))
+                {
+                    log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator " + elResolverComparatorClass
+                            + " . Check " + MyfacesConfig.EL_RESOLVER_COMPARATOR + " web config param. "
+                            + "Initialization continues with no comparator used.", e);
+                }
+            }
+        }
+        else
+        {
+            runtimeConfig.setELResolverComparator(null);
+        }
+
+        String elResolverPredicateClass = _myfacesConfig.getElResolverPredicate();
+        if (elResolverPredicateClass != null && !elResolverPredicateClass.isEmpty())
+        {
+            try
+            {
+                Class<?> clazz = ClassUtils.classForName(elResolverPredicateClass);
+                Object elResolverPredicate = ClassUtils.newInstance(clazz);
+                if (elResolverPredicate instanceof Predicate)
+                {
+                    runtimeConfig.setELResolverPredicate((Predicate) elResolverPredicate);
+                }
+                else
+                {
+                    if (log.isLoggable(Level.SEVERE))
+                    {
+                        log.log(Level.SEVERE, "EL Resolver Predicate " + elResolverPredicateClass
+                                + " must implement " + Predicate.class.getName()
+                                + " . Check " + MyfacesConfig.EL_RESOLVER_PREDICATE + " web config param. "
+                                + "Initialization continues with no predicate used.");
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                if (log.isLoggable(Level.SEVERE))
+                {
+                    log.log(Level.SEVERE, "Cannot instantiate EL Resolver Predicate " + elResolverPredicateClass
+                            + " . Check " + MyfacesConfig.EL_RESOLVER_PREDICATE + " web config param. "
+                            + "Initialization continues with no predicate used.", e);
+                }
+            }
+        }
+        else
+        {
+            runtimeConfig.setELResolverPredicate(null);
+        }
+
+        for (FaceletsProcessing faceletsProcessing : dispenser.getFaceletsProcessing())
+        {
+            runtimeConfig.addFaceletProcessingConfiguration(faceletsProcessing.getFileExtension(), faceletsProcessing);
+        }
+        
+        ResourceLibraryContractsProvider rlcp = ResourceLibraryContractsProviderFactory.
+            getFacesConfigResourceProviderFactory(_externalContext).
+            createResourceLibraryContractsProvider(_externalContext);
+        
+        try
+        {
+            // JSF 2.2 section 11.4.2.1 scan for available resource library contracts
+            // and store the result in a internal data structure, so it can be used 
+            // later in ViewDeclarationLanguage.calculateResourceLibraryContracts(
+            //   FacesContext context, String viewId)
+            runtimeConfig.setExternalContextResourceLibraryContracts(
+                rlcp.getExternalContextResourceLibraryContracts(_externalContext));
+            runtimeConfig.setClassLoaderResourceLibraryContracts(
+                rlcp.getClassloaderResourceLibraryContracts(_externalContext));
+        }
+        catch (Exception e)
+        {
+            if (log.isLoggable(Level.SEVERE))
+            {
+                log.log(Level.SEVERE, 
+                    "An error was found when scanning for resource library contracts", e);
+            }
+        }
+        
+        
+        // JSF 2.2 section 11.4.2.1 check all contracts are loaded
+        if (log.isLoggable(Level.INFO))
+        {
+            for (List<String> list : runtimeConfig.getContractMappings().values())
+            {
+                for (String contract : list)
+                {
+                    if (!runtimeConfig.getResourceLibraryContracts().contains(contract))
+                    {
+                        log.log(Level.INFO, 
+                            "Resource Library Contract "+ contract + " was not found while scanning for "
+                            + "available contracts.");
+                    }
+                }
+            }
+        }
+        
+        // JSF 2.2 section 11.4.2.1 if no contractMappings set, all available contracts applies
+        // to all views.
+        if (runtimeConfig.getContractMappings().isEmpty())
+        {
+            String[] contracts = runtimeConfig.getResourceLibraryContracts().toArray(
+                new String[runtimeConfig.getResourceLibraryContracts().size()]);
+            runtimeConfig.addContractMapping("*", contracts);
+        }
+        
+        for (String resourceResolver : dispenser.getResourceResolvers())
+        {
+            runtimeConfig.addResourceResolver(resourceResolver);
+        }
+        
+        for (FaceletTagLibrary faceletTagLibrary : dispenser.getTagLibraries())
+        {
+            runtimeConfig.addFaceletTagLibrary(faceletTagLibrary);
+            if (faceletTagLibrary.getNamespace() != null)
+            {
+                knownNamespaces.add(faceletTagLibrary.getNamespace());
+            }
+        }
+        
+        // Add default namespaces to the known namespaces
+        knownNamespaces.add("http://xmlns.jcp.org/jsf/core");
+        knownNamespaces.add("http://java.sun.com/jsf/core");
+        knownNamespaces.add("http://xmlns.jcp.org/jsf/html");
+        knownNamespaces.add("http://java.sun.com/jsf/html");
+        knownNamespaces.add("http://xmlns.jcp.org/jsf/facelets");
+        knownNamespaces.add("http://java.sun.com/jsf/facelets");
+        knownNamespaces.add("http://xmlns.jcp.org/jsp/jstl/core");
+        knownNamespaces.add("http://java.sun.com/jsp/jstl/core");
+        knownNamespaces.add("http://java.sun.com/jstl/core");
+        knownNamespaces.add("http://xmlns.jcp.org/jsp/jstl/functions");
+        knownNamespaces.add("http://java.sun.com/jsp/jstl/functions");
+        knownNamespaces.add("http://xmlns.jcp.org/jsf/composite");
+        knownNamespaces.add("http://java.sun.com/jsf/composite");
+        knownNamespaces.add("http://xmlns.jcp.org/jsf");
+        knownNamespaces.add("http://java.sun.com/jsf");
+        knownNamespaces.add("http://xmlns.jcp.org/jsf/passthrough");
+        knownNamespaces.add("http://java.sun.com/jsf/passthrough");
+        
+        Map<Integer, String> namespaceById = new HashMap<>();
+        Map<String, Integer> idByNamespace = new HashMap<>();
+        // Sort them to ensure the same id 
+        Collections.sort(knownNamespaces);
+        for (int i = 0; i < knownNamespaces.size(); i++)
+        {
+            namespaceById.put(i, knownNamespaces.get(i));
+            idByNamespace.put(knownNamespaces.get(i), i);
+        }
+        runtimeConfig.setNamespaceById(Collections.unmodifiableMap(namespaceById));
+        runtimeConfig.setIdByNamespace(Collections.unmodifiableMap(idByNamespace));
+        
+        for (ViewPoolMapping viewPoolMapping : dispenser.getViewPoolMappings())
+        {
+            runtimeConfig.addViewPoolMapping(viewPoolMapping);
+        }
+        
+        for (FaceletsTemplateMapping faceletsTemplateMapping : dispenser.getFaceletsTemplateMappings())
+        {
+            runtimeConfig.addFaceletsTemplateMapping(faceletsTemplateMapping);
+        }
+    }
+
+    private void configureRenderKits()
+    {
+        RenderKitFactory renderKitFactory
+                = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+
+        FacesConfigData dispenser = getDispenser();
+        for (String renderKitId : dispenser.getRenderKitIds())
+        {
+            Collection<String> renderKitClass = dispenser.getRenderKitClasses(renderKitId);
+
+            if (renderKitClass.isEmpty())
+            {
+                renderKitClass = new ArrayList<>(1);
+                renderKitClass.add(DEFAULT_RENDER_KIT_CLASS);
+            }
+
+            RenderKit renderKit = (RenderKit) ClassUtils.buildApplicationObject(RenderKit.class, renderKitClass, null);
+            // If the default html RenderKit instance is wrapped, the top level object will not implement
+            // LazyRenderKit and all renderers will be added using the standard form.
+            boolean lazyRenderKit = renderKit instanceof LazyRenderKit;
+
+            for (Renderer element : dispenser.getRenderers(renderKitId))
+            {
+                jakarta.faces.render.Renderer renderer;
+                
+                if (element.getRendererClass() != null)
+                {
+                    if (lazyRenderKit)
+                    {
+                        // Add renderer using LazyRenderKit interface. This will have the effect of improve startup
+                        // time avoiding load renderer classes that are not used.
+                        ((LazyRenderKit) renderKit).addRenderer(element.getComponentFamily(), 
+                            element.getRendererType(), element.getRendererClass());
+                    }
+                    else
+                    {
+                        // Use standard form
+                        try
+                        {
+                            renderer = (jakarta.faces.render.Renderer) ClassUtils.newInstance(
+                                element.getRendererClass());
+                        }
+                        catch (Throwable e)
+                        {
+                            // ignore the failure so that the render kit is configured
+                            log.log(Level.SEVERE, "failed to configure class " + element.getRendererClass(), e);
+                            continue;
+                        }
+                        if (renderer != null)
+                        {
+                            renderKit.addRenderer(element.getComponentFamily(), element.getRendererType(), renderer);
+                        }
+                        else
+                        {
+                            log.log(Level.INFO, "Renderer instance cannot be created for "+
+                                    element.getRendererClass()+ ", ignoring..." + 
+                                    element.getRendererClass());
+                        }
+                    }
+                }
+                else
+                {
+                        log.log(Level.INFO, "Renderer element with no rendererClass found, ignoring..." +
+                                element.getRendererClass());
+                }
+
+            }
+            
+            Collection<ClientBehaviorRenderer> clientBehaviorRenderers
+                    = dispenser.getClientBehaviorRenderers(renderKitId);
+
+            // Add in client behavior renderers.
+
+            for (ClientBehaviorRenderer clientBehaviorRenderer : clientBehaviorRenderers)
+            {
+                try
+                {
+                    jakarta.faces.render.ClientBehaviorRenderer behaviorRenderer
+                            = (jakarta.faces.render.ClientBehaviorRenderer)
+                            ClassUtils.newInstance(clientBehaviorRenderer.getRendererClass());
+
+                    renderKit.addClientBehaviorRenderer(clientBehaviorRenderer.getRendererType(), behaviorRenderer);
+                }
+
+                catch (Throwable e)
+                {
+                    // Ignore.
+
+                    if (log.isLoggable(Level.SEVERE))
+                    {
+                        log.log(Level.SEVERE, "failed to configure client behavior renderer class " +
+                                clientBehaviorRenderer.getRendererClass(), e);
+                    }
+                }
+            }
+
+            renderKitFactory.addRenderKit(renderKitId, renderKit);
+        }
+    }
+
+    private void configureLifecycle()
+    {
+        // create the lifecycle used by the app
+        LifecycleFactory lifecycleFactory
+                = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+        for (Iterator<String> it = lifecycleFactory.getLifecycleIds(); it.hasNext();)
+        {
+            Lifecycle lifecycle = lifecycleFactory.getLifecycle(it.next());
+            
+            // add phase listeners
+            for (String listenerClassName : getDispenser().getLifecyclePhaseListeners())
+            {
+                try
+                {
+                    PhaseListener listener = (PhaseListener)
+                            ClassUtils.newInstance(listenerClassName, PhaseListener.class);
+                    _callInjectAndPostConstruct(listener);
+                    lifecycle.addPhaseListener(listener);
+                }
+                catch (ClassCastException e)
+                {
+                    log.severe("Class " + listenerClassName + " does not implement PhaseListener");
+                }
+            }
+
+            // if ProjectStage is Development, install the DebugPhaseListener
+            FacesContext facesContext = getFacesContext();
+            if (facesContext.isProjectStage(ProjectStage.Development)
+                    && _myfacesConfig.isDebugPhaseListenerEnabled())
+            {
+                lifecycle.addPhaseListener(new DebugPhaseListener());
+            }
+        }
+    }
+
+
+    private void handleSerialFactory()
+    {
+        String serialProvider = _externalContext.getInitParameter(StateUtils.SERIAL_FACTORY);
+        SerialFactory serialFactory = null;
+
+        if (serialProvider == null)
+        {
+            serialFactory = new DefaultSerialFactory();
+        }
+        else
+        {
+            try
+            {
+                serialFactory = (SerialFactory) ClassUtils.newInstance(serialProvider);
+
+            }
+            catch (ClassCastException e)
+            {
+                log.log(Level.SEVERE, "Make sure '" + serialProvider + "' implements the correct interface", e);
+            }
+            catch (Exception e)
+            {
+                log.log(Level.SEVERE, "", e);
+            }
+            finally
+            {
+                if (serialFactory == null)
+                {
+                    serialFactory = new DefaultSerialFactory();
+                    log.severe("Using default serialization provider");
+                }
+            }
+
+        }
+
+        log.fine("Serialization provider : " + serialFactory.getClass());
+        _externalContext.getApplicationMap().put(StateUtils.SERIAL_FACTORY, serialFactory);
+    }
+
+    private void configureFlowHandler()
+    {
+        FacesContext facesContext = getFacesContext();
+        Application application = getApplication();
+        
+        FacesConfigData dispenser = getDispenser();
+        
+        if (!dispenser.getFacesFlowDefinitions().isEmpty())
+        {
+            // Faces Flow require client window enabled to work.
+            FacesConfigurator.enableDefaultWindowMode(facesContext);
+        }
+        
+        for (FacesFlowDefinition flowDefinition : dispenser.getFacesFlowDefinitions())
+        {
+            FlowImpl flow = new FlowImpl();
+            
+            // TODO: configure flow object
+            flow.setId(flowDefinition.getId());
+            flow.setDefiningDocumentId(flowDefinition.getDefiningDocumentId());
+            
+            flow.setStartNodeId(flowDefinition.getStartNode());
+            
+            if (StringUtils.isNotEmpty(flowDefinition.getInitializer()))
+            {
+                flow.setInitializer(application.getExpressionFactory().createMethodExpression(
+                    facesContext.getELContext(), flowDefinition.getInitializer(), null, NO_PARAMETER_TYPES));
+            }
+            if (StringUtils.isNotEmpty(flowDefinition.getFinalizer()))
+            {
+                flow.setFinalizer(application.getExpressionFactory().createMethodExpression(
+                    facesContext.getELContext(), flowDefinition.getFinalizer(), null, NO_PARAMETER_TYPES));
+            }
+            
+            for (FacesFlowCall call : flowDefinition.getFlowCallList())
+            {
+                FlowCallNodeImpl node = new FlowCallNodeImpl(call.getId());
+                if (call.getFlowReference() != null)
+                {
+                    node.setCalledFlowId(call.getFlowReference().getFlowId());
+                    node.setCalledFlowDocumentId(call.getFlowReference().getFlowDocumentId());
+                }
+
+                for (FacesFlowParameter parameter : call.getOutboundParameterList())
+                {
+                    node.putOutboundParameter( parameter.getName(),
+                        new ParameterImpl(parameter.getName(),
+                        application.getExpressionFactory().createValueExpression(
+                            facesContext.getELContext(), parameter.getValue(), Object.class)) );
+                }
+                flow.putFlowCall(node.getId(), node);
+            }
+
+            for (FacesFlowMethodCall methodCall : flowDefinition.getMethodCallList())
+            {
+                MethodCallNodeImpl node = new MethodCallNodeImpl(methodCall.getId());
+                if (StringUtils.isNotEmpty(methodCall.getMethod()))
+                {
+                    node.setMethodExpression(
+                        application.getExpressionFactory().createMethodExpression(
+                            facesContext.getELContext(), methodCall.getMethod(), null, NO_PARAMETER_TYPES));
+                }
+                if (StringUtils.isNotEmpty(methodCall.getDefaultOutcome()))
+                {
+                    node.setOutcome(
+                        application.getExpressionFactory().createValueExpression(
+                                facesContext.getELContext(), methodCall.getDefaultOutcome(), Object.class));
+                }
+                for (FacesFlowMethodParameter parameter : methodCall.getParameterList())
+                {
+                    node.addParameter(
+                        new ParameterImpl(parameter.getClassName(),
+                        application.getExpressionFactory().createValueExpression(
+                            facesContext.getELContext(), parameter.getValue(), Object.class)) );
+                }
+                flow.addMethodCall(node);
+            }
+            
+            for (FacesFlowParameter parameter : flowDefinition.getInboundParameterList())
+            {
+                flow.putInboundParameter(parameter.getName(),
+                    new ParameterImpl(parameter.getName(),
+                    application.getExpressionFactory().createValueExpression(
+                        facesContext.getELContext(), parameter.getValue(), Object.class)) );
+            }
+            
+            for (NavigationRule rule : flowDefinition.getNavigationRuleList())
+            {
+                flow.addNavigationCases(rule.getFromViewId(), NavigationUtils.convertNavigationCasesToAPI(rule));
+            }
+            
+            for (FacesFlowSwitch flowSwitch : flowDefinition.getSwitchList())
+            {
+                SwitchNodeImpl node = new SwitchNodeImpl(flowSwitch.getId());
+                
+                if (flowSwitch.getDefaultOutcome() != null &&
+                    StringUtils.isNotEmpty(flowSwitch.getDefaultOutcome().getFromOutcome()))
+                {
+                    if (ELText.isLiteral(flowSwitch.getDefaultOutcome().getFromOutcome()))
+                    {
+                        node.setDefaultOutcome(flowSwitch.getDefaultOutcome().getFromOutcome());
+                    }
+                    else
+                    {
+                        node.setDefaultOutcome(
+                            application.getExpressionFactory().createValueExpression(
+                                facesContext.getELContext(), flowSwitch.getDefaultOutcome().getFromOutcome(),
+                                Object.class));
+                    }
+                }
+                
+                for (NavigationCase navCase : flowSwitch.getNavigationCaseList())
+                {
+                    SwitchCaseImpl nodeCase = new SwitchCaseImpl();
+                    nodeCase.setFromOutcome(navCase.getFromOutcome());
+                    if (StringUtils.isNotEmpty(navCase.getIf()))
+                    {
+                        nodeCase.setCondition(
+                            application.getExpressionFactory().createValueExpression(
+                                facesContext.getELContext(), navCase.getIf(),
+                                Object.class));
+                    }
+                    node.addCase(nodeCase);
+                }
+                
+                flow.putSwitch(node.getId(), node);
+            }
+            
+            for (FacesFlowView view : flowDefinition.getViewList())
+            {
+                ViewNodeImpl node = new ViewNodeImpl(view.getId(), view.getVdlDocument());
+                flow.addView(node);
+            }
+
+            for (FacesFlowReturn flowReturn : flowDefinition.getReturnList())
+            {
+                ReturnNodeImpl node = new ReturnNodeImpl(flowReturn.getId());
+                if (flowReturn.getNavigationCase() != null &&
+                    StringUtils.isNotEmpty(flowReturn.getNavigationCase().getFromOutcome()))
+                {
+                    if (ELText.isLiteral(flowReturn.getNavigationCase().getFromOutcome()))
+                    {
+                        node.setFromOutcome(flowReturn.getNavigationCase().getFromOutcome());
+                    }
+                    else
+                    {
+                        node.setFromOutcome(
+                            application.getExpressionFactory().createValueExpression(
+                                facesContext.getELContext(), flowReturn.getNavigationCase().getFromOutcome(),
+                                Object.class));
+                    }
+                }
+                flow.putReturn(node.getId(), node);
+            }
+            
+            flow.freeze();
+            
+            // Add the flow, so the config can be processed by the flow system and the
+            // navigation system.
+            application.getFlowHandler().addFlow(facesContext, flow);
+        }
+        
+        configureAnnotatedFlows(facesContext);
+    }
+    
+    public static void configureAnnotatedFlows(FacesContext facesContext)
+    {
+        FacesFlowProviderFactory factory = 
+            FacesFlowProviderFactory.getFacesFlowProviderFactory(facesContext.getExternalContext());
+        FacesFlowProvider provider = factory.getFacesFlowProvider(facesContext.getExternalContext());
+        
+        Iterator<Flow> it = provider.getAnnotatedFlows(facesContext);
+        if (it == null)
+        {
+            return;
+        }
+
+        if (it.hasNext())
+        {
+            enableDefaultWindowMode(facesContext);
+        }
+        while (it.hasNext())
+        {
+            Flow flow = it.next();
+            if (flow instanceof FlowImpl)
+            {
+                ((FlowImpl) flow).freeze();
+            }
+            facesContext.getApplication().getFlowHandler().addFlow(facesContext, flow);
+        }
+    }
+    
+    public static void enableDefaultWindowMode(FacesContext facesContext)
+    {
+        if (!isEnableDefaultWindowMode(facesContext))
+        {
+            String windowMode = WebConfigParamUtils.getStringInitParameter(
+                    facesContext.getExternalContext(), 
+                    ClientWindow.CLIENT_WINDOW_MODE_PARAM_NAME, null);
+            
+            if (windowMode == null)
+            {
+                //No window mode set, force window mode to url
+                String defaultWindowMode = WebConfigParamUtils.getStringInitParameter(
+                    facesContext.getExternalContext(), 
+                    ClientWindowFactoryImpl.INIT_PARAM_DEFAULT_WINDOW_MODE, 
+                    ClientWindowFactoryImpl.WINDOW_MODE_URL);
+                
+                log.info("The current configuration requires client window enabled, setting it to '"+
+                    defaultWindowMode+ '\'');
+                
+                facesContext.getExternalContext().getApplicationMap().put(
+                    ENABLE_DEFAULT_WINDOW_MODE, Boolean.TRUE);
+            }
+        }
+    }
+    
+    public static boolean isEnableDefaultWindowMode(FacesContext facesContext)
+    {
+        return Boolean.TRUE.equals(facesContext.getExternalContext().
+            getApplicationMap().get(ENABLE_DEFAULT_WINDOW_MODE));
+    }
+
+    public void configureProtectedViews()
+    {
+        Application application = getApplication();
+
+        FacesConfigData dispenser = getDispenser();
+        //Protected Views
+        ViewHandler viewHandler = application.getViewHandler();
+        for (String urlPattern : dispenser.getProtectedViewUrlPatterns())
+        {
+            viewHandler.addProtectedView(urlPattern);
+        }
+    }
+    
+    protected InjectionProvider getInjectionProvider()
+    {
+        if (_injectionProvider == null)
+        {
+            _injectionProvider = InjectionProviderFactory.getInjectionProviderFactory(
+                _externalContext).getInjectionProvider(_externalContext);
+        }
+        return _injectionProvider;
+    }
+    
+    protected FacesContext getFacesContext()
+    {
+        if (_facesContext == null)
+        {
+            _facesContext = FacesContext.getCurrentInstance();
+        }
+        return _facesContext;
+    }
+    
+    protected Application getApplication()
+    {
+        if (_application == null)
+        {
+            return getFacesContext().getApplication();
+        }
+        return _application;
+    }
+    
+    protected void setApplication(Application application)
+    {
+        this._application = application;
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java b/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
index b866caa..b4e685d 100755
--- a/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
+++ b/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
@@ -1,1761 +1,1761 @@
-/*
- * 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.config;
-
-import java.util.ResourceBundle;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import jakarta.faces.application.ProjectStage;
-import jakarta.faces.application.StateManager;
-import jakarta.faces.application.ViewHandler;
-import jakarta.faces.context.ExternalContext;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.lifecycle.ClientWindow;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
-import org.apache.myfaces.spi.InjectionProvider;
-import org.apache.myfaces.util.lang.ClassUtils;
-import org.apache.myfaces.util.lang.StringUtils;
-import org.apache.myfaces.view.facelets.ELExpressionCacheMode;
-
-/**
- * Holds all configuration init parameters (from web.xml) that are independent
- * from the core implementation. The parameters in this class are available to
- * all shared, component and implementation classes.
- * See RuntimeConfig for configuration infos that come from the faces-config
- * files and are needed by the core implementation.
- *
- * MyfacesConfig is meant for components that implement some of the extended features
- * of MyFaces. Anyhow, using the MyFaces JSF implementation is no precondition for using
- * MyfacesConfig in custom components. Upon using another JSF implementation
- * (or omitting the extended init parameters) all config properties will simply have
- * their default values.
- */
-//CHECKSTYLE:OFF
-public class MyfacesConfig
-{
-    private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
-
-    /**
-     * Set the time in seconds that check for updates of web.xml and faces-config descriptors and 
-     * refresh the configuration.
-     * This param is valid only if project stage is not production. Set this param to 0 disable this feature.
-     */
-    @JSFWebConfigParam(defaultValue="2",since="1.1", classType="java.lang.Long")
-    public static final String CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
-    private static final long CONFIG_REFRESH_PERIOD_DEFAULT = 2;
-
-    /**
-     * Define if the input field that should store the state (jakarta.faces.ViewState) should render 
-     * id="jakarta.faces.ViewState".
-     * 
-     * JSF API 1.2 defines a "jakarta.faces.ViewState" client parameter, that must be rendered as both the "name"
-     * and the "id" attribute of the hidden input that is rendered for the purpose of state saving
-     * (see ResponseStateManager.VIEW_STATE_PARAM).
-     * Actually this causes duplicate id attributes and thus invalid XHTML pages when multiple forms are rendered on
-     * one page. With the org.apache.myfaces.RENDER_VIEWSTATE_ID context parameter you can tune this behaviour.
-     * <br/>Set it to
-     * <ul><li>true - to render JSF 1.2 compliant id attributes (that might cause invalid XHTML), or</li>
-     * <li>false - to omit rendering of the id attribute (which is only needed for very special 
-     * AJAX/Javascript components)</li></ul>
-     * Default value is: true (for backwards compatibility and JSF 1.2 compliancy) 
-     */
-    @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1", 
-            ignoreUpperLowerCase=true, group="state")
-    public static final String RENDER_VIEWSTATE_ID = "org.apache.myfaces.RENDER_VIEWSTATE_ID";
-    private static final boolean RENDER_VIEWSTATE_ID_DEFAULT = true;
-
-    /**
-     * Use "&amp;amp;" entity instead a plain "&amp;" character within HTML.
-     * <p>W3C recommends to use the "&amp;amp;" entity instead of a plain "&amp;" character within HTML.
-     * This also applies to attribute values and thus to the "href" attribute of &lt;a&gt; elements as well.
-     * Even more, when XHTML is used as output the usage of plain "&amp;" characters is forbidden and would lead to
-     * invalid XML code.
-     * Therefore, since version 1.1.6 MyFaces renders the correct "&amp;amp;" entity for links.</p>
-     * <p>The init parameter
-     * org.apache.myfaces.STRICT_XHTML_LINKS makes it possible to restore the old behaviour and to make MyFaces
-     * "bug compatible" to the Sun RI which renders plain "&amp;" chars in links as well.</p>
-     * <p>
-     * See: <a href="http://www.w3.org/TR/html401/charset.html#h-5.3.2">HTML 4.01 Specification</a>
-     * See: <a href="http://issues.apache.org/jira/browse/MYFACES-1774">Jira: MYFACES-1774</a>
-     * </p>
-     */
-    @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1.6", 
-            ignoreUpperLowerCase=true, group="render")
-    public static final String STRICT_XHTML_LINKS = "org.apache.myfaces.STRICT_XHTML_LINKS";
-    private static final boolean STRICT_XHTML_LINKS_DEFAULT = true;
-    
-    /**
-     * This param renders the clear javascript on button necessary only for
-     * compatibility with hidden fields feature of myfaces. This is done 
-     * because jsf ri does not render javascript on onclick method for button,
-     * so myfaces should do this.
-     */
-    @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.2.3",
-            ignoreUpperLowerCase=true, group="render")
-    public static final String RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON = 
-        "org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON";
-    private static final boolean RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT= false;
-
-    /**
-     * Define an alternate class name that will be used to initialize MyFaces, instead the default 
-     * jakarta.faces.webapp.FacesServlet.
-     * 
-     * <p>This helps MyFaces to detect the mappings and other additional configuration used to setup the 
-     * environment, and prevent abort initialization if no FacesServlet config is detected.
-     * </p>
-     */
-    @JSFWebConfigParam(since="1.2.7")
-    public static final String DELEGATE_FACES_SERVLET = "org.apache.myfaces.DELEGATE_FACES_SERVLET";
-
-    /**
-     * Indicate if the facelet associated to the view should be reapplied when the view is refreshed.
-     *  Default mode is "auto".
-     * 
-     * <p>This param is only valid when partial state saving is on.
-     * If this is set as true, the tag-handlers are always reapplied before render view, like in facelets 1.1.x, 
-     * allowing c:if work correctly to "toggle" components based on a value changed on invoke application phase. 
-     * If the param is set as "auto", the implementation check if c:if, c:forEach, 
-     * c:choose and ui:include with src=ELExpression is used on the page and if that so, mark the view
-     * to be refreshed.</p> 
-     */
-    @JSFWebConfigParam(since="2.0", defaultValue="auto", expectedValues="true,false,auto", tags="performance", 
-            ignoreUpperLowerCase=true, group="state")
-    public final static String REFRESH_TRANSIENT_BUILD_ON_PSS = 
-        "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS"; 
-    private final static String REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT = "auto";
-
-    /**
-     * Enable or disable a special mode that enable full state for parent components containing c:if, c:forEach, 
-     * c:choose and ui:include with src=ELExpression. By default is disabled(false).
-     * 
-     * <p>This param is only valid when partial state saving is on.
-     * If this is set as true, parent components containing  c:if, c:forEach, 
-     * c:choose and ui:include with src=ELExpression are marked to be restored fully, so state
-     * is preserved between request.</p>
-     */
-    @JSFWebConfigParam(since="2.0", defaultValue="false", expectedValues="true, false, on, off, yes, no", 
-            tags="performance", ignoreUpperLowerCase=true, group="state")
-    public final static String REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE = 
-        "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE";
-    private final static boolean REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT = false;
-    
-    /**
-     * If set to <code>true</code>, tag library XML files and faces config XML files using schema 
-     * will be validated during application start up
-     */
-    @JSFWebConfigParam(since="2.0", expectedValues="true, false, on, off, yes, no", ignoreUpperLowerCase=true)
-    public final static String VALIDATE_XML = "org.apache.myfaces.VALIDATE_XML";
-    private final static boolean VALIDATE_XML_DEFAULT = false;
-    
-    /**
-     * Wrap content inside script with xml comment to prevent old browsers to display it. By default it is true. 
-     */
-    @JSFWebConfigParam(since="2.0.1", expectedValues="true, false, on, off, yes, no", defaultValue="false",
-            ignoreUpperLowerCase=true, group="render")
-    public final static String WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG = 
-        "org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG";
-    private final static boolean WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT = false;
-    
-    /**
-     * Enable/disable DebugPhaseListener feature, with provide useful information about ValueHolder 
-     * variables (submittedValue, localValue, value).
-     * Note evaluate those getters for each component could cause some unwanted side effects when 
-     * using "access" type scopes like on MyFaces CODI.
-     * This param only has effect when project stage is Development.     
-     */
-    @JSFWebConfigParam(since="2.0.8")
-    public final static String DEBUG_PHASE_LISTENER = "org.apache.myfaces.DEBUG_PHASE_LISTENER";
-    private final static boolean DEBUG_PHASE_LISTENER_DEFAULT = false;
-    
-    /**
-     * Change default getType() behavior for composite component EL resolver, from return null 
-     * (see JSF 2_0 spec section 5_6_2_2) to
-     * use the metadata information added by composite:attribute, ensuring components working with 
-     * chained EL expressions to find the
-     * right type when a getType() is called over the source EL expression.
-     * 
-     * To ensure strict compatibility with the spec set this param to true (by default is false, 
-     * so the change is enabled by default). 
-     */
-    @JSFWebConfigParam(since="2.0.10", expectedValues="true, false", defaultValue="false", group="EL")
-    public final static String STRICT_JSF_2_CC_EL_RESOLVER = 
-        "org.apache.myfaces.STRICT_JSF_2_CC_EL_RESOLVER";
-    private final static boolean STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT = false;
-    
-    /**
-     * Define the default content type that the default ResponseWriter generates, when no match can be derived from
-     * HTTP Accept Header.
-     */
-    @JSFWebConfigParam(since="2.0.11,2.1.5", expectedValues="text/html, application/xhtml+xml", 
-            defaultValue="text/html", group="render")
-    public final static String DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE = 
-        "org.apache.myfaces.DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE";
-    private final static String DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT = "text/html";
-
-    /**
-     * Enable or disable a cache used to "remember" the generated facelets unique ids and reduce 
-     * the impact on memory usage, only active if jakarta.faces.FACELETS_REFRESH_PERIOD is -1 (no refresh).
-     */
-    @JSFWebConfigParam(defaultValue = "true", since = "2.0.13, 2.1.7", expectedValues="true, false", 
-            group="viewhandler", tags="performance",
-            desc="Enable or disable a cache used to 'remember' the generated facelets unique ids " + 
-                 "and reduce the impact over memory usage.")
-    public static final String VIEW_UNIQUE_IDS_CACHE_ENABLED = 
-        "org.apache.myfaces.VIEW_UNIQUE_IDS_CACHE_ENABLED";
-    private static final boolean VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT = true;
-    
-    /**
-     * Set the size of the cache used to store strings generated using SectionUniqueIdCounter
-     * for component ids. If this is set to 0, no cache is used. By default is set to 200.
-     */
-    @JSFWebConfigParam(defaultValue = "100", since = "2.0.13, 2.1.7",
-            group="viewhandler", tags="performance")
-    public static final String COMPONENT_UNIQUE_IDS_CACHE_SIZE =
-        "org.apache.myfaces.COMPONENT_UNIQUE_IDS_CACHE_SIZE";
-    private static final int COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT = 200;
-
-    /**
-     * If this param is set to true, a check will be done in Restore View Phase to check
-     * if the viewId exists or not and if it does not exists, a 404 response will be thrown.
-     * 
-     * This is applicable in cases where all the views in the application are generated by a 
-     * ViewDeclarationLanguage implementation.
-     */
-    @JSFWebConfigParam(since = "2.1.13", defaultValue="false", expectedValues="true,false", 
-            group="viewhandler")
-    public static final String STRICT_JSF_2_VIEW_NOT_FOUND = 
-            "org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND";
-    private final static boolean STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT = false;
-
-    @JSFWebConfigParam(defaultValue = "false", since = "2.2.0", expectedValues="true, false", group="render",
-            tags="performance",
-            desc="Enable or disable an early flush which allows to send e.g. the HTML-Head to the client " +
-                    "while the rest gets rendered. It's a well known technique to reduce the time for loading a page.")
-    public static final String EARLY_FLUSH_ENABLED =
-        "org.apache.myfaces.EARLY_FLUSH_ENABLED";
-    private static final boolean EARLY_FLUSH_ENABLED_DEFAULT = false;
-    
-    /**
-     * This param makes components like c:set, ui:param and templating components like ui:decorate,
-     * ui:composition and ui:include to behave like the ones provided originally in facelets 1_1_x. 
-     * See MYFACES-3810 for details.
-     */
-    @JSFWebConfigParam(since = "2.2.0", defaultValue="false", expectedValues="true,false", 
-            group="viewhandler")
-    public static final String STRICT_JSF_2_FACELETS_COMPATIBILITY = 
-            "org.apache.myfaces.STRICT_JSF_2_FACELETS_COMPATIBILITY";
-    private final static boolean STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT = false;    
-    
-    /**
-     * This param makes h:form component to render the view state and other hidden fields
-     * at the beginning of the form. This also includes component resources with target="form",
-     * but it does not include legacy 1.1 myfaces specific hidden field adition.
-     */
-    @JSFWebConfigParam(since = "2.2.4", defaultValue = "false", expectedValues = "true,false",
-            group="render")
-    public static final String RENDER_FORM_VIEW_STATE_AT_BEGIN =
-            "org.apache.myfaces.RENDER_FORM_VIEW_STATE_AT_BEGIN";
-    private final static boolean RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT = false;
-    
-    /**
-     * Defines whether flash scope is disabled, preventing add the Flash cookie to the response. 
-     * 
-     * <p>This is useful for applications that does not require to use flash scope, and instead uses other scopes.</p>
-     */
-    @JSFWebConfigParam(defaultValue="false",since="2.0.5")
-    public static final String FLASH_SCOPE_DISABLED = "org.apache.myfaces.FLASH_SCOPE_DISABLED";
-    private static final boolean FLASH_SCOPE_DISABLED_DEFAULT = false;
-    
-    /**
-     * Defines the amount (default = 20) of the latest views are stored in session.
-     * 
-     * <p>Only applicable if state saving method is "server" (= default).
-     * </p>
-     * 
-     */
-    @JSFWebConfigParam(defaultValue="20",since="1.1", classType="java.lang.Integer", group="state", tags="performance")
-    public static final String NUMBER_OF_VIEWS_IN_SESSION = "org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION";
-    /**
-     * Default value for <code>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</code> context parameter.
-     */
-    public static final int NUMBER_OF_VIEWS_IN_SESSION_DEFAULT = 20;    
-
-    /**
-     * Indicates the amount of views (default is not active) that should be stored in session between sequential
-     * POST or POST-REDIRECT-GET if org.apache.myfaces.USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION is true.
-     * 
-     * <p>Only applicable if state saving method is "server" (= default). For example, if this param has value = 2 and 
-     * in your custom webapp there is a form that is clicked 3 times, only 2 views
-     * will be stored and the third one (the one stored the first time) will be
-     * removed from session, even if the view can
-     * store more sessions org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION.
-     * This feature becomes useful for multi-window applications.
-     * where without this feature a window can swallow all view slots so
-     * the other ones will throw ViewExpiredException.</p>
-     */
-    @JSFWebConfigParam(since="2.0.6", classType="java.lang.Integer", group="state", tags="performance", 
-            defaultValue = "4")
-    public static final String NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION
-            = "org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION";
-    public static final Integer NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT = 4;
-    
-    /**
-     * Indicate the max number of flash tokens stored into session. It is only active when 
-     * jakarta.faces.CLIENT_WINDOW_MODE is enabled and jakarta.faces.STATE_SAVING_METHOD is set
-     * to "server". Each flash token is associated to one client window id at
-     * the same time, so this param is related to the limit of active client windows per session. 
-     * By default is the same number as in 
-     * (org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION / 
-     * org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION) + 1 = 6.
-     */
-    @JSFWebConfigParam(since="2.2.6", group="state", tags="performance")
-    public static final String NUMBER_OF_FLASH_TOKENS_IN_SESSION = 
-            "org.apache.myfaces.NUMBER_OF_FLASH_TOKENS_IN_SESSION";
-
-    /**
-     * This parameter specifies whether or not the ImportHandler will be supported
-     */
-    @JSFWebConfigParam(since="2.2.9", defaultValue="false", expectedValues="true,false", group="EL")
-    public static final String SUPPORT_EL_3_IMPORT_HANDLER = "org.apache.myfaces.SUPPORT_EL_3_IMPORT_HANDLER";
-    private final static boolean SUPPORT_EL_3_IMPORT_HANDLER_DEFAULT = false;
-
-    /**
-     * This parameter specifies whether or not the Origin header app path should be checked 
-     */
-    @JSFWebConfigParam(since="2.3", defaultValue="false", expectedValues="true,false")
-    public static final String STRICT_JSF_2_ORIGIN_HEADER_APP_PATH = 
-            "org.apache.myfaces.STRICT_JSF_2_ORIGIN_HEADER_APP_PATH";
-    private final static boolean STRICT_JSF_2_ORIGIN_HEADER_APP_PATH_DEFAULT = false;
-
-    /**
-     * Allow slash in the library name of a Resource. 
-     */
-    @JSFWebConfigParam(since="2.1.6, 2.0.12", defaultValue="false", 
-            expectedValues="true, false", group="resources")
-    public static final String STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME = 
-            "org.apache.myfaces.STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME";
-    private static final boolean STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME_DEFAULT = false;
-    
-    /**
-     * Define the default buffer size that is used between Resource.getInputStream() and 
-     * httpServletResponse.getOutputStream() when rendering resources using the default
-     * ResourceHandler.
-     */
-    @JSFWebConfigParam(since="2.1.10, 2.0.16", defaultValue="2048", group="resources")
-    public static final String RESOURCE_BUFFER_SIZE = "org.apache.myfaces.RESOURCE_BUFFER_SIZE";
-    private static final int RESOURCE_BUFFER_SIZE_DEFAULT = 2048;
-    
-    /**
-     * Validate if the managed beans and navigations rules are correct.
-     * 
-     * <p>For example, it checks if the managed bean classes really exists, or if the 
-     * navigation rules points to existing view files.</p>
-     */
-    @JSFWebConfigParam(since="2.0", defaultValue="false", expectedValues="true, false")
-    public static final String VALIDATE = "org.apache.myfaces.VALIDATE";
-    
-    /**
-     * Defines if CDI should be used for annotation scanning to improve the startup performance.
-     */
-    @JSFWebConfigParam(since="2.2.9", tags = "performance", defaultValue = "false")
-    public static final String USE_CDI_FOR_ANNOTATION_SCANNING
-            = "org.apache.myfaces.annotation.USE_CDI_FOR_ANNOTATION_SCANNING";
-    private static final boolean USE_CDI_FOR_ANNOTATION_SCANNING_DEFAULT = false;
-    
-    
-    /**
-     * Controls the size of the cache used to check if a resource exists or not. 
-     * 
-     * <p>See org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED for details.</p>
-     */
-    @JSFWebConfigParam(defaultValue = "500", since = "2.0.2", group="resources", 
-            classType="java.lang.Integer", tags="performance")
-    public static final String RESOURCE_HANDLER_CACHE_SIZE = 
-        "org.apache.myfaces.RESOURCE_HANDLER_CACHE_SIZE";
-    private static final int RESOURCE_HANDLER_CACHE_SIZE_DEFAULT = 500;
-
-    /**
-     * Enable or disable the cache used to "remember" if a resource handled by 
-     * the default ResourceHandler exists or not.
-     * 
-     */
-    @JSFWebConfigParam(defaultValue = "true", since = "2.0.2", group="resources", 
-            expectedValues="true,false", tags="performance")
-    public static final String RESOURCE_HANDLER_CACHE_ENABLED = 
-        "org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED";
-    private static final boolean RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT = true;
-    
-    /**
-     * Servlet context init parameter which defines which packages to scan
-     * for beans, separated by commas.
-     */
-    @JSFWebConfigParam(since="2.0")
-    public static final String SCAN_PACKAGES = "org.apache.myfaces.annotation.SCAN_PACKAGES";
- 
-    /**
-     * Indicates the port used for websocket connections.
-     */
-    @JSFWebConfigParam(since = "2.3")
-    public static final java.lang.String WEBSOCKET_ENDPOINT_PORT = "jakarta.faces.WEBSOCKET_ENDPOINT_PORT";
-
-    @JSFWebConfigParam(defaultValue = "300000")
-    public static final String WEBSOCKET_MAX_IDLE_TIMEOUT = "org.apache.myfaces.WEBSOCKET_MAX_IDLE_TIMEOUT";
-    private static final long WEBSOCKET_MAX_IDLE_TIMEOUT_DEFAULT = 300000L;
-    
-    /**
-     * Defines how to generate the csrf session token.
-     */
-    @JSFWebConfigParam(since="2.2.0", expectedValues="secureRandom, random", 
-            defaultValue="secureRandom", group="state")
-    public static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN
-            = "org.apache.myfaces.RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN";
-
-    public static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_SECURE_RANDOM = "secureRandom";
-    public static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_RANDOM = "random";
-    private static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_DEFAULT = RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_SECURE_RANDOM;
-
-    /**
-     * Define the time in minutes where the view state is valid when
-     * client side state saving is used. By default it is set to 0
-     * (infinite).
-     */
-    @JSFWebConfigParam(since="2.1.9, 2.0.15", defaultValue="0", group="state")
-    public static final String CLIENT_VIEW_STATE_TIMEOUT = 
-            "org.apache.myfaces.CLIENT_VIEW_STATE_TIMEOUT";
-    private static final Long CLIENT_VIEW_STATE_TIMEOUT_DEFAULT = 0L;
-   
-    
-    /**
-     * Adds a random key to the generated view state session token.
-     */
-    @JSFWebConfigParam(since="2.1.9, 2.0.15", expectedValues="secureRandom, random", 
-            defaultValue="secureRandom", group="state")
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN
-            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN";
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM = "secureRandom";
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_RANDOM = "random";
-    private static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_DEFAULT = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM;
-    
-    /**
-     * Set the default length of the random key added to the view state session token.
-     * By default is 8. 
-     */
-    @JSFWebConfigParam(since="2.1.9, 2.0.15", defaultValue="8", group="state")
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH
-            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH";
-    private static final int RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH_DEFAULT = 8;
-    
-    /**
-     * Sets the random class to initialize the secure random id generator. 
-     * By default it uses java.security.SecureRandom
-     */
-    @JSFWebConfigParam(since="2.1.9, 2.0.15", group="state")
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_CLASS
-            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_CLASS";
-    
-    /**
-     * Sets the random provider to initialize the secure random id generator.
-     */
-    @JSFWebConfigParam(since="2.1.9, 2.0.15", group="state")
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_PROVIDER
-            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_PROVIDER";
-    
-    /**
-     * Sets the random algorithm to initialize the secure random id generator. 
-     * By default is SHA1PRNG
-     */
-    @JSFWebConfigParam(since="2.1.9, 2.0.15", defaultValue="SHA1PRNG", group="state")
-    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM
-            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM";
-    private static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM_DEFAULT = "SHA1PRNG";
-    
-    public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM = "secureRandom";
-    public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_RANDOM = "random";
-    
-    /**
-     * Defines how to generate the csrf session token.
-     */
-    @JSFWebConfigParam(since="2.2.0", expectedValues="secureRandom, random", defaultValue="secureRandom", group="state")
-    public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN
-            = "org.apache.myfaces.RANDOM_KEY_IN_CSRF_SESSION_TOKEN";
-    private static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_DEFAULT = RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM;
-    
-    /**
-     * Indicates that the serialized state will be compressed before it is written to the session. By default true.
-     * 
-     * Only applicable if state saving method is "server" (= default) and if
-     * <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code> is <code>true</code> (= default).
-     * If <code>true</code> (default) the serialized state will be compressed before it is written to the session.
-     * If <code>false</code> the state will not be compressed.
-     */
-    @JSFWebConfigParam(defaultValue="true",since="1.1", expectedValues="true,false", group="state", tags="performance")
-    public static final String COMPRESS_STATE_IN_SESSION = "org.apache.myfaces.COMPRESS_STATE_IN_SESSION";
-    private static final boolean COMPRESS_STATE_IN_SESSION_DEFAULT = true;
-    
-    /**
-     * Allow use flash scope to keep track of the views used in session and the previous ones,
-     * so server side state saving can delete old views even if POST-REDIRECT-GET pattern is used.
-     * 
-     * <p>
-     * Only applicable if state saving method is "server" (= default).
-     * The default value is false.</p>
-     */
-    @JSFWebConfigParam(since="2.0.6", defaultValue="false", expectedValues="true, false", group="state")
-    public static final String USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION
-            = "org.apache.myfaces.USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION";
-    private static final boolean USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT = false;
-    
-    /**
-     * Add autocomplete="off" to the view state hidden field. Enabled by default.
-     */
-    @JSFWebConfigParam(since="2.2.8, 2.1.18, 2.0.24", expectedValues="true, false", 
-           defaultValue="true", group="state")
-    public static final String AUTOCOMPLETE_OFF_VIEW_STATE = 
-            "org.apache.myfaces.AUTOCOMPLETE_OFF_VIEW_STATE";
-    private static final boolean AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT = true;
-    
-    /**
-     * Set the max time in miliseconds set on the "Expires" header for a resource rendered by 
-     * the default ResourceHandler.
-     * (default to one week in miliseconds or 604800000) 
-     */
-    @JSFWebConfigParam(since="2.0", defaultValue="604800000", group="resources", tags="performance")
-    public static final String RESOURCE_MAX_TIME_EXPIRES = "org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES";
-    private static final long RESOURCE_MAX_TIME_EXPIRES_DEFAULT = 604800000L;
-    
-
-    /**
-     * Indicate if the classes associated to components, converters, validators or behaviors
-     * should be loaded as soon as they are added to the current application instance or instead
-     * loaded in a lazy way.
-     */
-    @JSFWebConfigParam(defaultValue="true",since="2.0",tags="performance")
-    public static final String LAZY_LOAD_CONFIG_OBJECTS = "org.apache.myfaces.LAZY_LOAD_CONFIG_OBJECTS";
-    private static final boolean LAZY_LOAD_CONFIG_OBJECTS_DEFAULT = true;
-
-    
-    /**
-     * Define a custom comparator class used to sort the ELResolvers.
-     * 
-     * <p>This is useful when it is necessary to put an ELResolver on top of other resolvers. Note set
-     * this param override the default ordering described by JSF spec section 5. 
-     * </p>
-     */
-    @JSFWebConfigParam(since = "1.2.10, 2.0.2", group="EL",
-            desc = "The Class of an Comparator&lt;ELResolver&gt; implementation.")
-    public static final String EL_RESOLVER_COMPARATOR = "org.apache.myfaces.EL_RESOLVER_COMPARATOR";
-    
-    @JSFWebConfigParam(since = "2.1.0", group="EL",
-        desc="The Class of an java.util.function.Predicate&lt;ELResolver&gt; implementation."
-             + "If used and returns false for a ELResolver instance, such resolver will not be installed in "
-             + "ELResolvers chain. Use with caution - can break functionality defined in JSF specification "
-             + "'ELResolver Instances Provided by Faces'")
-    public static final String EL_RESOLVER_PREDICATE = "org.apache.myfaces.EL_RESOLVER_PREDICATE";
-
-    @JSFWebConfigParam(defaultValue = "500", since = "2.0.2", group="viewhandler", tags="performance", 
-            classType="java.lang.Integer",
-            desc="Controls the size of the viewId related caches: " + 
-                    "VIEWID_EXISTS_CACHE_ENABLED, VIEWID_PROTECTED_CACHE_ENABLED, VIEWID_DERIVE_CACHE_ENABLED")
-    public static final String VIEWID_CACHE_SIZE = "org.apache.myfaces.VIEWID_CACHE_SIZE";
-    private static final int VIEWID_CACHE_SIZE_DEFAULT = 500;
-
-    @JSFWebConfigParam(defaultValue = "true", since = "2.0.2", expectedValues="true, false", group="viewhandler", 
-            tags="performance",
-            desc="Enable or disable the cache used to 'remember' if a view exists or not and reduce the impact " +
-                 "of sucesive calls to ExternalContext.getResource().")
-    public static final String VIEWID_EXISTS_CACHE_ENABLED = "org.apache.myfaces.VIEWID_EXISTS_CACHE_ENABLED";
-    private static final boolean VIEWID_EXISTS_CACHE_ENABLED_DEFAULT = true;
-    
-
-    @JSFWebConfigParam(defaultValue = "true", since = "2.3-next", expectedValues="true, false", group="viewhandler", 
-            tags="performance",
-            desc="Enable or disable the cache used to 'remember' if a view is protected or not.")
-    public static final String VIEWID_PROTECTED_CACHE_ENABLED = "org.apache.myfaces.VIEWID_PROTECTED_CACHE_ENABLED";
-    private static final boolean VIEWID_PROTECTED_CACHE_ENABLED_DEFAULT = true;
-    
-    @JSFWebConfigParam(defaultValue = "true", since = "2.3-next", expectedValues="true, false", group="viewhandler", 
-            tags="performance",
-            desc="Enable or disable the cache used to 'remember' the derived viewId from the rawViewId.")
-    public static final String VIEWID_DERIVE_CACHE_ENABLED = "org.apache.myfaces.VIEWID_DERIVE_CACHE_ENABLED";
-    private static final boolean VIEWID_DERIVE_CACHE_ENABLED_DEFAULT = true;
-
-    /**
-     * Enforce f:validateBean to be called first before any JSF validator.
-     */
-    @JSFWebConfigParam(defaultValue="false", expectedValues="true, false", since = "2.2.10", group="validation")
-    public final static String BEAN_BEFORE_JSF_VALIDATION
-            = "org.apache.myfaces.validator.BEAN_BEFORE_JSF_VALIDATION";
-    private final static boolean BEAN_BEFORE_JSF_VALIDATION_DEFAULT = false;
-
-    /**
-     * comma delimited list of plugin classes which can be hooked into myfaces
-     */
-    @JSFWebConfigParam(since = "2.0")
-    public static final String FACES_INIT_PLUGINS = "org.apache.myfaces.FACES_INIT_PLUGINS";
-    
-    /**
-     * If the flag is true, the algoritm skip jar scanning for faces-config files to check if the current
-     * application requires FacesServlet to be added dynamically (servlet spec 3). This param can be set using 
-     * a system property with the same name too.
-     */
-    @JSFWebConfigParam(since="2.2.10", expectedValues = "true, false", defaultValue = "false", 
-            tags = "performance")
-    public static final String INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN = 
-            "org.apache.myfaces.INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN";
-    private static final boolean INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN_DEFAULT = false;
-    
-    /**
-     * If this param is set to true, the check for faces servlet mapping is not done 
-     */
-    @JSFWebConfigParam(since="2.0.3", defaultValue="false")
-    public static final String INITIALIZE_ALWAYS_STANDALONE = "org.apache.myfaces.INITIALIZE_ALWAYS_STANDALONE";
-
-    /**
-     * This parameter specifies the ExpressionFactory implementation to use.
-     */
-    @JSFWebConfigParam(since="1.2.7", group="EL")
-    public static final String EXPRESSION_FACTORY = "org.apache.myfaces.EXPRESSION_FACTORY";
-   
-    /**
-     * Define how duplicate ids are checked when ProjectStage is Production, by default (auto) it only check ids of
-     * components that does not encapsulate markup (like facelets UILeaf).
-     *  
-     * <ul>
-     * <li>true: check all ids, including ids for components that are transient and encapsulate markup.</li>
-     * <li>auto: (default) check ids of components that does not encapsulate markup (like facelets UILeaf). 
-     * Note ids of UILeaf instances are generated by facelets vdl, start with "j_id", are never rendered 
-     * into the response and UILeaf instances are never used as a target for listeners, so in practice 
-     * there is no need to check such ids. This reduce the overhead associated with generate client ids.</li>
-     * <li>false: do not do any check when ProjectStage is Production</li>
-     * </ul>
-     * <p> According to specification, identifiers must be unique within the scope of the nearest ancestor to 
-     * the component that is a naming container.</p>
-     */
-    @JSFWebConfigParam(since="2.0.12, 2.1.6", defaultValue="auto", expectedValues="true, auto, false",
-                       group="state", tags="performance")
-    public static final String CHECK_ID_PRODUCTION_MODE
-            = "org.apache.myfaces.CHECK_ID_PRODUCTION_MODE";
-    private static final String CHECK_ID_PRODUCTION_MODE_DEFAULT = "auto";
-    public static final String CHECK_ID_PRODUCTION_MODE_TRUE = "true";
-    public static final String CHECK_ID_PRODUCTION_MODE_AUTO = "auto";
-    
-    @JSFWebConfigParam(since = "2.1", defaultValue = "false", expectedValues = "true, false", tags = "performance")
-    public final static String MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW
-            = "org.apache.myfaces.MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW";
-    private static final boolean MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW_DEFAULT = false;
-  
-    /**
-     * Class implementing ResourceResolver interface used to locate facelet resources. 
-     */
-    @JSFWebConfigParam(since = "2.0", alias = "facelets.RESOURCE_RESOLVER")
-    public final static String FACELETS_RESOURCE_RESOLVER = "jakarta.faces.FACELETS_RESOURCE_RESOLVER";
-    
-    /**
-     * Indicates if expressions generated by facelets should be cached or not.
-     * Default is noCache. There there are four modes:
-     * 
-     * <ul>
-     * <li>alwaysRecompile (since 2.1.12): Only does not cache when the expression contains
-     * a variable resolved using VariableMapper</li>
-     * <li>always: Only does not cache when expressions are inside user tags or the
-     * expression contains a variable resolved using VariableMapper</li>
-     * <li>allowCset: Like always, but does not allow cache when ui:param
-     * was used on the current template context</li>
-     * <li>strict: Like allowCset, but does not allow cache when c:set with
-     * var and value properties only is used on the current page context</li>
-     * <li>noCache: All expression are created each time the view is built</li>
-     * </ul>
-     * 
-     */
-    @JSFWebConfigParam(since="2.0.8", defaultValue="noCache",
-                       expectedValues="noCache, strict, allowCset, always, alwaysRecompile",
-                       group="EL", tags="performance")
-    public static final String CACHE_EL_EXPRESSIONS = "org.apache.myfaces.CACHE_EL_EXPRESSIONS";
-    private static final String CACHE_EL_EXPRESSIONS_DEFAULT = ELExpressionCacheMode.alwaysRecompile.name();
-    
-    /**
-     * Wrap exception caused by calls to EL expressions, so information like
-     * the location, expression string and tag name can be retrieved by
-     * the ExceptionHandler implementation and used to output meaningful information about itself.
-     * 
-     * <p>Note in some cases this will wrap the original jakarta.el.ELException,
-     * so the information will not be on the stack trace unless ExceptionHandler
-     * retrieve checking if the exception implements ContextAware interface and calling getWrapped() method.
-     * </p>
-     * 
-     */
-    @JSFWebConfigParam(since="2.0.9, 2.1.3" , defaultValue="true", expectedValues="true, false")
-    public static final String WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE
-            = "org.apache.myfaces.WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE";
-    private static final boolean WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE_DEFAULT = true;
-    
-    /**
-     * Defines if the last-modified should be cached of the resources when the ProjectStage is Production.
-     * If the cache is disabled, each last-modified request will read the last-modified from the file.
-     */
-    @JSFWebConfigParam(since="2.3-next" , defaultValue="true", expectedValues="true, false")
-    public static final String RESOURCE_CACHE_LAST_MODIFIED
-            = "org.apache.myfaces.RESOURCE_CACHE_LAST_MODIFIED";
-    private static final boolean RESOURCE_CACHE_LAST_MODIFIED_DEFAULT = true;
-
-    /**
-     * Indicate if log all web config params should be done before initialize the webapp. 
-     * <p>
-     * If is set in "auto" mode, web config params are only logged on "Development" and "Production" project stages.
-     * </p> 
-     */
-    @JSFWebConfigParam(expectedValues="true, auto, false", defaultValue="auto")
-    public static final String LOG_WEB_CONTEXT_PARAMS = "org.apache.myfaces.LOG_WEB_CONTEXT_PARAMS";
-    private static final String LOG_WEB_CONTEXT_PARAMS_DEFAULT = "auto";
-    
-    /**
-     * This parameter enables automatic extensionless mapping for all JSF views.
-     */
-    @JSFWebConfigParam(since="2.3", expectedValues = "true, false", defaultValue = "false")
-    public static final String AUTOMATIC_EXTENSIONLESS_MAPPING = 
-            "org.apache.myfaces.AUTOMATIC_EXTENSIONLESS_MAPPING";
-    public static final boolean AUTOMATIC_EXTENSIONLESS_MAPPING_DEFAULT = false;
-    
-    /**
-     * Indicate the class implementing FacesInitializer interface that will
-     * be used to setup MyFaces Core contexts.
-     * <p>This is used when some custom task must be done specifically when
-     * a myfaces web context is initialized or destroyed, or when MyFaces should
-     * be initialized in some custom environment. 
-     * </p>
-     */
-    @JSFWebConfigParam(since = "2.0.1", desc = "Class name of a custom FacesInitializer implementation.")
-    public static final String FACES_INITIALIZER = "org.apache.myfaces.FACES_INITIALIZER";
-    
-
-    /**
-     * Define the class implementing InjectionProvider interface to handle dependendy injection,
-     * PostConstruct and PreDestroy callbacks.
-     * 
-     * <p>This also can be configured using a SPI entry (/META-INF/services/...).</p>
-     */
-    @JSFWebConfigParam(name="org.apache.myfaces.spi.InjectionProvider", since="2.2")
-    public static final String INJECTION_PROVIDER = InjectionProvider.class.getName();
-    
-    @JSFWebConfigParam(name="org.apache.myfaces.WEBSOCKET_MAX_CONNECTIONS", since="2.3")
-    public static final String WEBSOCKET_MAX_CONNECTIONS = "org.apache.myfaces.WEBSOCKET_MAX_CONNECTIONS";
-    public static final Integer WEBSOCKET_MAX_CONNECTIONS_DEFAULT = 5000;
-    
-    
-    /**
-     * Defines if the clientbehavior scripts are passed as string or function to the faces.util.chain.
-     * "As string" is actually the default behavior of both MyFaces (until 2.3-next) and Mojarra.
-     * "As function" is quite usefull for CSP as no string needs to be evaluated as function.
-     * 
-     * Our faces.util.chain supports both of course.
-     */
-    @JSFWebConfigParam(name="org.apache.myfaces.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING", since="2.3-next", defaultValue = "false")
-    public static final String RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING = "org.apache.myfaces.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING";
-    public static final boolean RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING_DEFAULT = false;
-    
-    /**
-     * Defines if a session should be created (if one does not exist) before response rendering.
-     * When this parameter is set to true, a session will be created even when client side state 
-     * saving or stateless views are used, which can lead to unintended resource consumption.
-     * When this parameter is set to false, a session will only be created before response 
-     * rendering if a view is not transient and server side state saving is in use.     
-     */
-    @JSFWebConfigParam(since="2.3.6", defaultValue="false", expectedValues="true,false")
-    public static final String ALWAYS_FORCE_SESSION_CREATION = 
-            "org.apache.myfaces.ALWAYS_FORCE_SESSION_CREATION";
-    protected final static boolean ALWAYS_FORCE_SESSION_CREATION_DEFAULT = false;
-    
-    /**
-     * Defines the {@link java.util.ResourceBundle.Control} to use for all
-     * {@link java.util.ResourceBundle#getBundle(java.lang.String)} calls.
-     */
-    @JSFWebConfigParam(since="2.3-next")
-    public static final String RESOURCE_BUNDLE_CONTROL = 
-            "org.apache.myfaces.RESOURCE_BUNDLE_CONTROL";
-    
-    // we need it, applicationImpl not ready probably
-    private ProjectStage projectStage = ProjectStage.Production;
-    private boolean strictJsf2AllowSlashLibraryName;
-    private long configRefreshPeriod = CONFIG_REFRESH_PERIOD_DEFAULT;
-    private boolean renderViewStateId = RENDER_VIEWSTATE_ID_DEFAULT;
-    private boolean strictXhtmlLinks = STRICT_XHTML_LINKS_DEFAULT;
-    private boolean renderClearJavascriptOnButton = RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT;
-    private String delegateFacesServlet;
-    private boolean refreshTransientBuildOnPSS = true;
-    private boolean refreshTransientBuildOnPSSAuto = true;
-    private boolean refreshTransientBuildOnPSSPreserveState = REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT;
-    private boolean validateXML = VALIDATE_XML_DEFAULT;
-    private boolean wrapScriptContentWithXmlCommentTag = WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT;
-    private boolean debugPhaseListenerEnabled = DEBUG_PHASE_LISTENER_DEFAULT;
-    private boolean strictJsf2CCELResolver = STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT;
-    private String defaultResponseWriterContentTypeMode = DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT;
-    private boolean viewUniqueIdsCacheEnabled = VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT;
-    private int componentUniqueIdsCacheSize = COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT;
-    private boolean strictJsf2ViewNotFound = STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT;
-    private boolean earlyFlushEnabled = EARLY_FLUSH_ENABLED_DEFAULT;
-    private boolean strictJsf2FaceletsCompatibility = STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT;
-    private boolean renderFormViewStateAtBegin = RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT;
-    private boolean flashScopeDisabled = FLASH_SCOPE_DISABLED_DEFAULT;
-    private Integer numberOfViewsInSession = NUMBER_OF_VIEWS_IN_SESSION_DEFAULT;
-    private Integer numberOfSequentialViewsInSession = NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT;
-    private Integer numberOfFlashTokensInSession;
-    private Integer numberOfClientWindows;
-    private boolean supportEL3ImportHandler = SUPPORT_EL_3_IMPORT_HANDLER_DEFAULT;
-    private boolean strictJsf2OriginHeaderAppPath = STRICT_JSF_2_ORIGIN_HEADER_APP_PATH_DEFAULT;
-    private int resourceBufferSize = RESOURCE_BUFFER_SIZE_DEFAULT;
-    private boolean useCdiForAnnotationScanning = USE_CDI_FOR_ANNOTATION_SCANNING_DEFAULT;
-    private boolean resourceHandlerCacheEnabled = RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT;
-    private int resourceHandlerCacheSize = RESOURCE_HANDLER_CACHE_SIZE_DEFAULT;
-    private String scanPackages;
-    private long websocketMaxIdleTimeout = WEBSOCKET_MAX_IDLE_TIMEOUT_DEFAULT;
-    private Integer websocketEndpointPort;
-    private String randomKeyInWebsocketSessionToken = RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_DEFAULT;
-    private long clientViewStateTimeout = CLIENT_VIEW_STATE_TIMEOUT_DEFAULT;
-    private String randomKeyInViewStateSessionToken = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_DEFAULT;
-    private int randomKeyInViewStateSessionTokenLength = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH_DEFAULT;
-    private String randomKeyInViewStateSessionTokenSecureRandomClass;
-    private String randomKeyInViewStateSessionTokenSecureRandomProvider;
-    private String randomKeyInViewStateSessionTokenSecureRandomAlgorithm
-            = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM_DEFAULT;
-    private String randomKeyInCsrfSessionToken = RANDOM_KEY_IN_CSRF_SESSION_TOKEN_DEFAULT;
-    private boolean serializeStateInSession = false;
-    private boolean compressStateInSession = COMPRESS_STATE_IN_SESSION_DEFAULT;
-    private boolean useFlashScopePurgeViewsInSession = USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT;
-    private boolean autocompleteOffViewState = AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT;
-    private long resourceMaxTimeExpires = RESOURCE_MAX_TIME_EXPIRES_DEFAULT;
-    private boolean lazyLoadConfigObjects = LAZY_LOAD_CONFIG_OBJECTS_DEFAULT;
-    private String elResolverComparator;
-    private String elResolverPredicate;
-    private boolean viewIdExistsCacheEnabled = VIEWID_EXISTS_CACHE_ENABLED_DEFAULT;
-    private boolean viewIdProtectedCacheEnabled = VIEWID_PROTECTED_CACHE_ENABLED_DEFAULT;
-    private boolean viewIdDeriveCacheEnabled = VIEWID_DERIVE_CACHE_ENABLED_DEFAULT;
-    private int viewIdCacheSize = VIEWID_CACHE_SIZE_DEFAULT;
-    private boolean beanBeforeJsfValidation = BEAN_BEFORE_JSF_VALIDATION_DEFAULT;
-    private String facesInitPlugins;
-    private boolean initializeSkipJarFacesConfigScan = INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN_DEFAULT;
-    private String expressionFactory;
-    private String checkIdProductionMode = CHECK_ID_PRODUCTION_MODE_DEFAULT;
-    private boolean partialStateSaving = true;
-    private String[] fullStateSavingViewIds;
-    private int faceletsBufferSize = 1024;
-    private boolean markInitialStateWhenApplyBuildView = MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW_DEFAULT;
-    private String resourceResolver;
-    private String[] viewSuffix = new String[] { ViewHandler.DEFAULT_SUFFIX };
-    private String[] faceletsViewMappings = new String[] {};
-    private String faceletsViewSuffix = ViewHandler.DEFAULT_FACELETS_SUFFIX;
-    private ELExpressionCacheMode elExpressionCacheMode;
-    private boolean wrapTagExceptionsAsContextAware = WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE_DEFAULT;
-    private boolean resourceCacheLastModified = RESOURCE_CACHE_LAST_MODIFIED_DEFAULT;
-    private boolean logWebContextParams = false;
-    private int websocketMaxConnections = WEBSOCKET_MAX_CONNECTIONS_DEFAULT;
-    private boolean renderClientBehaviorScriptsAsString = RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING_DEFAULT;
-    private boolean alwaysForceSessionCreation = ALWAYS_FORCE_SESSION_CREATION_DEFAULT;
-    private ResourceBundle.Control resourceBundleControl;
-    private boolean automaticExtensionlessMapping = AUTOMATIC_EXTENSIONLESS_MAPPING_DEFAULT;
-    
-    private static final boolean MYFACES_IMPL_AVAILABLE;
-    private static final boolean RI_IMPL_AVAILABLE;
-
-    static
-    {
-        boolean myfacesImplAvailable;
-        try
-        {
-            ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
-            myfacesImplAvailable = true;
-        }
-        catch (ClassNotFoundException e)
-        {
-            myfacesImplAvailable = false;
-        }
-        MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
-        
-        boolean riImplAvailable;
-        try
-        {
-            ClassUtils.classForName("com.sun.faces.application.ApplicationImpl");
-            riImplAvailable = true;
-        }
-        catch (ClassNotFoundException e)
-        {
-            riImplAvailable = false;
-        }
-        RI_IMPL_AVAILABLE = riImplAvailable;
-    }
-
-    public static MyfacesConfig getCurrentInstance()
-    {
-        return getCurrentInstance(FacesContext.getCurrentInstance().getExternalContext());
-    }
-    
-    public static MyfacesConfig getCurrentInstance(FacesContext facesContext)
-    {
-        return getCurrentInstance(facesContext.getExternalContext());
-    }
-    
-    public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
-    {
-        MyfacesConfig config = (MyfacesConfig) extCtx.getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
-        if (config == null)
-        {
-            config = createAndInitializeMyFacesConfig(extCtx);
-            extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, config);
-        }
-
-        return config;
-    }
-    
-    public MyfacesConfig()
-    {
-        numberOfFlashTokensInSession = (NUMBER_OF_VIEWS_IN_SESSION_DEFAULT
-                / NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT) + 1;
-    }
-
-    private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx)
-    {
-        MyfacesConfig cfg = new MyfacesConfig();
-
-        try
-        {
-            cfg.projectStage = ProjectStage.valueOf(getString(extCtx, ProjectStage.PROJECT_STAGE_PARAM_NAME, null));
-        }
-        catch (Exception e)
-        {
-            // ignore, it's logged in ApplicationImpl
-        }
-        if (cfg.projectStage == null)
-        {
-            cfg.projectStage = ProjectStage.Production;
-        }
-
-        cfg.renderClearJavascriptOnButton = getBoolean(extCtx, RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON,
-                RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT);
-
-        cfg.renderViewStateId = getBoolean(extCtx, RENDER_VIEWSTATE_ID,
-                RENDER_VIEWSTATE_ID_DEFAULT);
-        
-        cfg.strictXhtmlLinks = getBoolean(extCtx, STRICT_XHTML_LINKS,
-                STRICT_XHTML_LINKS_DEFAULT);
-        
-        cfg.configRefreshPeriod = getLong(extCtx, CONFIG_REFRESH_PERIOD,
-                CONFIG_REFRESH_PERIOD_DEFAULT);
-
-        cfg.delegateFacesServlet = getString(extCtx, DELEGATE_FACES_SERVLET,
-                null);
-        
-        String refreshTransientBuildOnPSS = getString(extCtx, REFRESH_TRANSIENT_BUILD_ON_PSS, 
-                REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT);
-        if (refreshTransientBuildOnPSS == null)
-        {
-            cfg.refreshTransientBuildOnPSS = false;
-            cfg.refreshTransientBuildOnPSSAuto = false;
-        }
-        else if ("auto".equalsIgnoreCase(refreshTransientBuildOnPSS))
-        {
-            cfg.refreshTransientBuildOnPSS = true;
-            cfg.refreshTransientBuildOnPSSAuto = true;
-        }
-        else if (refreshTransientBuildOnPSS.equalsIgnoreCase("true") || 
-                refreshTransientBuildOnPSS.equalsIgnoreCase("on") || 
-                refreshTransientBuildOnPSS.equalsIgnoreCase("yes"))
-        {
-            cfg.refreshTransientBuildOnPSS = true;
-            cfg.refreshTransientBuildOnPSSAuto = false;
-        }
-        else
-        {
-            cfg.refreshTransientBuildOnPSS = false;
-            cfg.refreshTransientBuildOnPSSAuto = false;
-        }
-        
-        cfg.refreshTransientBuildOnPSSPreserveState = getBoolean(extCtx, REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE,
-                REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT);
-        
-        cfg.validateXML = getBoolean(extCtx, VALIDATE_XML, 
-                VALIDATE_XML_DEFAULT);
-        
-        cfg.wrapScriptContentWithXmlCommentTag = getBoolean(extCtx, WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG, 
-                WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT);
-        
-        cfg.debugPhaseListenerEnabled = getBoolean(extCtx, DEBUG_PHASE_LISTENER,
-                DEBUG_PHASE_LISTENER_DEFAULT);
-                
-        cfg.strictJsf2CCELResolver = getBoolean(extCtx, STRICT_JSF_2_CC_EL_RESOLVER,
-                STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT);
-        
-        cfg.defaultResponseWriterContentTypeMode = getString(extCtx, DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE,
-                DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT);
-
-        cfg.viewUniqueIdsCacheEnabled = getBoolean(extCtx, VIEW_UNIQUE_IDS_CACHE_ENABLED,
-                VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT);
-
-        cfg.componentUniqueIdsCacheSize = getInt(extCtx, COMPONENT_UNIQUE_IDS_CACHE_SIZE, 
-                COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT);
-
-        cfg.strictJsf2ViewNotFound = getBoolean(extCtx, STRICT_JSF_2_VIEW_NOT_FOUND,
-                STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT);
-        
-        cfg.earlyFlushEnabled = getBoolean(extCtx, EARLY_FLUSH_ENABLED,
-                EARLY_FLUSH_ENABLED_DEFAULT);
-        if (cfg.projectStage != ProjectStage.Production)
-        {
-            cfg.earlyFlushEnabled = false;
-        }
-
-        cfg.strictJsf2FaceletsCompatibility = getBoolean(extCtx, STRICT_JSF_2_FACELETS_COMPATIBILITY, 
-                STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT);
-        
-        cfg.renderFormViewStateAtBegin = getBoolean(extCtx, RENDER_FORM_VIEW_STATE_AT_BEGIN,
-                RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT);
-        
-        cfg.flashScopeDisabled = getBoolean(extCtx, FLASH_SCOPE_DISABLED,
-                FLASH_SCOPE_DISABLED_DEFAULT);
-        
-        cfg.strictJsf2AllowSlashLibraryName = getBoolean(extCtx, STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME,
-                STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME_DEFAULT);
-        
-        try
-        {
-            cfg.numberOfSequentialViewsInSession = getInt(extCtx, NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION,
-                    NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT);
-            if (cfg.numberOfSequentialViewsInSession == null
-                    || cfg.numberOfSequentialViewsInSession < 0)
-            {
-                Logger.getLogger(MyfacesConfig.class.getName()).severe(
-                        "Configured value for " + NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION
-                          + " is not valid, must be an value >= 0, using default value ("
-                          + NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT);
-                cfg.numberOfSequentialViewsInSession = NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT;
-            }
-        }
-        catch (Throwable e)
-        {
-            Logger.getLogger(MyfacesConfig.class.getName()).log(Level.SEVERE, "Error determining the value for "
-                   + NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION
-                   + ", expected an integer value > 0, using default value ("
-                   + NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT + "): " + e.getMessage(), e);
-        }        
-        try
-        {
-            cfg.numberOfViewsInSession = getInt(extCtx, NUMBER_OF_VIEWS_IN_SESSION,
-                    NUMBER_OF_VIEWS_IN_SESSION_DEFAULT);
-            if (cfg.numberOfViewsInSession == null || cfg.numberOfViewsInSession <= 0)
-            {
-                Logger.getLogger(MyfacesConfig.class.getName()).severe(
-                        "Configured value for " + NUMBER_OF_VIEWS_IN_SESSION
-                          + " is not valid, must be an value > 0, using default value ("
-                          + NUMBER_OF_VIEWS_IN_SESSION_DEFAULT);
-                cfg.numberOfViewsInSession = NUMBER_OF_VIEWS_IN_SESSION_DEFAULT;
-            }
-        }
-        catch (Throwable e)
-        {
-            Logger.getLogger(MyfacesConfig.class.getName()).log(Level.SEVERE, "Error determining the value for "
-                   + NUMBER_OF_VIEWS_IN_SESSION
-                   + ", expected an integer value > 0, using default value ("
-                   + NUMBER_OF_VIEWS_IN_SESSION_DEFAULT + "): " + e.getMessage(), e);
-        }
-
-        Integer numberOfFlashTokensInSessionDefault;
-        if (cfg.numberOfSequentialViewsInSession != null && cfg.numberOfSequentialViewsInSession > 0)
-        {
-            numberOfFlashTokensInSessionDefault = (cfg.numberOfViewsInSession
-                    / cfg.numberOfSequentialViewsInSession) + 1;
-        }
-        else
-        {
-            numberOfFlashTokensInSessionDefault = cfg.numberOfViewsInSession + 1;
-        }
-
-        cfg.numberOfFlashTokensInSession = getInt(extCtx, NUMBER_OF_FLASH_TOKENS_IN_SESSION,
-                numberOfFlashTokensInSessionDefault);
-
-        cfg.numberOfClientWindows = getInt(extCtx,
-                ClientWindow.NUMBER_OF_CLIENT_WINDOWS_PARAM_NAME, 
-                10);
-                        
-        cfg.supportEL3ImportHandler = getBoolean(extCtx, SUPPORT_EL_3_IMPORT_HANDLER, 
-                SUPPORT_EL_3_IMPORT_HANDLER_DEFAULT); 
-
-        cfg.strictJsf2OriginHeaderAppPath = getBoolean(extCtx, STRICT_JSF_2_ORIGIN_HEADER_APP_PATH, 
-                STRICT_JSF_2_ORIGIN_HEADER_APP_PATH_DEFAULT);
-
-        cfg.resourceBufferSize = getInt(extCtx, RESOURCE_BUFFER_SIZE, 
-                RESOURCE_BUFFER_SIZE_DEFAULT);
-        
-        cfg.useCdiForAnnotationScanning = getBoolean(extCtx, USE_CDI_FOR_ANNOTATION_SCANNING,
-                USE_CDI_FOR_ANNOTATION_SCANNING_DEFAULT);
-        
-        cfg.resourceHandlerCacheEnabled = getBoolean(extCtx, RESOURCE_HANDLER_CACHE_ENABLED,
-                RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT);
-        if (cfg.projectStage != ProjectStage.Production)
-        {
-            cfg.resourceHandlerCacheEnabled = false;
-        }
-        
-        cfg.resourceHandlerCacheSize = getInt(extCtx, RESOURCE_HANDLER_CACHE_SIZE,
-                RESOURCE_HANDLER_CACHE_SIZE_DEFAULT);
-        
-        cfg.scanPackages = getString(extCtx, SCAN_PACKAGES,
-                null);
-        
-        String websocketEndpointPort = extCtx.getInitParameter(WEBSOCKET_ENDPOINT_PORT);
-        if (websocketEndpointPort != null && !websocketEndpointPort.isEmpty())
-        {
-            cfg.websocketEndpointPort = Integer.valueOf(websocketEndpointPort);
-        }
-        
-        cfg.websocketMaxIdleTimeout = getLong(extCtx, WEBSOCKET_MAX_IDLE_TIMEOUT,
-                WEBSOCKET_MAX_IDLE_TIMEOUT_DEFAULT);
-        
-        cfg.randomKeyInWebsocketSessionToken = getString(extCtx, RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN,
-                RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_DEFAULT);
-        
-        cfg.clientViewStateTimeout = getLong(extCtx, CLIENT_VIEW_STATE_TIMEOUT,
-                CLIENT_VIEW_STATE_TIMEOUT_DEFAULT);
-        if (cfg.clientViewStateTimeout < 0L)
-        {
-            cfg.clientViewStateTimeout = 0L;
-        }
-        
-        cfg.randomKeyInViewStateSessionToken = getString(extCtx, RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN,
-                RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_DEFAULT);
-        
-        cfg.randomKeyInViewStateSessionTokenLength = getInt(extCtx, RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH,
-                RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH_DEFAULT);
-        
-        cfg.randomKeyInViewStateSessionTokenSecureRandomClass = getString(extCtx,
-                RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_CLASS,
-                null);
-        
-        cfg.randomKeyInViewStateSessionTokenSecureRandomProvider = getString(extCtx,
-                RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_PROVIDER,
-                null);
-        
-        cfg.randomKeyInViewStateSessionTokenSecureRandomAlgorithm = getString(extCtx,
-                RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM,
-                RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM_DEFAULT);
-        
-        cfg.randomKeyInCsrfSessionToken = getString(extCtx, RANDOM_KEY_IN_CSRF_SESSION_TOKEN,
-                RANDOM_KEY_IN_CSRF_SESSION_TOKEN_DEFAULT);
-        
-        cfg.serializeStateInSession = getBoolean(extCtx, StateManager.SERIALIZE_SERVER_STATE_PARAM_NAME,
-                false);
-        
-        cfg.compressStateInSession = getBoolean(extCtx, COMPRESS_STATE_IN_SESSION,
-                COMPRESS_STATE_IN_SESSION_DEFAULT);
-        
-        cfg.useFlashScopePurgeViewsInSession = getBoolean(extCtx, USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION,
-                USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT);
-
-        cfg.autocompleteOffViewState = getBoolean(extCtx, AUTOCOMPLETE_OFF_VIEW_STATE,
-                AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT);
-        
-        cfg.resourceMaxTimeExpires = getLong(extCtx, RESOURCE_MAX_TIME_EXPIRES,
-                RESOURCE_MAX_TIME_EXPIRES_DEFAULT);
-        
-        cfg.lazyLoadConfigObjects = getBoolean(extCtx, LAZY_LOAD_CONFIG_OBJECTS,
-                LAZY_LOAD_CONFIG_OBJECTS_DEFAULT);
-        
-        cfg.elResolverComparator = getString(extCtx, EL_RESOLVER_COMPARATOR,
-                null);
-        
-        cfg.elResolverPredicate = getString(extCtx, EL_RESOLVER_PREDICATE,
-                null);
-        
-        cfg.viewIdExistsCacheEnabled = getBoolean(extCtx, VIEWID_EXISTS_CACHE_ENABLED,
-                VIEWID_EXISTS_CACHE_ENABLED_DEFAULT);
-        if (cfg.projectStage == ProjectStage.Development)
-        {
-            cfg.viewIdExistsCacheEnabled = false;
-        }
-        
-        cfg.viewIdProtectedCacheEnabled = getBoolean(extCtx, VIEWID_PROTECTED_CACHE_ENABLED,
-                VIEWID_PROTECTED_CACHE_ENABLED_DEFAULT);
-        if (cfg.projectStage == ProjectStage.Development)
-        {
-            cfg.viewIdProtectedCacheEnabled = false;
-        }
-
-        cfg.viewIdDeriveCacheEnabled = getBoolean(extCtx, VIEWID_DERIVE_CACHE_ENABLED,
-                VIEWID_DERIVE_CACHE_ENABLED_DEFAULT);
-        if (cfg.projectStage == ProjectStage.Development)
-        {
-            cfg.viewIdDeriveCacheEnabled = false;
-        }
-        
-        cfg.viewIdCacheSize = getInt(extCtx, VIEWID_CACHE_SIZE,
-                VIEWID_CACHE_SIZE_DEFAULT);
-
-        cfg.beanBeforeJsfValidation = getBoolean(extCtx, BEAN_BEFORE_JSF_VALIDATION,
-                BEAN_BEFORE_JSF_VALIDATION_DEFAULT);
-        
-        cfg.facesInitPlugins = getString(extCtx, FACES_INIT_PLUGINS,
-                null);
-        
-        cfg.initializeSkipJarFacesConfigScan = getBoolean(extCtx, INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN,
-                INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN_DEFAULT);
-        
-        cfg.expressionFactory = getString(extCtx, EXPRESSION_FACTORY,
-                null);
-        
-        cfg.checkIdProductionMode = getString(extCtx, CHECK_ID_PRODUCTION_MODE,
-                CHECK_ID_PRODUCTION_MODE_DEFAULT);
-        
-        // Per spec section 11.1.3, the default value for the partial state saving feature needs
-        // to be true if 2.0, false otherwise.
-        // lets ignore this on 3.x
-        cfg.partialStateSaving = getBoolean(extCtx, StateManager.PARTIAL_STATE_SAVING_PARAM_NAME,
-                true);
-
-        cfg.fullStateSavingViewIds = StringUtils.splitShortString(
-                getString(extCtx, StateManager.FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME, null),
-                ',');
-        
-        cfg.faceletsBufferSize = getInt(extCtx, ViewHandler.FACELETS_BUFFER_SIZE_PARAM_NAME,
-                1024);
-        
-        cfg.markInitialStateWhenApplyBuildView = getBoolean(extCtx, MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW,
-                MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW_DEFAULT);
-        
-        cfg.resourceResolver = getString(extCtx, FACELETS_RESOURCE_RESOLVER,
-                null);
-        
-        cfg.viewSuffix = StringUtils.splitShortString(
-                getString(extCtx, ViewHandler.DEFAULT_SUFFIX_PARAM_NAME, ViewHandler.DEFAULT_SUFFIX),
-                ' ');
-        
-        cfg.faceletsViewMappings = StringUtils.splitShortString(
-                getString(extCtx, ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME, null),
-                ';');
-        
-        cfg.faceletsViewSuffix = getString(extCtx, ViewHandler.FACELETS_SUFFIX_PARAM_NAME,
-                ViewHandler.DEFAULT_FACELETS_SUFFIX);
-        
-        String elExpressionCacheMode = getString(extCtx, CACHE_EL_EXPRESSIONS,
-                CACHE_EL_EXPRESSIONS_DEFAULT);    
-        cfg.elExpressionCacheMode = Enum.valueOf(ELExpressionCacheMode.class, elExpressionCacheMode); 
- 
-        cfg.wrapTagExceptionsAsContextAware = getBoolean(extCtx, WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE,
-                WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE_DEFAULT);
-        
-        cfg.resourceCacheLastModified = getBoolean(extCtx, RESOURCE_CACHE_LAST_MODIFIED,
-                RESOURCE_CACHE_LAST_MODIFIED_DEFAULT);
-        if (cfg.projectStage == ProjectStage.Development)
-        {
-            cfg.resourceCacheLastModified = false;
-        }
-        
-        String logWebContextParams = getString(extCtx, LOG_WEB_CONTEXT_PARAMS,
-                LOG_WEB_CONTEXT_PARAMS_DEFAULT);    
-        if (logWebContextParams.equals("false") || (logWebContextParams.equals("auto")
-                && (cfg.projectStage == ProjectStage.SystemTest || cfg.projectStage == ProjectStage.UnitTest)))
-        {
-            cfg.logWebContextParams = false;
-        }
-        else
-        {
-            cfg.logWebContextParams = true;
-        }
-        
-        cfg.websocketMaxConnections = getInt(extCtx, WEBSOCKET_MAX_CONNECTIONS,
-                WEBSOCKET_MAX_CONNECTIONS_DEFAULT);
-
-        cfg.renderClientBehaviorScriptsAsString = getBoolean(extCtx, RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING,
-                RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING_DEFAULT);
-
-        cfg.alwaysForceSessionCreation = getBoolean(extCtx, ALWAYS_FORCE_SESSION_CREATION,
-                ALWAYS_FORCE_SESSION_CREATION_DEFAULT);
-        
-        String resourceBundleControl = getString(extCtx, RESOURCE_BUNDLE_CONTROL, null);
-        if (StringUtils.isNotBlank(resourceBundleControl))
-        {
-            cfg.resourceBundleControl = (ResourceBundle.Control) ClassUtils.newInstance(resourceBundleControl);
-        }
-        
-        cfg.automaticExtensionlessMapping = getBoolean(extCtx, AUTOMATIC_EXTENSIONLESS_MAPPING,
-                AUTOMATIC_EXTENSIONLESS_MAPPING_DEFAULT);
-
-        return cfg;
-    }
-
-    private static boolean getBoolean(ExternalContext externalContext, String paramName, boolean defaultValue)
-    {
-        String value = externalContext.getInitParameter(paramName);
-        if (value == null)
-        {
-            return defaultValue;
-        }
-
-        if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("on") || value.equalsIgnoreCase("yes"))
-        {
-            return true;
-        }
-        else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("off") || value.equalsIgnoreCase("no"))
-        {
-            return false;
-        }
-
-        return defaultValue;
-    }
-
-    private static String getString(ExternalContext externalContext, String paramName, String defaultValue)
-    {
-        String value = externalContext.getInitParameter(paramName);
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        
-        return value;
-    }
-
-    private static int getInt(ExternalContext externalContext, String paramName, int defaultValue)
-    {
-        String value = externalContext.getInitParameter(paramName);
-        if (value == null)
-        {
-            return defaultValue;
-        }
-
-        try
-        {
-            return Integer.parseInt(value);
-        }
-        catch (NumberFormatException e)
-        {
-        }
-        return defaultValue;
-    }
-    
-    private static long getLong(ExternalContext externalContext, String paramName, long defaultValue)
-    {
-       String value = externalContext.getInitParameter(paramName);
-       if (value == null)
-       {
-           return defaultValue;
-       }
-
-        try
-        {
-            return Long.parseLong(value);
-        }
-        catch (NumberFormatException e)
-        {
-        }
-        return defaultValue;
-    }
-
-    public boolean isMyfacesImplAvailable()
-    {
-        return MYFACES_IMPL_AVAILABLE;
-    }
-
-    public boolean isRiImplAvailable()
-    {
-        return RI_IMPL_AVAILABLE;
-    }
-
-    public boolean isStrictJsf2AllowSlashLibraryName()
-    {
-        return strictJsf2AllowSlashLibraryName;
-    }
-
-    public long getConfigRefreshPeriod()
-    {
-        return configRefreshPeriod;
-    }
-
-    public boolean isRenderViewStateId()
-    {
-        return renderViewStateId;
-    }
-
-    public boolean isStrictXhtmlLinks()
-    {
-        return strictXhtmlLinks;
-    }
-
-    public boolean isRenderClearJavascriptOnButton()
-    {
-        return renderClearJavascriptOnButton;
-    }
-
-    public String getDelegateFacesServlet()
-    {
-        return delegateFacesServlet;
-    }
-
-    public boolean isRefreshTransientBuildOnPSS()
-    {
-        return refreshTransientBuildOnPSS;
-    }
-
-    public boolean isRefreshTransientBuildOnPSSAuto()
-    {
-        return refreshTransientBuildOnPSSAuto;
-    }
-
-    public boolean isRefreshTransientBuildOnPSSPreserveState()
-    {
-        return refreshTransientBuildOnPSSPreserveState;
-    }
-
-    public boolean isValidateXML()
-    {
-        return validateXML;
-    }
-
-    public boolean isWrapScriptContentWithXmlCommentTag()
-    {
-        return wrapScriptContentWithXmlCommentTag;
-    }
-
-    public boolean isDebugPhaseListenerEnabled()
-    {
-        return debugPhaseListenerEnabled;
-    }
-
-    public boolean isStrictJsf2CCELResolver()
-    {
-        return strictJsf2CCELResolver;
-    }
-
-    public String getDefaultResponseWriterContentTypeMode()
-    {
-        return defaultResponseWriterContentTypeMode;
-    }
-
-    public boolean isViewUniqueIdsCacheEnabled()
-    {
-        return viewUniqueIdsCacheEnabled;
-    }
-
-    public int getComponentUniqueIdsCacheSize()
-    {
-        return componentUniqueIdsCacheSize;
-    }
-
-    public boolean isStrictJsf2ViewNotFound()
-    {
-        return strictJsf2ViewNotFound;
-    }
-
-    public boolean isEarlyFlushEnabled()
-    {
-        return earlyFlushEnabled;
-    }
-
-    public boolean isStrictJsf2FaceletsCompatibility()
-    {
-        return strictJsf2FaceletsCompatibility;
-    }
-
-    public boolean isRenderFormViewStateAtBegin()
-    {
-        return renderFormViewStateAtBegin;
-    }
-
-    public boolean isFlashScopeDisabled()
-    {
-        return flashScopeDisabled;
-    }
-
-    public Integer getNumberOfViewsInSession()
-    {
-        return numberOfViewsInSession;
-    }
-
-    public Integer getNumberOfSequentialViewsInSession()
-    {
-        return numberOfSequentialViewsInSession;
-    }
-
-    public Integer getNumberOfFlashTokensInSession()
-    {
-        return numberOfFlashTokensInSession;
-    }
-
-    public boolean isSupportEL3ImportHandler()
-    {
-        return supportEL3ImportHandler;
-    }
-
-    public boolean isStrictJsf2OriginHeaderAppPath()
-    {
-        return strictJsf2OriginHeaderAppPath;
-    }
-
-    public int getResourceBufferSize()
-    {
-        return resourceBufferSize;
-    }
-
-    public boolean isUseCdiForAnnotationScanning()
-    {
-        return useCdiForAnnotationScanning;
-    }
-
-    public boolean isResourceHandlerCacheEnabled()
-    {
-        return resourceHandlerCacheEnabled;
-    }
-
-    public int getResourceHandlerCacheSize()
-    {
-        return resourceHandlerCacheSize;
-    }
-
-    public String getScanPackages()
-    {
-        return scanPackages;
-    }
-
-    public long getWebsocketMaxIdleTimeout()
-    {
-        return websocketMaxIdleTimeout;
-    }   
-    
-    public Integer getWebsocketEndpointPort()
-    {
-        return websocketEndpointPort;
-    }
-
-    public long getClientViewStateTimeout()
-    {
-        return clientViewStateTimeout;
-    }
-
-    public String getRandomKeyInViewStateSessionToken()
-    {
-        return randomKeyInViewStateSessionToken;
-    }
-
-    public int getRandomKeyInViewStateSessionTokenLength()
-    {
-        return randomKeyInViewStateSessionTokenLength;
-    }
-
-    public String getRandomKeyInViewStateSessionTokenSecureRandomClass()
-    {
-        return randomKeyInViewStateSessionTokenSecureRandomClass;
-    }
-
-    public String getRandomKeyInViewStateSessionTokenSecureRandomProvider()
-    {
-        return randomKeyInViewStateSessionTokenSecureRandomProvider;
-    }
-
-    public String getRandomKeyInViewStateSessionTokenSecureRandomAlgorithm()
-    {
-        return randomKeyInViewStateSessionTokenSecureRandomAlgorithm;
-    }
-
-    public String getRandomKeyInCsrfSessionToken()
-    {
-        return randomKeyInCsrfSessionToken;
-    }
-
-    public boolean isSerializeStateInSession()
-    {
-        return serializeStateInSession;
-    }
-
-    public boolean isCompressStateInSession()
-    {
-        return compressStateInSession;
-    }
-
-    public boolean isUseFlashScopePurgeViewsInSession()
-    {
-        return useFlashScopePurgeViewsInSession;
-    }
-
-    public boolean isAutocompleteOffViewState()
-    {
-        return autocompleteOffViewState;
-    }
-
-    public long getResourceMaxTimeExpires()
-    {
-        return resourceMaxTimeExpires;
-    }
-
-    public boolean isLazyLoadConfigObjects()
-    {
-        return lazyLoadConfigObjects;
-    }
-
-    public String getElResolverComparator()
-    {
-        return elResolverComparator;
-    }
-
-    public String getElResolverPredicate()
-    {
-        return elResolverPredicate;
-    }
-
-    public int getViewIdCacheSize()
-    {
-        return viewIdCacheSize;
-    }
-
-    public boolean isBeanBeforeJsfValidation()
-    {
-        return beanBeforeJsfValidation;
-    }
-
-    public String getRandomKeyInWebsocketSessionToken()
-    {
-        return randomKeyInWebsocketSessionToken;
-    }
-
-    public String getFacesInitPlugins()
-    {
-        return facesInitPlugins;
-    }
-
-    public boolean isInitializeSkipJarFacesConfigScan()
-    {
-        return initializeSkipJarFacesConfigScan;
-    }
-
-    public String getExpressionFactory()
-    {
-        return expressionFactory;
-    }
-
-    public String getCheckIdProductionMode()
-    {
-        return checkIdProductionMode;
-    }
-
-    public boolean isPartialStateSaving()
-    {
-        return partialStateSaving;
-    }
-
-    public String[] getFullStateSavingViewIds()
-    {
-        return fullStateSavingViewIds;
-    }
-
-    public int getFaceletsBufferSize()
-    {
-        return faceletsBufferSize;
-    }
-
-    public boolean isMarkInitialStateWhenApplyBuildView()
-    {
-        return markInitialStateWhenApplyBuildView;
-    }
-
-    public String getResourceResolver()
-    {
-        return resourceResolver;
-    }
-
-    public String[] getViewSuffix()
-    {
-        return viewSuffix;
-    }
-
-    public String[] getFaceletsViewMappings()
-    {
-        return faceletsViewMappings;
-    }
-
-    public String getFaceletsViewSuffix()
-    {
-        return faceletsViewSuffix;
-    }
-
-    public boolean isViewIdExistsCacheEnabled()
-    {
-        return viewIdExistsCacheEnabled;
-    }
-
-    public boolean isViewIdProtectedCacheEnabled()
-    {
-        return viewIdProtectedCacheEnabled;
-    }
-
-    public boolean isViewIdDeriveCacheEnabled()
-    {
-        return viewIdDeriveCacheEnabled;
-    }
-
-    public ELExpressionCacheMode getELExpressionCacheMode()
-    {
-        return elExpressionCacheMode;
-    }
-
-    public boolean isWrapTagExceptionsAsContextAware()
-    {
-        return wrapTagExceptionsAsContextAware;
-    }
-
-    public boolean isResourceCacheLastModified()
-    {
-        return resourceCacheLastModified;
-    }
-
-    public boolean isLogWebContextParams()
-    {
-        return logWebContextParams;
-    }
-
-    public int getWebsocketMaxConnections()
-    {
-        return websocketMaxConnections;
-    }
-
-    public boolean isRenderClientBehaviorScriptsAsString()
-    {
-        return renderClientBehaviorScriptsAsString;
-    }
-
-    public boolean isAlwaysForceSessionCreation()
-    {
-        return alwaysForceSessionCreation;
-    }
-
-    public ProjectStage getProjectStage()
-    {
-        return projectStage;
-    }
-
-    public ResourceBundle.Control getResourceBundleControl()
-    {
-        return resourceBundleControl;
-    }
-
-    public boolean isAutomaticExtensionlessMapping()
-    {
-        return automaticExtensionlessMapping;
-    }
-
-    public Integer getNumberOfClientWindows()
-    {
-        return numberOfClientWindows;
-    }
-}
-
+/*
+ * 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.config;
+
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import jakarta.faces.application.ProjectStage;
+import jakarta.faces.application.StateManager;
+import jakarta.faces.application.ViewHandler;
+import jakarta.faces.context.ExternalContext;
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.lifecycle.ClientWindow;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
+import org.apache.myfaces.spi.InjectionProvider;
+import org.apache.myfaces.util.lang.ClassUtils;
+import org.apache.myfaces.util.lang.StringUtils;
+import org.apache.myfaces.view.facelets.ELExpressionCacheMode;
+
+/**
+ * Holds all configuration init parameters (from web.xml) that are independent
+ * from the core implementation. The parameters in this class are available to
+ * all shared, component and implementation classes.
+ * See RuntimeConfig for configuration infos that come from the faces-config
+ * files and are needed by the core implementation.
+ *
+ * MyfacesConfig is meant for components that implement some of the extended features
+ * of MyFaces. Anyhow, using the MyFaces JSF implementation is no precondition for using
+ * MyfacesConfig in custom components. Upon using another JSF implementation
+ * (or omitting the extended init parameters) all config properties will simply have
+ * their default values.
+ */
+//CHECKSTYLE:OFF
+public class MyfacesConfig
+{
+    private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
+
+    /**
+     * Set the time in seconds that check for updates of web.xml and faces-config descriptors and 
+     * refresh the configuration.
+     * This param is valid only if project stage is not production. Set this param to 0 disable this feature.
+     */
+    @JSFWebConfigParam(defaultValue="2",since="1.1", classType="java.lang.Long")
+    public static final String CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
+    private static final long CONFIG_REFRESH_PERIOD_DEFAULT = 2;
+
+    /**
+     * Define if the input field that should store the state (jakarta.faces.ViewState) should render 
+     * id="jakarta.faces.ViewState".
+     * 
+     * JSF API 1.2 defines a "jakarta.faces.ViewState" client parameter, that must be rendered as both the "name"
+     * and the "id" attribute of the hidden input that is rendered for the purpose of state saving
+     * (see ResponseStateManager.VIEW_STATE_PARAM).
+     * Actually this causes duplicate id attributes and thus invalid XHTML pages when multiple forms are rendered on
+     * one page. With the org.apache.myfaces.RENDER_VIEWSTATE_ID context parameter you can tune this behaviour.
+     * <br/>Set it to
+     * <ul><li>true - to render JSF 1.2 compliant id attributes (that might cause invalid XHTML), or</li>
+     * <li>false - to omit rendering of the id attribute (which is only needed for very special 
+     * AJAX/Javascript components)</li></ul>
+     * Default value is: true (for backwards compatibility and JSF 1.2 compliancy) 
+     */
+    @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1", 
+            ignoreUpperLowerCase=true, group="state")
+    public static final String RENDER_VIEWSTATE_ID = "org.apache.myfaces.RENDER_VIEWSTATE_ID";
+    private static final boolean RENDER_VIEWSTATE_ID_DEFAULT = true;
+
+    /**
+     * Use "&amp;amp;" entity instead a plain "&amp;" character within HTML.
+     * <p>W3C recommends to use the "&amp;amp;" entity instead of a plain "&amp;" character within HTML.
+     * This also applies to attribute values and thus to the "href" attribute of &lt;a&gt; elements as well.
+     * Even more, when XHTML is used as output the usage of plain "&amp;" characters is forbidden and would lead to
+     * invalid XML code.
+     * Therefore, since version 1.1.6 MyFaces renders the correct "&amp;amp;" entity for links.</p>
+     * <p>The init parameter
+     * org.apache.myfaces.STRICT_XHTML_LINKS makes it possible to restore the old behaviour and to make MyFaces
+     * "bug compatible" to the Sun RI which renders plain "&amp;" chars in links as well.</p>
+     * <p>
+     * See: <a href="http://www.w3.org/TR/html401/charset.html#h-5.3.2">HTML 4.01 Specification</a>
+     * See: <a href="http://issues.apache.org/jira/browse/MYFACES-1774">Jira: MYFACES-1774</a>
+     * </p>
+     */
+    @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1.6", 
+            ignoreUpperLowerCase=true, group="render")
+    public static final String STRICT_XHTML_LINKS = "org.apache.myfaces.STRICT_XHTML_LINKS";
+    private static final boolean STRICT_XHTML_LINKS_DEFAULT = true;
+    
+    /**
+     * This param renders the clear javascript on button necessary only for
+     * compatibility with hidden fields feature of myfaces. This is done 
+     * because jsf ri does not render javascript on onclick method for button,
+     * so myfaces should do this.
+     */
+    @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.2.3",
+            ignoreUpperLowerCase=true, group="render")
+    public static final String RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON = 
+        "org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON";
+    private static final boolean RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT= false;
+
+    /**
+     * Define an alternate class name that will be used to initialize MyFaces, instead the default 
+     * jakarta.faces.webapp.FacesServlet.
+     * 
+     * <p>This helps MyFaces to detect the mappings and other additional configuration used to setup the 
+     * environment, and prevent abort initialization if no FacesServlet config is detected.
+     * </p>
+     */
+    @JSFWebConfigParam(since="1.2.7")
+    public static final String DELEGATE_FACES_SERVLET = "org.apache.myfaces.DELEGATE_FACES_SERVLET";
+
+    /**
+     * Indicate if the facelet associated to the view should be reapplied when the view is refreshed.
+     *  Default mode is "auto".
+     * 
+     * <p>This param is only valid when partial state saving is on.
+     * If this is set as true, the tag-handlers are always reapplied before render view, like in facelets 1.1.x, 
+     * allowing c:if work correctly to "toggle" components based on a value changed on invoke application phase. 
+     * If the param is set as "auto", the implementation check if c:if, c:forEach, 
+     * c:choose and ui:include with src=ELExpression is used on the page and if that so, mark the view
+     * to be refreshed.</p> 
+     */
+    @JSFWebConfigParam(since="2.0", defaultValue="auto", expectedValues="true,false,auto", tags="performance", 
+            ignoreUpperLowerCase=true, group="state")
+    public final static String REFRESH_TRANSIENT_BUILD_ON_PSS = 
+        "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS"; 
+    private final static String REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT = "auto";
+
+    /**
+     * Enable or disable a special mode that enable full state for parent components containing c:if, c:forEach, 
+     * c:choose and ui:include with src=ELExpression. By default is disabled(false).
+     * 
+     * <p>This param is only valid when partial state saving is on.
+     * If this is set as true, parent components containing  c:if, c:forEach, 
+     * c:choose and ui:include with src=ELExpression are marked to be restored fully, so state
+     * is preserved between request.</p>
+     */
+    @JSFWebConfigParam(since="2.0", defaultValue="false", expectedValues="true, false, on, off, yes, no", 
+            tags="performance", ignoreUpperLowerCase=true, group="state")
+    public final static String REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE = 
+        "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE";
+    private final static boolean REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT = false;
+    
+    /**
+     * If set to <code>true</code>, tag library XML files and faces config XML files using schema 
+     * will be validated during application start up
+     */
+    @JSFWebConfigParam(since="2.0", expectedValues="true, false, on, off, yes, no", ignoreUpperLowerCase=true)
+    public final static String VALIDATE_XML = "org.apache.myfaces.VALIDATE_XML";
+    private final static boolean VALIDATE_XML_DEFAULT = false;
+    
+    /**
+     * Wrap content inside script with xml comment to prevent old browsers to display it. By default it is true. 
+     */
+    @JSFWebConfigParam(since="2.0.1", expectedValues="true, false, on, off, yes, no", defaultValue="false",
+            ignoreUpperLowerCase=true, group="render")
+    public final static String WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG = 
+        "org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG";
+    private final static boolean WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT = false;
+    
+    /**
+     * Enable/disable DebugPhaseListener feature, with provide useful information about ValueHolder 
+     * variables (submittedValue, localValue, value).
+     * Note evaluate those getters for each component could cause some unwanted side effects when 
+     * using "access" type scopes like on MyFaces CODI.
+     * This param only has effect when project stage is Development.     
+     */
+    @JSFWebConfigParam(since="2.0.8")
+    public final static String DEBUG_PHASE_LISTENER = "org.apache.myfaces.DEBUG_PHASE_LISTENER";
+    private final static boolean DEBUG_PHASE_LISTENER_DEFAULT = false;
+    
+    /**
+     * Change default getType() behavior for composite component EL resolver, from return null 
+     * (see JSF 2_0 spec section 5_6_2_2) to
+     * use the metadata information added by composite:attribute, ensuring components working with 
+     * chained EL expressions to find the
+     * right type when a getType() is called over the source EL expression.
+     * 
+     * To ensure strict compatibility with the spec set this param to true (by default is false, 
+     * so the change is enabled by default). 
+     */
+    @JSFWebConfigParam(since="2.0.10", expectedValues="true, false", defaultValue="false", group="EL")
+    public final static String STRICT_JSF_2_CC_EL_RESOLVER = 
+        "org.apache.myfaces.STRICT_JSF_2_CC_EL_RESOLVER";
+    private final static boolean STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT = false;
+    
+    /**
+     * Define the default content type that the default ResponseWriter generates, when no match can be derived from
+     * HTTP Accept Header.
+     */
+    @JSFWebConfigParam(since="2.0.11,2.1.5", expectedValues="text/html, application/xhtml+xml", 
+            defaultValue="text/html", group="render")
+    public final static String DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE = 
+        "org.apache.myfaces.DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE";
+    private final static String DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT = "text/html";
+
+    /**
+     * Enable or disable a cache used to "remember" the generated facelets unique ids and reduce 
+     * the impact on memory usage, only active if jakarta.faces.FACELETS_REFRESH_PERIOD is -1 (no refresh).
+     */
+    @JSFWebConfigParam(defaultValue = "true", since = "2.0.13, 2.1.7", expectedValues="true, false", 
+            group="viewhandler", tags="performance",
+            desc="Enable or disable a cache used to 'remember' the generated facelets unique ids " + 
+                 "and reduce the impact over memory usage.")
+    public static final String VIEW_UNIQUE_IDS_CACHE_ENABLED = 
+        "org.apache.myfaces.VIEW_UNIQUE_IDS_CACHE_ENABLED";
+    private static final boolean VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT = true;
+    
+    /**
+     * Set the size of the cache used to store strings generated using SectionUniqueIdCounter
+     * for component ids. If this is set to 0, no cache is used. By default is set to 200.
+     */
+    @JSFWebConfigParam(defaultValue = "100", since = "2.0.13, 2.1.7",
+            group="viewhandler", tags="performance")
+    public static final String COMPONENT_UNIQUE_IDS_CACHE_SIZE =
+        "org.apache.myfaces.COMPONENT_UNIQUE_IDS_CACHE_SIZE";
+    private static final int COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT = 200;
+
+    /**
+     * If this param is set to true, a check will be done in Restore View Phase to check
+     * if the viewId exists or not and if it does not exists, a 404 response will be thrown.
+     * 
+     * This is applicable in cases where all the views in the application are generated by a 
+     * ViewDeclarationLanguage implementation.
+     */
+    @JSFWebConfigParam(since = "2.1.13", defaultValue="false", expectedValues="true,false", 
+            group="viewhandler")
+    public static final String STRICT_JSF_2_VIEW_NOT_FOUND = 
+            "org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND";
+    private final static boolean STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT = false;
+
+    @JSFWebConfigParam(defaultValue = "false", since = "2.2.0", expectedValues="true, false", group="render",
+            tags="performance",
+            desc="Enable or disable an early flush which allows to send e.g. the HTML-Head to the client " +
+                    "while the rest gets rendered. It's a well known technique to reduce the time for loading a page.")
+    public static final String EARLY_FLUSH_ENABLED =
+        "org.apache.myfaces.EARLY_FLUSH_ENABLED";
+    private static final boolean EARLY_FLUSH_ENABLED_DEFAULT = false;
+    
+    /**
+     * This param makes components like c:set, ui:param and templating components like ui:decorate,
+     * ui:composition and ui:include to behave like the ones provided originally in facelets 1_1_x. 
+     * See MYFACES-3810 for details.
+     */
+    @JSFWebConfigParam(since = "2.2.0", defaultValue="false", expectedValues="true,false", 
+            group="viewhandler")
+    public static final String STRICT_JSF_2_FACELETS_COMPATIBILITY = 
+            "org.apache.myfaces.STRICT_JSF_2_FACELETS_COMPATIBILITY";
+    private final static boolean STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT = false;    
+    
+    /**
+     * This param makes h:form component to render the view state and other hidden fields
+     * at the beginning of the form. This also includes component resources with target="form",
+     * but it does not include legacy 1.1 myfaces specific hidden field adition.
+     */
+    @JSFWebConfigParam(since = "2.2.4", defaultValue = "false", expectedValues = "true,false",
+            group="render")
+    public static final String RENDER_FORM_VIEW_STATE_AT_BEGIN =
+            "org.apache.myfaces.RENDER_FORM_VIEW_STATE_AT_BEGIN";
+    private final static boolean RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT = false;
+    
+    /**
+     * Defines whether flash scope is disabled, preventing add the Flash cookie to the response. 
+     * 
+     * <p>This is useful for applications that does not require to use flash scope, and instead uses other scopes.</p>
+     */
+    @JSFWebConfigParam(defaultValue="false",since="2.0.5")
+    public static final String FLASH_SCOPE_DISABLED = "org.apache.myfaces.FLASH_SCOPE_DISABLED";
+    private static final boolean FLASH_SCOPE_DISABLED_DEFAULT = false;
+    
+    /**
+     * Defines the amount (default = 20) of the latest views are stored in session.
+     * 
+     * <p>Only applicable if state saving method is "server" (= default).
+     * </p>
+     * 
+     */
+    @JSFWebConfigParam(defaultValue="20",since="1.1", classType="java.lang.Integer", group="state", tags="performance")
+    public static final String NUMBER_OF_VIEWS_IN_SESSION = "org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION";
+    /**
+     * Default value for <code>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</code> context parameter.
+     */
+    public static final int NUMBER_OF_VIEWS_IN_SESSION_DEFAULT = 20;    
+
+    /**
+     * Indicates the amount of views (default is not active) that should be stored in session between sequential
+     * POST or POST-REDIRECT-GET if org.apache.myfaces.USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION is true.
+     * 
+     * <p>Only applicable if state saving method is "server" (= default). For example, if this param has value = 2 and 
+     * in your custom webapp there is a form that is clicked 3 times, only 2 views
+     * will be stored and the third one (the one stored the first time) will be
+     * removed from session, even if the view can
+     * store more sessions org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION.
+     * This feature becomes useful for multi-window applications.
+     * where without this feature a window can swallow all view slots so
+     * the other ones will throw ViewExpiredException.</p>
+     */
+    @JSFWebConfigParam(since="2.0.6", classType="java.lang.Integer", group="state", tags="performance", 
+            defaultValue = "4")
+    public static final String NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION
+            = "org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION";
+    public static final Integer NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT = 4;
+    
+    /**
+     * Indicate the max number of flash tokens stored into session. It is only active when 
+     * jakarta.faces.CLIENT_WINDOW_MODE is enabled and jakarta.faces.STATE_SAVING_METHOD is set
+     * to "server". Each flash token is associated to one client window id at
+     * the same time, so this param is related to the limit of active client windows per session. 
+     * By default is the same number as in 
+     * (org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION / 
+     * org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION) + 1 = 6.
+     */
+    @JSFWebConfigParam(since="2.2.6", group="state", tags="performance")
+    public static final String NUMBER_OF_FLASH_TOKENS_IN_SESSION = 
+            "org.apache.myfaces.NUMBER_OF_FLASH_TOKENS_IN_SESSION";
+
+    /**
+     * This parameter specifies whether or not the ImportHandler will be supported
+     */
+    @JSFWebConfigParam(since="2.2.9", defaultValue="false", expectedValues="true,false", group="EL")
+    public static final String SUPPORT_EL_3_IMPORT_HANDLER = "org.apache.myfaces.SUPPORT_EL_3_IMPORT_HANDLER";
+    private final static boolean SUPPORT_EL_3_IMPORT_HANDLER_DEFAULT = false;
+
+    /**
+     * This parameter specifies whether or not the Origin header app path should be checked 
+     */
+    @JSFWebConfigParam(since="2.3", defaultValue="false", expectedValues="true,false")
+    public static final String STRICT_JSF_2_ORIGIN_HEADER_APP_PATH = 
+            "org.apache.myfaces.STRICT_JSF_2_ORIGIN_HEADER_APP_PATH";
+    private final static boolean STRICT_JSF_2_ORIGIN_HEADER_APP_PATH_DEFAULT = false;
+
+    /**
+     * Allow slash in the library name of a Resource. 
+     */
+    @JSFWebConfigParam(since="2.1.6, 2.0.12", defaultValue="false", 
+            expectedValues="true, false", group="resources")
+    public static final String STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME = 
+            "org.apache.myfaces.STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME";
+    private static final boolean STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME_DEFAULT = false;
+    
+    /**
+     * Define the default buffer size that is used between Resource.getInputStream() and 
+     * httpServletResponse.getOutputStream() when rendering resources using the default
+     * ResourceHandler.
+     */
+    @JSFWebConfigParam(since="2.1.10, 2.0.16", defaultValue="2048", group="resources")
+    public static final String RESOURCE_BUFFER_SIZE = "org.apache.myfaces.RESOURCE_BUFFER_SIZE";
+    private static final int RESOURCE_BUFFER_SIZE_DEFAULT = 2048;
+    
+    /**
+     * Validate if the managed beans and navigations rules are correct.
+     * 
+     * <p>For example, it checks if the managed bean classes really exists, or if the 
+     * navigation rules points to existing view files.</p>
+     */
+    @JSFWebConfigParam(since="2.0", defaultValue="false", expectedValues="true, false")
+    public static final String VALIDATE = "org.apache.myfaces.VALIDATE";
+    
+    /**
+     * Defines if CDI should be used for annotation scanning to improve the startup performance.
+     */
+    @JSFWebConfigParam(since="2.2.9", tags = "performance", defaultValue = "false")
+    public static final String USE_CDI_FOR_ANNOTATION_SCANNING
+            = "org.apache.myfaces.annotation.USE_CDI_FOR_ANNOTATION_SCANNING";
+    private static final boolean USE_CDI_FOR_ANNOTATION_SCANNING_DEFAULT = false;
+    
+    
+    /**
+     * Controls the size of the cache used to check if a resource exists or not. 
+     * 
+     * <p>See org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED for details.</p>
+     */
+    @JSFWebConfigParam(defaultValue = "500", since = "2.0.2", group="resources", 
+            classType="java.lang.Integer", tags="performance")
+    public static final String RESOURCE_HANDLER_CACHE_SIZE = 
+        "org.apache.myfaces.RESOURCE_HANDLER_CACHE_SIZE";
+    private static final int RESOURCE_HANDLER_CACHE_SIZE_DEFAULT = 500;
+
+    /**
+     * Enable or disable the cache used to "remember" if a resource handled by 
+     * the default ResourceHandler exists or not.
+     * 
+     */
+    @JSFWebConfigParam(defaultValue = "true", since = "2.0.2", group="resources", 
+            expectedValues="true,false", tags="performance")
+    public static final String RESOURCE_HANDLER_CACHE_ENABLED = 
+        "org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED";
+    private static final boolean RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT = true;
+    
+    /**
+     * Servlet context init parameter which defines which packages to scan
+     * for beans, separated by commas.
+     */
+    @JSFWebConfigParam(since="2.0")
+    public static final String SCAN_PACKAGES = "org.apache.myfaces.annotation.SCAN_PACKAGES";
+ 
+    /**
+     * Indicates the port used for websocket connections.
+     */
+    @JSFWebConfigParam(since = "2.3")
+    public static final java.lang.String WEBSOCKET_ENDPOINT_PORT = "jakarta.faces.WEBSOCKET_ENDPOINT_PORT";
+
+    @JSFWebConfigParam(defaultValue = "300000")
+    public static final String WEBSOCKET_MAX_IDLE_TIMEOUT = "org.apache.myfaces.WEBSOCKET_MAX_IDLE_TIMEOUT";
+    private static final long WEBSOCKET_MAX_IDLE_TIMEOUT_DEFAULT = 300000L;
+    
+    /**
+     * Defines how to generate the csrf session token.
+     */
+    @JSFWebConfigParam(since="2.2.0", expectedValues="secureRandom, random", 
+            defaultValue="secureRandom", group="state")
+    public static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN
+            = "org.apache.myfaces.RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN";
+
+    public static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_SECURE_RANDOM = "secureRandom";
+    public static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_RANDOM = "random";
+    private static final String RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_DEFAULT = RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_SECURE_RANDOM;
+
+    /**
+     * Define the time in minutes where the view state is valid when
+     * client side state saving is used. By default it is set to 0
+     * (infinite).
+     */
+    @JSFWebConfigParam(since="2.1.9, 2.0.15", defaultValue="0", group="state")
+    public static final String CLIENT_VIEW_STATE_TIMEOUT = 
+            "org.apache.myfaces.CLIENT_VIEW_STATE_TIMEOUT";
+    private static final Long CLIENT_VIEW_STATE_TIMEOUT_DEFAULT = 0L;
+   
+    
+    /**
+     * Adds a random key to the generated view state session token.
+     */
+    @JSFWebConfigParam(since="2.1.9, 2.0.15", expectedValues="secureRandom, random", 
+            defaultValue="secureRandom", group="state")
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN
+            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN";
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM = "secureRandom";
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_RANDOM = "random";
+    private static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_DEFAULT = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM;
+    
+    /**
+     * Set the default length of the random key added to the view state session token.
+     * By default is 8. 
+     */
+    @JSFWebConfigParam(since="2.1.9, 2.0.15", defaultValue="8", group="state")
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH
+            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH";
+    private static final int RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH_DEFAULT = 8;
+    
+    /**
+     * Sets the random class to initialize the secure random id generator. 
+     * By default it uses java.security.SecureRandom
+     */
+    @JSFWebConfigParam(since="2.1.9, 2.0.15", group="state")
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_CLASS
+            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_CLASS";
+    
+    /**
+     * Sets the random provider to initialize the secure random id generator.
+     */
+    @JSFWebConfigParam(since="2.1.9, 2.0.15", group="state")
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_PROVIDER
+            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_PROVIDER";
+    
+    /**
+     * Sets the random algorithm to initialize the secure random id generator. 
+     * By default is SHA1PRNG
+     */
+    @JSFWebConfigParam(since="2.1.9, 2.0.15", defaultValue="SHA1PRNG", group="state")
+    public static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM
+            = "org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM";
+    private static final String RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM_DEFAULT = "SHA1PRNG";
+    
+    public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM = "secureRandom";
+    public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_RANDOM = "random";
+    
+    /**
+     * Defines how to generate the csrf session token.
+     */
+    @JSFWebConfigParam(since="2.2.0", expectedValues="secureRandom, random", defaultValue="secureRandom", group="state")
+    public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN
+            = "org.apache.myfaces.RANDOM_KEY_IN_CSRF_SESSION_TOKEN";
+    private static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_DEFAULT = RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM;
+    
+    /**
+     * Indicates that the serialized state will be compressed before it is written to the session. By default true.
+     * 
+     * Only applicable if state saving method is "server" (= default) and if
+     * <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code> is <code>true</code> (= default).
+     * If <code>true</code> (default) the serialized state will be compressed before it is written to the session.
+     * If <code>false</code> the state will not be compressed.
+     */
+    @JSFWebConfigParam(defaultValue="true",since="1.1", expectedValues="true,false", group="state", tags="performance")
+    public static final String COMPRESS_STATE_IN_SESSION = "org.apache.myfaces.COMPRESS_STATE_IN_SESSION";
+    private static final boolean COMPRESS_STATE_IN_SESSION_DEFAULT = true;
+    
+    /**
+     * Allow use flash scope to keep track of the views used in session and the previous ones,
+     * so server side state saving can delete old views even if POST-REDIRECT-GET pattern is used.
+     * 
+     * <p>
+     * Only applicable if state saving method is "server" (= default).
+     * The default value is false.</p>
+     */
+    @JSFWebConfigParam(since="2.0.6", defaultValue="false", expectedValues="true, false", group="state")
+    public static final String USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION
+            = "org.apache.myfaces.USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION";
+    private static final boolean USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT = false;
+    
+    /**
+     * Add autocomplete="off" to the view state hidden field. Enabled by default.
+     */
+    @JSFWebConfigParam(since="2.2.8, 2.1.18, 2.0.24", expectedValues="true, false", 
+           defaultValue="true", group="state")
+    public static final String AUTOCOMPLETE_OFF_VIEW_STATE = 
+            "org.apache.myfaces.AUTOCOMPLETE_OFF_VIEW_STATE";
+    private static final boolean AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT = true;
+    
+    /**
+     * Set the max time in miliseconds set on the "Expires" header for a resource rendered by 
+     * the default ResourceHandler.
+     * (default to one week in miliseconds or 604800000) 
+     */
+    @JSFWebConfigParam(since="2.0", defaultValue="604800000", group="resources", tags="performance")
+    public static final String RESOURCE_MAX_TIME_EXPIRES = "org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES";
+    private static final long RESOURCE_MAX_TIME_EXPIRES_DEFAULT = 604800000L;
+    
+
+    /**
+     * Indicate if the classes associated to components, converters, validators or behaviors
+     * should be loaded as soon as they are added to the current application instance or instead
+     * loaded in a lazy way.
+     */
+    @JSFWebConfigParam(defaultValue="true",since="2.0",tags="performance")
+    public static final String LAZY_LOAD_CONFIG_OBJECTS = "org.apache.myfaces.LAZY_LOAD_CONFIG_OBJECTS";
+    private static final boolean LAZY_LOAD_CONFIG_OBJECTS_DEFAULT = true;
+
+    
+    /**
+     * Define a custom comparator class used to sort the ELResolvers.
+     * 
+     * <p>This is useful when it is necessary to put an ELResolver on top of other resolvers. Note set
+     * this param override the default ordering described by JSF spec section 5. 
+     * </p>
+     */
+    @JSFWebConfigParam(since = "1.2.10, 2.0.2", group="EL",
+            desc = "The Class of an Comparator&lt;ELResolver&gt; implementation.")
+    public static final String EL_RESOLVER_COMPARATOR = "org.apache.myfaces.EL_RESOLVER_COMPARATOR";
+    
+    @JSFWebConfigParam(since = "2.1.0", group="EL",
+        desc="The Class of an java.util.function.Predicate&lt;ELResolver&gt; implementation."
+             + "If used and returns false for a ELResolver instance, such resolver will not be installed in "
+             + "ELResolvers chain. Use with caution - can break functionality defined in JSF specification "
+             + "'ELResolver Instances Provided by Faces'")
+    public static final String EL_RESOLVER_PREDICATE = "org.apache.myfaces.EL_RESOLVER_PREDICATE";
+
+    @JSFWebConfigParam(defaultValue = "500", since = "2.0.2", group="viewhandler", tags="performance", 
+            classType="java.lang.Integer",
+            desc="Controls the size of the viewId related caches: " + 
+                    "VIEWID_EXISTS_CACHE_ENABLED, VIEWID_PROTECTED_CACHE_ENABLED, VIEWID_DERIVE_CACHE_ENABLED")
+    public static final String VIEWID_CACHE_SIZE = "org.apache.myfaces.VIEWID_CACHE_SIZE";
+    private static final int VIEWID_CACHE_SIZE_DEFAULT = 500;
+
+    @JSFWebConfigParam(defaultValue = "true", since = "2.0.2", expectedValues="true, false", group="viewhandler", 
+            tags="performance",
+            desc="Enable or disable the cache used to 'remember' if a view exists or not and reduce the impact " +
+                 "of sucesive calls to ExternalContext.getResource().")
+    public static final String VIEWID_EXISTS_CACHE_ENABLED = "org.apache.myfaces.VIEWID_EXISTS_CACHE_ENABLED";
+    private static final boolean VIEWID_EXISTS_CACHE_ENABLED_DEFAULT = true;
+    
+
+    @JSFWebConfigParam(defaultValue = "true", since = "2.3-next", expectedValues="true, false", group="viewhandler", 
+            tags="performance",
+            desc="Enable or disable the cache used to 'remember' if a view is protected or not.")
+    public static final String VIEWID_PROTECTED_CACHE_ENABLED = "org.apache.myfaces.VIEWID_PROTECTED_CACHE_ENABLED";
+    private static final boolean VIEWID_PROTECTED_CACHE_ENABLED_DEFAULT = true;
+    
+    @JSFWebConfigParam(defaultValue = "true", since = "2.3-next", expectedValues="true, false", group="viewhandler", 
+            tags="performance",
+            desc="Enable or disable the cache used to 'remember' the derived viewId from the rawViewId.")
+    public static final String VIEWID_DERIVE_CACHE_ENABLED = "org.apache.myfaces.VIEWID_DERIVE_CACHE_ENABLED";
+    private static final boolean VIEWID_DERIVE_CACHE_ENABLED_DEFAULT = true;
+
+    /**
+     * Enforce f:validateBean to be called first before any JSF validator.
+     */
+    @JSFWebConfigParam(defaultValue="false", expectedValues="true, false", since = "2.2.10", group="validation")
+    public final static String BEAN_BEFORE_JSF_VALIDATION
+            = "org.apache.myfaces.validator.BEAN_BEFORE_JSF_VALIDATION";
+    private final static boolean BEAN_BEFORE_JSF_VALIDATION_DEFAULT = false;
+
+    /**
+     * comma delimited list of plugin classes which can be hooked into myfaces
+     */
+    @JSFWebConfigParam(since = "2.0")
+    public static final String FACES_INIT_PLUGINS = "org.apache.myfaces.FACES_INIT_PLUGINS";
+    
+    /**
+     * If the flag is true, the algoritm skip jar scanning for faces-config files to check if the current
+     * application requires FacesServlet to be added dynamically (servlet spec 3). This param can be set using 
+     * a system property with the same name too.
+     */
+    @JSFWebConfigParam(since="2.2.10", expectedValues = "true, false", defaultValue = "false", 
+            tags = "performance")
+    public static final String INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN = 
+            "org.apache.myfaces.INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN";
+    private static final boolean INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN_DEFAULT = false;
+    
+    /**
+     * If this param is set to true, the check for faces servlet mapping is not done 
+     */
+    @JSFWebConfigParam(since="2.0.3", defaultValue="false")
+    public static final String INITIALIZE_ALWAYS_STANDALONE = "org.apache.myfaces.INITIALIZE_ALWAYS_STANDALONE";
+
+    /**
+     * This parameter specifies the ExpressionFactory implementation to use.
+     */
+    @JSFWebConfigParam(since="1.2.7", group="EL")
+    public static final String EXPRESSION_FACTORY = "org.apache.myfaces.EXPRESSION_FACTORY";
+   
+    /**
+     * Define how duplicate ids are checked when ProjectStage is Production, by default (auto) it only check ids of
+     * components that does not encapsulate markup (like facelets UILeaf).
+     *  
+     * <ul>
+     * <li>true: check all ids, including ids for components that are transient and encapsulate markup.</li>
+     * <li>auto: (default) check ids of components that does not encapsulate markup (like facelets UILeaf). 
+     * Note ids of UILeaf instances are generated by facelets vdl, start with "j_id", are never rendered 
+     * into the response and UILeaf instances are never used as a target for listeners, so in practice 
+     * there is no need to check such ids. This reduce the overhead associated with generate client ids.</li>
+     * <li>false: do not do any check when ProjectStage is Production</li>
+     * </ul>
+     * <p> According to specification, identifiers must be unique within the scope of the nearest ancestor to 
+     * the component that is a naming container.</p>
+     */
+    @JSFWebConfigParam(since="2.0.12, 2.1.6", defaultValue="auto", expectedValues="true, auto, false",
+                       group="state", tags="performance")
+    public static final String CHECK_ID_PRODUCTION_MODE
+            = "org.apache.myfaces.CHECK_ID_PRODUCTION_MODE";
+    private static final String CHECK_ID_PRODUCTION_MODE_DEFAULT = "auto";
+    public static final String CHECK_ID_PRODUCTION_MODE_TRUE = "true";
+    public static final String CHECK_ID_PRODUCTION_MODE_AUTO = "auto";
+    
+    @JSFWebConfigParam(since = "2.1", defaultValue = "false", expectedValues = "true, false", tags = "performance")
+    public final static String MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW
+            = "org.apache.myfaces.MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW";
+    private static final boolean MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW_DEFAULT = false;
+  
+    /**
+     * Class implementing ResourceResolver interface used to locate facelet resources. 
+     */
+    @JSFWebConfigParam(since = "2.0", alias = "facelets.RESOURCE_RESOLVER")
+    public final static String FACELETS_RESOURCE_RESOLVER = "jakarta.faces.FACELETS_RESOURCE_RESOLVER";
+    
+    /**
+     * Indicates if expressions generated by facelets should be cached or not.
+     * Default is noCache. There there are four modes:
+     * 
+     * <ul>
+     * <li>alwaysRecompile (since 2.1.12): Only does not cache when the expression contains
+     * a variable resolved using VariableMapper</li>
+     * <li>always: Only does not cache when expressions are inside user tags or the
+     * expression contains a variable resolved using VariableMapper</li>
+     * <li>allowCset: Like always, but does not allow cache when ui:param
+     * was used on the current template context</li>
+     * <li>strict: Like allowCset, but does not allow cache when c:set with
+     * var and value properties only is used on the current page context</li>
+     * <li>noCache: All expression are created each time the view is built</li>
+     * </ul>
+     * 
+     */
+    @JSFWebConfigParam(since="2.0.8", defaultValue="noCache",
+                       expectedValues="noCache, strict, allowCset, always, alwaysRecompile",
+                       group="EL", tags="performance")
+    public static final String CACHE_EL_EXPRESSIONS = "org.apache.myfaces.CACHE_EL_EXPRESSIONS";
+    private static final String CACHE_EL_EXPRESSIONS_DEFAULT = ELExpressionCacheMode.alwaysRecompile.name();
+    
+    /**
+     * Wrap exception caused by calls to EL expressions, so information like
+     * the location, expression string and tag name can be retrieved by
+     * the ExceptionHandler implementation and used to output meaningful information about itself.
+     * 
+     * <p>Note in some cases this will wrap the original jakarta.el.ELException,
+     * so the information will not be on the stack trace unless ExceptionHandler
+     * retrieve checking if the exception implements ContextAware interface and calling getWrapped() method.
+     * </p>
+     * 
+     */
+    @JSFWebConfigParam(since="2.0.9, 2.1.3" , defaultValue="true", expectedValues="true, false")
+    public static final String WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE
+            = "org.apache.myfaces.WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE";
+    private static final boolean WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE_DEFAULT = true;
+    
+    /**
+     * Defines if the last-modified should be cached of the resources when the ProjectStage is Production.
+     * If the cache is disabled, each last-modified request will read the last-modified from the file.
+     */
+    @JSFWebConfigParam(since="2.3-next" , defaultValue="true", expectedValues="true, false")
+    public static final String RESOURCE_CACHE_LAST_MODIFIED
+            = "org.apache.myfaces.RESOURCE_CACHE_LAST_MODIFIED";
+    private static final boolean RESOURCE_CACHE_LAST_MODIFIED_DEFAULT = true;
+
+    /**
+     * Indicate if log all web config params should be done before initialize the webapp. 
+     * <p>
+     * If is set in "auto" mode, web config params are only logged on "Development" and "Production" project stages.
+     * </p> 
+     */
+    @JSFWebConfigParam(expectedValues="true, auto, false", defaultValue="auto")
+    public static final String LOG_WEB_CONTEXT_PARAMS = "org.apache.myfaces.LOG_WEB_CONTEXT_PARAMS";
+    private static final String LOG_WEB_CONTEXT_PARAMS_DEFAULT = "auto";
+    
+    /**
+     * This parameter enables automatic extensionless mapping for all JSF views.
+     */
+    @JSFWebConfigParam(since="2.3", expectedValues = "true, false", defaultValue = "false")
+    public static final String AUTOMATIC_EXTENSIONLESS_MAPPING = 
+            "org.apache.myfaces.AUTOMATIC_EXTENSIONLESS_MAPPING";
+    public static final boolean AUTOMATIC_EXTENSIONLESS_MAPPING_DEFAULT = false;
+    
+    /**
+     * Indicate the class implementing FacesInitializer interface that will
+     * be used to setup MyFaces Core contexts.
+     * <p>This is used when some custom task must be done specifically when
+     * a myfaces web context is initialized or destroyed, or when MyFaces should
+     * be initialized in some custom environment. 
+     * </p>
+     */
+    @JSFWebConfigParam(since = "2.0.1", desc = "Class name of a custom FacesInitializer implementation.")
+    public static final String FACES_INITIALIZER = "org.apache.myfaces.FACES_INITIALIZER";
+    
+
+    /**
+     * Define the class implementing InjectionProvider interface to handle dependendy injection,
+     * PostConstruct and PreDestroy callbacks.
+     * 
+     * <p>This also can be configured using a SPI entry (/META-INF/services/...).</p>
+     */
+    @JSFWebConfigParam(name="org.apache.myfaces.spi.InjectionProvider", since="2.2")
+    public static final String INJECTION_PROVIDER = InjectionProvider.class.getName();
+    
+    @JSFWebConfigParam(name="org.apache.myfaces.WEBSOCKET_MAX_CONNECTIONS", since="2.3")
+    public static final String WEBSOCKET_MAX_CONNECTIONS = "org.apache.myfaces.WEBSOCKET_MAX_CONNECTIONS";
+    public static final Integer WEBSOCKET_MAX_CONNECTIONS_DEFAULT = 5000;
+    
+    
+    /**
+     * Defines if the clientbehavior scripts are passed as string or function to the faces.util.chain.
+     * "As string" is actually the default behavior of both MyFaces (until 2.3-next) and Mojarra.
+     * "As function" is quite usefull for CSP as no string needs to be evaluated as function.
+     * 
+     * Our faces.util.chain supports both of course.
+     */
+    @JSFWebConfigParam(name="org.apache.myfaces.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING", since="2.3-next", defaultValue = "false")
+    public static final String RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING = "org.apache.myfaces.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING";
+    public static final boolean RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING_DEFAULT = false;
+    
+    /**
+     * Defines if a session should be created (if one does not exist) before response rendering.
+     * When this parameter is set to true, a session will be created even when client side state 
+     * saving or stateless views are used, which can lead to unintended resource consumption.
+     * When this parameter is set to false, a session will only be created before response 
+     * rendering if a view is not transient and server side state saving is in use.     
+     */
+    @JSFWebConfigParam(since="2.3.6", defaultValue="false", expectedValues="true,false")
+    public static final String ALWAYS_FORCE_SESSION_CREATION = 
+            "org.apache.myfaces.ALWAYS_FORCE_SESSION_CREATION";
+    protected final static boolean ALWAYS_FORCE_SESSION_CREATION_DEFAULT = false;
+    
+    /**
+     * Defines the {@link java.util.ResourceBundle.Control} to use for all
+     * {@link java.util.ResourceBundle#getBundle(java.lang.String)} calls.
+     */
+    @JSFWebConfigParam(since="2.3-next")
+    public static final String RESOURCE_BUNDLE_CONTROL = 
+            "org.apache.myfaces.RESOURCE_BUNDLE_CONTROL";
+    
+    // we need it, applicationImpl not ready probably
+    private ProjectStage projectStage = ProjectStage.Production;
+    private boolean strictJsf2AllowSlashLibraryName;
+    private long configRefreshPeriod = CONFIG_REFRESH_PERIOD_DEFAULT;
+    private boolean renderViewStateId = RENDER_VIEWSTATE_ID_DEFAULT;
+    private boolean strictXhtmlLinks = STRICT_XHTML_LINKS_DEFAULT;
+    private boolean renderClearJavascriptOnButton = RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT;
+    private String delegateFacesServlet;
+    private boolean refreshTransientBuildOnPSS = true;
+    private boolean refreshTransientBuildOnPSSAuto = true;
+    private boolean refreshTransientBuildOnPSSPreserveState = REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT;
+    private boolean validateXML = VALIDATE_XML_DEFAULT;
+    private boolean wrapScriptContentWithXmlCommentTag = WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT;
+    private boolean debugPhaseListenerEnabled = DEBUG_PHASE_LISTENER_DEFAULT;
+    private boolean strictJsf2CCELResolver = STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT;
+    private String defaultResponseWriterContentTypeMode = DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT;
+    private boolean viewUniqueIdsCacheEnabled = VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT;
+    private int componentUniqueIdsCacheSize = COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT;
+    private boolean strictJsf2ViewNotFound = STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT;
+    private boolean earlyFlushEnabled = EARLY_FLUSH_ENABLED_DEFAULT;
+    private boolean strictJsf2FaceletsCompatibility = STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT;
+    private boolean renderFormViewStateAtBegin = RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT;
+    private boolean flashScopeDisabled = FLASH_SCOPE_DISABLED_DEFAULT;
+    private Integer numberOfViewsInSession = NUMBER_OF_VIEWS_IN_SESSION_DEFAULT;
+    private Integer numberOfSequentialViewsInSession = NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_DEFAULT;
+    private Integer numberOfFlashTokensInSession;
+    private Integer numberOfClientWindows;
+    private boolean supportEL3ImportHandler = SUPPORT_EL_3_IMPORT_HANDLER_DEFAULT;
+    private boolean strictJsf2OriginHeaderAppPath = STRICT_JSF_2_ORIGIN_HEADER_APP_PATH_DEFAULT;
+    private int resourceBufferSize = RESOURCE_BUFFER_SIZE_DEFAULT;
+    private boolean useCdiForAnnotationScanning = USE_CDI_FOR_ANNOTATION_SCANNING_DEFAULT;
+    private boolean resourceHandlerCacheEnabled = RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT;
+    private int resourceHandlerCacheSize = RESOURCE_HANDLER_CACHE_SIZE_DEFAULT;
+    private String scanPackages;
+    private long websocketMaxIdleTimeout = WEBSOCKET_MAX_IDLE_TIMEOUT_DEFAULT;
+    private Integer websocketEndpointPort;
+    private String randomKeyInWebsocketSessionToken = RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN_DEFAULT;
+    private long clientViewStateTimeout = CLIENT_VIEW_STATE_TIMEOUT_DEFAULT;
+    private String randomKeyInViewStateSessionToken = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_DEFAULT;
+    private int randomKeyInViewStateSessionTokenLength = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_LENGTH_DEFAULT;
+    private String randomKeyInViewStateSessionTokenSecureRandomClass;
+    private String randomKeyInViewStateSessionTokenSecureRandomProvider;
+    private String randomKeyInViewStateSessionTokenSecureRandomAlgorithm
+            = RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM_ALGORITHM_DEFAULT;
+    private String randomKeyInCsrfSessionToken = RANDOM_KEY_IN_CSRF_SESSION_TOKEN_DEFAULT;
+    private boolean serializeStateInSession = false;
+    private boolean compressStateInSession = COMPRESS_STATE_IN_SESSION_DEFAULT;
+    private boolean useFlashScopePurgeViewsInSession = USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT;
+    private boolean autocompleteOffViewState = AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT;
+    private long resourceMaxTimeExpires = RESOURCE_MAX_TIME_EXPIRES_DEFAULT;
+    private boolean lazyLoadConfigObjects = LAZY_LOAD_CONFIG_OBJECTS_DEFAULT;
+    private String elResolverComparator;
+    private String elResolverPredicate;
+    private boolean viewIdExistsCacheEnabled = VIEWID_EXISTS_CACHE_ENABLED_DEFAULT;
+    private boolean viewIdProtectedCacheEnabled = VIEWID_PROTECTED_CACHE_ENABLED_DEFAULT;
+    private boolean viewIdDeriveCacheEnabled = VIEWID_DERIVE_CACHE_ENABLED_DEFAULT;
+    private int viewIdCacheSize = VIEWID_CACHE_SIZE_DEFAULT;
+    private boolean beanBeforeJsfValidation = BEAN_BEFORE_JSF_VALIDATION_DEFAULT;
+    private String facesInitPlugins;
+    private boolean initializeSkipJarFacesConfigScan = INITIALIZE_SKIP_JAR_FACES_CONFIG_SCAN_DEFAULT;
+    private String expressionFactory;
+    private String checkIdProductionMode = CHECK_ID_PRODUCTION_MODE_DEFAULT;
+    private boolean partialStateSaving = true;
+    private String[] fullStateSavingViewIds;
+    private int faceletsBufferSize = 1024;
+    private boolean markInitialStateWhenApplyBuildView = MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW_DEFAULT;
+    private String resourceResolver;
+    private String[] viewSuffix = new String[] { ViewHandler.DEFAULT_SUFFIX };
+    private String[] faceletsViewMappings = new String[] {};
+    private String faceletsViewSuffix = ViewHandler.DEFAULT_FACELETS_SUFFIX;
+    private ELExpressionCacheMode elExpressionCacheMode;
+    private boolean wrapTagExceptionsAsContextAware = WRAP_TAG_EXCEPTIONS_AS_CONTEXT_AWARE_DEFAULT;
+    private boolean resourceCacheLastModified = RESOURCE_CACHE_LAST_MODIFIED_DEFAULT;
+    private boolean logWebContextParams = false;
+    private int websocketMaxConnections = WEBSOCKET_MAX_CONNECTIONS_DEFAULT;
+    private boolean renderClientBehaviorScriptsAsString = RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING_DEFAULT;
+    private boolean alwaysForceSessionCreation = ALWAYS_FORCE_SESSION_CREATION_DEFAULT;
+    private ResourceBundle.Control resourceBundleControl;
+    private boolean automaticExtensionlessMapping = AUTOMATIC_EXTENSIONLESS_MAPPING_DEFAULT;
+    
+    private static final boolean MYFACES_IMPL_AVAILABLE;
+    private static final boolean RI_IMPL_AVAILABLE;
+
+    static
+    {
+        boolean myfacesImplAvailable;
+        try
+        {
+            ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
+            myfacesImplAvailable = true;
+        }
+        catch (ClassNotFoundException e)
+        {
+            myfacesImplAvailable = false;
+        }
+        MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
... 33094 lines suppressed ...