You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/11/26 21:32:42 UTC

svn commit: r1039554 [2/4] - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/application/ main/java/org/apache/myfaces/config/ main/java/org/apache/myfaces/config/annotation/ main/java/org/apache/myfaces/config/element/ main/java/org/apac...

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=1039554&r1=1039553&r2=1039554&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Fri Nov 26 20:32:39 2010
@@ -18,11 +18,8 @@
  */
 package org.apache.myfaces.config;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -31,16 +28,11 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -77,7 +69,6 @@ import javax.faces.validator.BeanValidat
 import javax.faces.webapp.FacesServlet;
 
 import org.apache.myfaces.application.ApplicationFactoryImpl;
-import org.apache.myfaces.application.ApplicationImpl;
 import org.apache.myfaces.application.BackwardsCompatibleNavigationHandlerWrapper;
 import org.apache.myfaces.component.visit.VisitContextFactoryImpl;
 import org.apache.myfaces.config.annotation.AnnotationConfigurator;
@@ -85,23 +76,16 @@ import org.apache.myfaces.config.annotat
 import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
 import org.apache.myfaces.config.element.Behavior;
 import org.apache.myfaces.config.element.ClientBehaviorRenderer;
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.config.element.FacesConfigData;
 import org.apache.myfaces.config.element.ManagedBean;
+import org.apache.myfaces.config.element.NamedEvent;
 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.digester.DigesterFacesConfigDispenserImpl;
 import org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl;
-import org.apache.myfaces.config.impl.digester.elements.ConfigOthersSlot;
-import org.apache.myfaces.config.impl.digester.elements.FacesConfig;
-import org.apache.myfaces.config.impl.digester.elements.FacesConfigNameSlot;
-import org.apache.myfaces.config.impl.digester.elements.Factory;
-import org.apache.myfaces.config.impl.digester.elements.NamedEvent;
-import org.apache.myfaces.config.impl.digester.elements.OrderSlot;
-import org.apache.myfaces.config.impl.digester.elements.Ordering;
-import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
-import org.apache.myfaces.config.impl.digester.elements.SystemEventListener;
-import org.apache.myfaces.config.util.CyclicDependencyException;
-import org.apache.myfaces.config.util.DirectedAcyclicGraphVerifier;
-import org.apache.myfaces.config.util.Vertex;
 import org.apache.myfaces.context.ExceptionHandlerFactoryImpl;
 import org.apache.myfaces.context.ExternalContextFactoryImpl;
 import org.apache.myfaces.context.FacesContextFactoryImpl;
@@ -117,15 +101,14 @@ import org.apache.myfaces.shared_impl.ut
 import org.apache.myfaces.shared_impl.util.StateUtils;
 import org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory;
 import org.apache.myfaces.shared_impl.util.serial.SerialFactory;
-import org.apache.myfaces.spi.FacesConfigResourceProvider;
-import org.apache.myfaces.spi.FacesConfigResourceProviderFactory;
+import org.apache.myfaces.spi.FacesConfigurationProvider;
+import org.apache.myfaces.spi.FacesConfigurationProviderFactory;
 import org.apache.myfaces.util.ContainerUtils;
 import org.apache.myfaces.util.ExternalSpecifications;
 import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl;
 import org.apache.myfaces.view.facelets.tag.jsf.TagHandlerDelegateFactoryImpl;
 import org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener;
 import org.apache.myfaces.webapp.ManagedBeanDestroyerListener;
-import org.xml.sax.SAXException;
 
 /**
  * Configures everything for a given context. The FacesConfigurator is independent of the concrete implementations that
@@ -140,13 +123,6 @@ public class FacesConfigurator
     //private static final Log log = LogFactory.getLog(FacesConfigurator.class);
     private static final Logger log = Logger.getLogger(FacesConfigurator.class.getName());
 
-    private static final String STANDARD_FACES_CONFIG_RESOURCE = "META-INF/standard-faces-config.xml";
-    //private static final String FACES_CONFIG_RESOURCE = "META-INF/faces-config.xml";
-    //private static final String META_INF_PREFIX = "META-INF/";
-    //private static final String FACES_CONFIG_SUFFIX = ".faces-config.xml";
-
-    private static final String META_INF_SERVICES_RESOURCE_PREFIX = "META-INF/services/";
-
     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();
@@ -160,23 +136,9 @@ public class FacesConfigurator
     private static final String DEFAULT_TAG_HANDLER_DELEGATE_FACTORY = TagHandlerDelegateFactoryImpl.class.getName();
     private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";
 
-    private static final Set<String> FACTORY_NAMES = new HashSet<String>();
-    {
-        FACTORY_NAMES.add(FactoryFinder.APPLICATION_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.EXCEPTION_HANDLER_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.EXTERNAL_CONTEXT_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.FACES_CONTEXT_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.LIFECYCLE_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.RENDER_KIT_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.VISIT_CONTEXT_FACTORY);
-        FACTORY_NAMES.add(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY);
-    }
-
     private final ExternalContext _externalContext;
     private FacesConfigUnmarshaller<? extends FacesConfig> _unmarshaller;
-    private FacesConfigDispenser<FacesConfig> _dispenser;
+    private FacesConfigData _dispenser;
     private AnnotationConfigurator _annotationConfigurator;
 
     private RuntimeConfig _runtimeConfig;
@@ -272,7 +234,7 @@ public class FacesConfigurator
      * @param dispenser
      *            the dispenser to set
      */
-    public void setDispenser(FacesConfigDispenser<FacesConfig> dispenser)
+    public void setDispenser(FacesConfigData dispenser)
     {
         _dispenser = dispenser;
     }
@@ -280,7 +242,7 @@ public class FacesConfigurator
     /**
      * @return the dispenser
      */
-    protected FacesConfigDispenser<FacesConfig> getDispenser()
+    protected FacesConfigData getDispenser()
     {
         if (_dispenser == null)
         {
@@ -299,7 +261,7 @@ public class FacesConfigurator
     {
         if (_annotationConfigurator == null)
         {
-            _annotationConfigurator = new AnnotationConfigurator(_externalContext);
+            _annotationConfigurator = new AnnotationConfigurator();
         }
         return _annotationConfigurator;
     }
@@ -483,49 +445,10 @@ public class FacesConfigurator
 
     public void configure() throws FacesException
     {
-        boolean metadataComplete = false;
-        try
-        {
-            //1. Feed standard-faces-config.xml first.
-            feedStandardConfig();
-            //2. Feed META-INF/services factories
-            feedMetaInfServicesFactories();
-            //3. Retrieve webAppFacesConfig (we need check for metadataComplete and config ordering algorithm)
-            FacesConfig webAppFacesConfig = getWebAppConfig();
-
-            //read metadata-complete attribute on WEB-INF/faces-config.xml
-            if(webAppFacesConfig != null)
-            {
-                metadataComplete = Boolean.valueOf(webAppFacesConfig.getMetadataComplete());    
-            }
-            else
-            {
-                metadataComplete = false;   //assume false if no faces-config.xml was found
-                                            //metadata-complete can only be specified in faces-config.xml per the JSF 2.0 schema 
-            }
-            feedAnnotationConfig(metadataComplete);
-            
-            //3. Retrieve all appConfigResources
-            List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
-            addClassloaderConfigurations(appConfigResources);
-            addContextSpecifiedConfig(appConfigResources);
-            
-            //5. Ordering of Artifacts (see section 11.4.7 of the spec)
-            orderAndFeedArtifacts(appConfigResources,webAppFacesConfig); 
-
-            if (log.isLoggable(Level.INFO))
-            {
-                logMetaInf();
-            }
-        }
-        catch (IOException e)
-        {
-            throw new FacesException(e);
-        }
-        catch (SAXException e)
-        {
-            throw new FacesException(e);
-        }
+        FacesConfigurationProvider provider = FacesConfigurationProviderFactory.getFacesConfigurationProviderFactory(_externalContext).
+                            getFacesConfigurationProvider(_externalContext);
+        
+        setDispenser(provider.getFacesConfigData(_externalContext)); 
 
         configureFactories();
         configureApplication();
@@ -546,38 +469,6 @@ public class FacesConfigurator
         lastUpdate = System.currentTimeMillis();
     }
 
-    private void feedStandardConfig() throws IOException, SAXException
-    {
-        if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
-        {
-            URL url = ClassUtils.getContextClassLoader().getResource(STANDARD_FACES_CONFIG_RESOURCE);
-            if (url == null)
-            {
-                url = this.getClass().getResource(STANDARD_FACES_CONFIG_RESOURCE);
-            }
-            if (url != null)
-            {
-                validateFacesConfig(url);
-            }
-        }
-        InputStream stream = ClassUtils.getResourceAsStream(STANDARD_FACES_CONFIG_RESOURCE);
-        if (stream == null)
-            throw new FacesException("Standard faces config " + STANDARD_FACES_CONFIG_RESOURCE + " not found");
-        if (log.isLoggable(Level.INFO))
-            log.info("Reading standard config " + STANDARD_FACES_CONFIG_RESOURCE);
-        getDispenser().feed(getUnmarshaller().getFacesConfig(stream, STANDARD_FACES_CONFIG_RESOURCE));
-        stream.close();
-    }
-    
-    private void feedAnnotationConfig(boolean metadataComplete)
-    {
-        FacesConfig annotationConfig = getAnnotationConfigurator().createFacesConfig(metadataComplete);
-        if (annotationConfig != null)
-        {
-            getDispenser().feed(annotationConfig);
-        }
-    }
-
     /**
      * This method performs part of the factory search outlined in section 10.2.6.1.
      */
@@ -671,217 +562,6 @@ public class FacesConfigurator
         }
     }
 
-    /**
-     * This method performs part of the factory search outlined in section 10.2.6.1.
-     */
-    protected void feedMetaInfServicesFactories()
-    {
-        try
-        {
-            FacesConfig facesConfig = new FacesConfig();
-            Factory factory = new Factory();
-            facesConfig.addFactory(factory);
-            for (String factoryName : FACTORY_NAMES)
-            {
-                Iterator<URL> it = ClassUtils.getResources(META_INF_SERVICES_RESOURCE_PREFIX + factoryName, this);
-                while (it.hasNext())
-                {
-                    URL url = it.next();
-                    InputStream stream = openStreamWithoutCache(url);
-                    InputStreamReader isr = new InputStreamReader(stream);
-                    BufferedReader br = new BufferedReader(isr);
-                    String className;
-                    try
-                    {
-                        className = br.readLine();
-                    }
-                    catch (IOException e)
-                    {
-                        throw new FacesException("Unable to read class name from file " + url.toExternalForm(), e);
-                    }
-                    finally
-                    {
-                        if (br != null)
-                        {
-                            br.close();
-                        }
-                        if (isr != null)
-                        {
-                            isr.close();
-                        }
-                        if (stream != null)
-                        {
-                            stream.close();
-                        }
-                    }
-
-
-                    if (log.isLoggable(Level.INFO))
-                    {
-                        log.info("Found " + factoryName + " factory implementation: " + className);
-                    }
-
-                    if (factoryName.equals(FactoryFinder.APPLICATION_FACTORY))
-                    {
-                        factory.addApplicationFactory(className);
-                    } else if (factoryName.equals(FactoryFinder.EXTERNAL_CONTEXT_FACTORY))
-                    {
-                        factory.addExternalContextFactory(className);
-                    } else if (factoryName.equals(FactoryFinder.FACES_CONTEXT_FACTORY))
-                    {
-                        factory.addFacesContextFactory(className);
-                    } else if (factoryName.equals(FactoryFinder.LIFECYCLE_FACTORY))
-                    {
-                        factory.addLifecycleFactory(className);
-                    } else if (factoryName.equals(FactoryFinder.RENDER_KIT_FACTORY))
-                    {
-                        factory.addRenderkitFactory(className);
-                    } else if (factoryName.equals(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY))
-                    {
-                        factory.addPartialViewContextFactory(className);
-                    } else if(factoryName.equals(FactoryFinder.VISIT_CONTEXT_FACTORY)) 
-                    {
-                        factory.addVisitContextFactory(className);
-                    } else
-                    {
-                        throw new IllegalStateException("Unexpected factory name " + factoryName);
-                    }
-                }
-            }
-            getDispenser().feed(facesConfig);
-        }
-        catch (Throwable e)
-        {
-            throw new FacesException(e);
-        }
-    }
-
-    private InputStream openStreamWithoutCache(URL url) throws IOException
-    {
-        URLConnection connection = url.openConnection();
-        connection.setUseCaches(false);
-        return connection.getInputStream();
-    }
-
-    /**
-     * This method fixes MYFACES-208
-     */
-    private void addClassloaderConfigurations(List<FacesConfig> appConfigResources)
-    {
-        try
-        {
-            FacesConfigResourceProvider provider = FacesConfigResourceProviderFactory.
-                getFacesConfigResourceProviderFactory(_externalContext).createFacesConfigResourceProvider(_externalContext);
-            
-            Collection<URL> facesConfigs = provider.getMetaInfConfigurationResources(_externalContext);
-            
-            for (URL url : facesConfigs)
-            {
-                if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
-                {
-                    validateFacesConfig(url);
-                }
-                InputStream stream = null;
-                try
-                {
-                    stream = openStreamWithoutCache(url);
-                    if (log.isLoggable(Level.INFO))
-                    {
-                        log.info("Reading config : " + url.toExternalForm());
-                    }
-                    appConfigResources.add(getUnmarshaller().getFacesConfig(stream, url.toExternalForm()));
-                    //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, entry.getKey()));
-                }
-                finally
-                {
-                    if (stream != null)
-                    {
-                        stream.close();
-                    }
-                }
-            }
-            
-            /*
-            Map<String, URL> facesConfigs = new TreeMap<String, URL>();
-            Iterator<URL> it = ClassUtils.getResources(FACES_CONFIG_RESOURCE, this);
-            while (it.hasNext())
-            {
-                URL url = it.next();
-                String systemId = url.toExternalForm();
-                facesConfigs.put(systemId, url);
-            }
-            
-            //Scan files inside META-INF ending with .faces-config.xml
-            //TODO: specify classpath for make easier configuration security java 2
-            URL[] urls = Classpath.search(META_INF_PREFIX, FACES_CONFIG_SUFFIX);
-            for (int i = 0; i < urls.length; i++)
-            {
-                String systemId = urls[i].toExternalForm();
-                facesConfigs.put(systemId, urls[i]);
-            }
-
-            for (Map.Entry<String, URL> entry : facesConfigs.entrySet())
-            {
-                if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
-                {
-                    validateFacesConfig(entry.getValue());
-                }
-                InputStream stream = null;
-                try
-                {
-                    stream = openStreamWithoutCache(entry.getValue());
-                    if (log.isLoggable(Level.INFO))
-                    {
-                        log.info("Reading config : " + entry.getKey());
-                    }
-                    appConfigResources.add(getUnmarshaller().getFacesConfig(stream, entry.getKey()));
-                    //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, entry.getKey()));
-                }
-                finally
-                {
-                    if (stream != null)
-                    {
-                        stream.close();
-                    }
-                }
-            }
-            */
-        }
-        catch (Throwable e)
-        {
-            throw new FacesException(e);
-        }
-    }
-
-    private void addContextSpecifiedConfig(List<FacesConfig> appConfigResources) throws IOException, SAXException
-    {
-        for (String systemId : getConfigFilesList())
-        {
-            if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
-            {
-                URL url = _externalContext.getResource(systemId);
-                if (url != null)
-                {
-                    validateFacesConfig(url);
-                }
-            }            
-            InputStream stream = _externalContext.getResourceAsStream(systemId);
-            if (stream == null)
-            {
-                log.severe("Faces config resource " + systemId + " not found");
-                continue;
-            }
-
-            if (log.isLoggable(Level.INFO))
-            {
-                log.info("Reading config " + systemId);
-            }
-            appConfigResources.add(getUnmarshaller().getFacesConfig(stream, systemId));
-            //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId));
-            stream.close();
-        }
-    }
-
     private List<String> getConfigFilesList() {
         String configFiles = _externalContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
         List<String> configFilesList = new ArrayList<String>();
@@ -910,983 +590,10 @@ public class FacesConfigurator
         }
         return configFilesList;
     }
-
-    private FacesConfig getWebAppConfig() throws IOException, SAXException
-    {
-        FacesConfig webAppConfig = null;
-        // web application config
-        if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
-        {
-            URL url = _externalContext.getResource(DEFAULT_FACES_CONFIG);
-            if (url != null)
-            {
-                validateFacesConfig(url);
-            }
-        }
-        InputStream stream = _externalContext.getResourceAsStream(DEFAULT_FACES_CONFIG);
-        if (stream != null)
-        {
-            if (log.isLoggable(Level.INFO))
-                log.info("Reading config /WEB-INF/faces-config.xml");
-            webAppConfig = getUnmarshaller().getFacesConfig(stream, DEFAULT_FACES_CONFIG);
-            //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, DEFAULT_FACES_CONFIG));
-            stream.close();
-        }
-        return webAppConfig;
-    }
-    
-    private void validateFacesConfig(URL url) throws IOException, SAXException
-    {
-        String version = ConfigFilesXmlValidationUtils.getFacesConfigVersion(url);
-        if ("1.2".equals(version) || "2.0".equals(version))
-        {
-            ConfigFilesXmlValidationUtils.validateFacesConfigFile(url, _externalContext, version);                
-        }
-    }
     
-    protected void orderAndFeedArtifacts(List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
-        throws FacesException
-    {
-        if (webAppConfig != null && webAppConfig.getAbsoluteOrdering() != null)
-        {
-            if (webAppConfig.getOrdering() != null)
-            {
-                if (log.isLoggable(Level.WARNING))
-                {
-                    log.warning("<ordering> element found in application faces config. " +
-                            "This description will be ignored and the actions described " +
-                            "in <absolute-ordering> element will be taken into account instead.");
-                }                
-            }
-            //Absolute ordering
-            
-            //1. Scan all appConfigResources and create a list
-            //containing all resources not mentioned directly, preserving the
-            //order founded
-            List<FacesConfig> othersResources = new ArrayList<FacesConfig>();
-            List<OrderSlot> slots = webAppConfig.getAbsoluteOrdering().getOrderList();
-            for (FacesConfig resource : appConfigResources)
-            {
-                // First condition: if faces-config.xml does not have name it is 1) pre-JSF-2.0 or 2) has no <name> element,
-                // -> in both cases cannot be ordered
-                // Second condition : faces-config.xml has a name but <ordering> element does not have slot with that name
-                //  -> resource can be ordered, but will fit into <others /> element
-                if ((resource.getName() == null) || (resource.getName() != null && !containsResourceInSlot(slots, resource.getName())))
-                {
-                    othersResources.add(resource);
-                }
-            }
-            
-            //2. Scan slot by slot and merge information according
-            for (OrderSlot slot : webAppConfig.getAbsoluteOrdering().getOrderList())
-            {
-                if (slot instanceof ConfigOthersSlot)
-                {
-                    //Add all mentioned in othersResources
-                    for (FacesConfig resource : othersResources)
-                    {
-                        getDispenser().feed(resource);
-                    }
-                }
-                else
-                {
-                    //Add it to the sorted list
-                    FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
-                    getDispenser().feed(getFacesConfig(appConfigResources, nameSlot.getName()));
-                }
-            }
-        }
-        else if (!appConfigResources.isEmpty())
-        {
-            //Relative ordering
-            for (FacesConfig resource : appConfigResources)
-            {
-                if (resource.getAbsoluteOrdering() != null)
-                {
-                    if (log.isLoggable(Level.WARNING))
-                    {
-                        log.warning("<absolute-ordering> element found in application " +
-                                "configuration resource "+resource.getName()+". " +
-                                "This description will be ignored and the actions described " +
-                                "in <ordering> elements will be taken into account instead.");
-                    }
-                }
-            }
-            
-            List<FacesConfig> postOrderedList = getPostOrderedList(appConfigResources);
-            
-            List<FacesConfig> sortedList = sortRelativeOrderingList(postOrderedList);
-            
-            if (sortedList == null)
-            {
-                //The previous algorithm can't sort correctly, try this one
-                sortedList = applySortingAlgorithm(appConfigResources);
-            }
-            
-            for (FacesConfig resource : sortedList)
-            {
-                //Feed
-                getDispenser().feed(resource);
-            }            
-        }
-        
-        if(webAppConfig != null)    //add null check for apps which don't have a faces-config.xml (e.g. tomahawk examples for 1.1/1.2)
-        {
-            getDispenser().feed(webAppConfig);
-        }
-    }
-
-    /**
-     * Sort using topological ordering algorithm.
-     * 
-     * @param appConfigResources
-     * @return
-     * @throws FacesException
-     */
-    protected List<FacesConfig> applySortingAlgorithm(List<FacesConfig> appConfigResources) throws FacesException
-    {
-        
-        //0. Convert the references into a graph
-        List<Vertex<FacesConfig>> vertexList = new ArrayList<Vertex<FacesConfig>>();
-        for (FacesConfig config : appConfigResources)
-        {
-            Vertex<FacesConfig> v = null;
-            if (config.getName() != null)
-            {
-                v = new Vertex<FacesConfig>(config.getName(), config);
-            }
-            else
-            {
-                v = new Vertex<FacesConfig>(config);
-            }
-            vertexList.add(v);
-        }
-        
-        //1. Resolve dependencies (before-after rules) and mark referenced vertex
-        boolean[] referencedVertex = new boolean[vertexList.size()];
-        
-        for (int i = 0; i < vertexList.size(); i++)
-        {
-            Vertex<FacesConfig> v = vertexList.get(i);
-            FacesConfig f = (FacesConfig) v.getNode();
-            
-            if (f.getOrdering() != null)
-            {
-                for (OrderSlot slot : f.getOrdering().getBeforeList())
-                {
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        int j = DirectedAcyclicGraphVerifier.findVertex(vertexList, name);
-                        Vertex<FacesConfig> v1 = vertexList.get(j);
-                        if (v1 != null)
-                        {
-                            referencedVertex[i] = true;
-                            referencedVertex[j] = true;
-                            v1.addDependency(v);
-                        }
-                    }
-                }
-                for (OrderSlot slot : f.getOrdering().getAfterList())
-                {
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        int j = DirectedAcyclicGraphVerifier.findVertex(vertexList, name);
-                        Vertex<FacesConfig> v1 = vertexList.get(j);
-                        if (v1 != null)
-                        {
-                            referencedVertex[i] = true;
-                            referencedVertex[j] = true;
-                            v.addDependency(v1);
-                        }
-                    }
-                }
-            }
-        }
-        
-        //2. Classify into categories
-        List<Vertex<FacesConfig>> beforeAfterOthersList = new ArrayList<Vertex<FacesConfig>>();
-        List<Vertex<FacesConfig>> othersList = new ArrayList<Vertex<FacesConfig>>();
-        List<Vertex<FacesConfig>> referencedList = new ArrayList<Vertex<FacesConfig>>();
-        
-        for (int i = 0; i < vertexList.size(); i++)
-        {
-            if (!referencedVertex[i])
-            {
-                Vertex<FacesConfig> v = vertexList.get(i);
-                FacesConfig f = (FacesConfig) v.getNode();
-                boolean added = false;
-                if (f.getOrdering() != null)
-                {
-                    if (!f.getOrdering().getBeforeList().isEmpty())
-                    {
-                        added = true;
-                        beforeAfterOthersList.add(v);
-                    }
-                    else if (!f.getOrdering().getAfterList().isEmpty())
-                    {
-                        added = true;
-                        beforeAfterOthersList.add(v);
-                    }
-                }
-                if (!added)
-                {
-                    othersList.add(v);
-                }
-            }
-            else
-            {
-                referencedList.add(vertexList.get(i));
-            }
-        }
-        
-        //3. Sort all referenced nodes
-        try
-        {
-            DirectedAcyclicGraphVerifier.topologicalSort(referencedList);
-        }
-        catch (CyclicDependencyException e)
-        {
-            e.printStackTrace();
-        }
-        
-        //4. Add referenced nodes
-        List<FacesConfig> sortedList = new ArrayList<FacesConfig>();
-        for (Vertex<FacesConfig> v : referencedList)
-        {
-            sortedList.add((FacesConfig)v.getNode());
-        }
-        
-        //5. add nodes without instructions at the end
-        for (Vertex<FacesConfig> v : othersList)
-        {
-            sortedList.add((FacesConfig)v.getNode());
-        }
-        
-        //6. add before/after nodes
-        for (Vertex<FacesConfig> v : beforeAfterOthersList)
-        {
-            FacesConfig f = (FacesConfig) v.getNode();
-            boolean added = false;
-            if (f.getOrdering() != null)
-            {
-                if (!f.getOrdering().getBeforeList().isEmpty())
-                {
-                    added = true;
-                    sortedList.add(0,f);
-                }
-            }
-            if (!added)
-            {
-                sortedList.add(f);
-            }            
-        }
-        
-        //Check
-        for (int i = 0; i < sortedList.size(); i++)
-        {
-            FacesConfig resource = sortedList.get(i);
-            
-            if (resource.getOrdering() != null)
-            {
-                for (OrderSlot slot : resource.getOrdering().getBeforeList())
-                {
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        if (name != null && !"".equals(name))
-                        {
-                            boolean founded = false;
-                            for (int j = i-1; j >= 0; j--)
-                            {
-                                if (name.equals(sortedList.get(j).getName()))
-                                {
-                                    founded=true;
-                                    break;
-                                }
-                            }
-                            if (founded)
-                            {
-                                log.severe("Circular references detected when sorting " +
-                                          "application config resources. Use absolute ordering instead.");
-                                throw new FacesException("Circular references detected when sorting " +
-                                        "application config resources. Use absolute ordering instead.");
-                            }
-                        }
-                    }
-                }
-                for (OrderSlot slot : resource.getOrdering().getAfterList())
-                {
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        if (name != null && !"".equals(name))
-                        {
-                            boolean founded = false;
-                            for (int j = i+1; j < sortedList.size(); j++)
-                            {
-                                if (name.equals(sortedList.get(j).getName()))
-                                {
-                                    founded=true;
-                                    break;
-                                }
-                            }
-                            if (founded)
-                            {
-                                log.severe("Circular references detected when sorting " +
-                                    "application config resources. Use absolute ordering instead.");
-                                throw new FacesException("Circular references detected when sorting " +
-                                    "application config resources. Use absolute ordering instead.");
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        
-        return sortedList;
-    }
-    
-    /**
-     * Sort a list of pre ordered elements. It scans one by one the elements
-     * and apply the conditions mentioned by Ordering object if it is available.
-     * 
-     * The preOrderedList ensures that application config resources referenced by
-     * other resources are processed first, making more easier the sort procedure. 
-     * 
-     * @param preOrderedList
-     * @return
-     */
-    protected List<FacesConfig> sortRelativeOrderingList(List<FacesConfig> preOrderedList)
-    {
-        List<FacesConfig> sortedList = new ArrayList<FacesConfig>();
-        
-        for (int i=0; i < preOrderedList.size(); i++)
-        {
-            FacesConfig resource = preOrderedList.get(i);
-            if (resource.getOrdering() != null)
-            {
-                if (resource.getOrdering().getBeforeList().isEmpty() &&
-                    resource.getOrdering().getAfterList().isEmpty())
-                {
-                    //No order rules, just put it as is
-                    sortedList.add(resource);
-                }
-                else if (resource.getOrdering().getBeforeList().isEmpty())
-                {
-                    //Only after rules
-                    applyAfterRule(sortedList, resource);
-                }
-                else if (resource.getOrdering().getAfterList().isEmpty())
-                {
-                    //Only before rules
-                    
-                    //Resolve if there is a later reference to this node before
-                    //apply it
-                    boolean referenceNode = false;
-
-                    for (int j = i+1; j < preOrderedList.size(); j++)
-                    {
-                        FacesConfig pointingResource = preOrderedList.get(j);
-                        for (OrderSlot slot : pointingResource.getOrdering().getBeforeList())
-                        {
-                            if (slot instanceof FacesConfigNameSlot &&
-                                    resource.getName().equals(((FacesConfigNameSlot)slot).getName()) )
-                            {
-                                referenceNode = true;
-                            }
-                            if (slot instanceof ConfigOthersSlot)
-                            {
-                                //No matter if there is a reference, because this rule
-                                //is not strict and before other ordering is unpredictable.
-                                //
-                                referenceNode = false;
-                                break;
-                            }
-                        }
-                        if (referenceNode)
-                        {
-                            break;
-                        }
-                        for (OrderSlot slot : pointingResource.getOrdering().getAfterList())
-                        {
-                            if (slot instanceof FacesConfigNameSlot &&
-                                resource.getName().equals(((FacesConfigNameSlot)slot).getName()) )
-                            {
-                                referenceNode = true;
-                                break;
-                            }
-                        }
-                    }
-                    
-                    applyBeforeRule(sortedList, resource, referenceNode);
-                }
-                else
-                {
-                    //Both before and after rules
-                    //In this case we should compare before and after rules
-                    //and the one with names takes precedence over the other one.
-                    //It both have names references, before rules takes
-                    //precedence over after
-                    //after some action is applied a check of the condition is made.
-                    int beforeWeight = 0;
-                    int afterWeight = 0;
-                    for (OrderSlot slot : resource.getOrdering()
-                            .getBeforeList())
-                    {
-                        if (slot instanceof FacesConfigNameSlot)
-                        {
-                            beforeWeight++;
-                        }
-                    }
-                    for (OrderSlot slot : resource.getOrdering()
-                            .getAfterList())
-                    {
-                        if (slot instanceof FacesConfigNameSlot)
-                        {
-                            afterWeight++;
-                        }
-                    }
-                    
-                    if (beforeWeight >= afterWeight)
-                    {
-                        applyBeforeRule(sortedList, resource,false);
-                    }
-                    else
-                    {
-                        applyAfterRule(sortedList, resource);
-                    }
-                    
-                    
-                }
-            }
-            else
-            {
-                //No order rules, just put it as is
-                sortedList.add(resource);
-            }
-        }
-        
-        //Check
-        for (int i = 0; i < sortedList.size(); i++)
-        {
-            FacesConfig resource = sortedList.get(i);
-            
-            if (resource.getOrdering() != null)
-            {
-                for (OrderSlot slot : resource.getOrdering().getBeforeList())
-                {
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        if (name != null && !"".equals(name))
-                        {
-                            boolean founded = false;                                
-                            for (int j = i-1; j >= 0; j--)
-                            {
-                                if (name.equals(sortedList.get(j).getName()))
-                                {
-                                    founded=true;
-                                    break;
-                                }
-                            }
-                            if (founded)
-                            {
-                                //Cyclic reference
-                                return null;
-                            }
-                        }
-                    }
-                }
-                for (OrderSlot slot : resource.getOrdering().getAfterList())
-                {
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        if (name != null && !"".equals(name))
-                        {
-                            boolean founded = false;                                
-                            for (int j = i+1; j < sortedList.size(); j++)
-                            {
-                                if (name.equals(sortedList.get(j).getName()))
-                                {
-                                    founded=true;
-                                    break;
-                                }
-                            }
-                            if (founded)
-                            {
-                                //Cyclic reference
-                                return null;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        
-        return sortedList;
-    }
-    
-    private void applyBeforeRule(List<FacesConfig> sortedList, FacesConfig resource, boolean referenced) throws FacesException
-    {
-        //Only before rules
-        boolean configOthers = false;
-        List<String> names = new ArrayList<String>();
-        
-        for (OrderSlot slot : resource.getOrdering().getBeforeList())
-        {
-            if (slot instanceof ConfigOthersSlot)
-            {
-                configOthers = true;
-                break;
-            }
-            else
-            {
-                FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
-                names.add(nameSlot.getName());
-            }
-        }
-        
-        if (configOthers)
-        {
-            //<before>....<others/></before> case
-            //other reference where already considered when
-            //pre ordered list was calculated, so just add to the end.
-            
-            //There is one very special case, and it is when there
-            //is another resource with a reference on it. In this case,
-            //it is better do not apply this rule and add it to the end
-            //to give the chance to the other one to be applied.
-            if (resource.getOrdering().getBeforeList().size() > 1)
-            {
-                //If there is a reference apply it
-                sortedList.add(0,resource);
-            }
-            else if (!referenced)
-            {
-                //If it is not referenced apply it
-                sortedList.add(0,resource);
-            }
-            else
-            {
-                //if it is referenced bypass the rule and add it to the end
-                sortedList.add(resource);
-            }
-        }
-        else
-        {
-            //Scan the nearest reference and add it after
-            boolean founded = false;
-            for (int i = 0; i < sortedList.size() ; i++)
-            {
-                if (names.contains(sortedList.get(i).getName()))
-                {
-                    sortedList.add(i,resource);
-                    founded = true;
-                    break;
-                }
-            }
-            if (!founded)
-            {
-                //just add it to the end
-                sortedList.add(resource);
-            }
-        }        
-    }
-    
-    private void applyAfterRule(List<FacesConfig> sortedList, FacesConfig resource) throws FacesException
-    {
-        boolean configOthers = false;
-        List<String> names = new ArrayList<String>();
-        
-        for (OrderSlot slot : resource.getOrdering().getAfterList())
-        {
-            if (slot instanceof ConfigOthersSlot)
-            {
-                configOthers = true;
-                break;
-            }
-            else
-            {
-                FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
-                names.add(nameSlot.getName());
-            }
-        }
-        
-        if (configOthers)
-        {
-            //<after>....<others/></after> case
-            //other reference where already considered when
-            //pre ordered list was calculated, so just add to the end.
-            sortedList.add(resource);
-        }
-        else
-        {
-            //Scan the nearest reference and add it after
-            boolean founded = false;
-            for (int i = sortedList.size()-1 ; i >=0 ; i--)
-            {
-                if (names.contains(sortedList.get(i).getName()))
-                {
-                    if (i+1 < sortedList.size())
-                    {
-                        sortedList.add(i+1,resource);
-                    }
-                    else
-                    {
-                        sortedList.add(resource);
-                    }
-                    founded = true;
-                    break;
-                }
-            }
-            if (!founded)
-            {
-                //just add it to the end
-                sortedList.add(resource);
-            }
-        }        
-    }
-    
-    
-    /**
-     * Pre Sort the appConfigResources, detecting cyclic references, so when sort process
-     * start, it is just necessary to traverse the preOrderedList once. To do that, we just
-     * scan "before" and "after" lists for references, and then those references are traversed
-     * again, so the first elements of the pre ordered list does not have references and
-     * the next elements has references to the already added ones.
-     * 
-     * The elements on the preOrderedList looks like this:
-     * 
-     * [ no ordering elements , referenced elements ... more referenced elements, 
-     *  before others / after others non referenced elements]
-     * 
-     * @param appConfigResources
-     * @return
-     */
-    protected List<FacesConfig> getPostOrderedList(final List<FacesConfig> appConfigResources) throws FacesException
-    {
-        
-        //0. Clean up: remove all not found resource references from the ordering 
-        //descriptions.
-        List<String> availableReferences = new ArrayList<String>();
-        for (FacesConfig resource : appConfigResources)
-        {
-            String name = resource.getName();
-            if (name != null && !"".equals(name))
-            {
-                availableReferences.add(name);
-            }
-        }
-        
-        for (FacesConfig resource : appConfigResources)
-        {
-            Ordering ordering = resource.getOrdering();
-            if (ordering != null)
-            {
-                for (Iterator<OrderSlot> it =  resource.getOrdering().getBeforeList().iterator();it.hasNext();)
-                {
-                    OrderSlot slot = it.next();
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        if (!availableReferences.contains(name))
-                        {
-                            it.remove();
-                        }
-                    }
-                }
-                for (Iterator<OrderSlot> it =  resource.getOrdering().getAfterList().iterator();it.hasNext();)
-                {
-                    OrderSlot slot = it.next();
-                    if (slot instanceof FacesConfigNameSlot)
-                    {
-                        String name = ((FacesConfigNameSlot) slot).getName();
-                        if (!availableReferences.contains(name))
-                        {
-                            it.remove();
-                        }
-                    }
-                }
-            }
-        }
-
-        List<FacesConfig> appFilteredConfigResources = null; 
-
-        //1. Pre filtering: Sort nodes according to its weight. The weight is the number of named
-        //nodes containing in both before and after lists. The sort is done from the more complex
-        //to the most simple
-        if (appConfigResources instanceof ArrayList)
-        {
-            appFilteredConfigResources = (List<FacesConfig>)
-                ((ArrayList<FacesConfig>)appConfigResources).clone();
-        }
-        else
-        {
-            appFilteredConfigResources = new ArrayList<FacesConfig>();
-            appFilteredConfigResources.addAll(appConfigResources);
-        }
-        Collections.sort(appFilteredConfigResources,
-                new Comparator<FacesConfig>()
-                {
-                    public int compare(FacesConfig o1, FacesConfig o2)
-                    {
-                        int o1Weight = 0;
-                        int o2Weight = 0;
-                        if (o1.getOrdering() != null)
-                        {
-                            for (OrderSlot slot : o1.getOrdering()
-                                    .getBeforeList())
-                            {
-                                if (slot instanceof FacesConfigNameSlot)
-                                {
-                                    o1Weight++;
-                                }
-                            }
-                            for (OrderSlot slot : o1.getOrdering()
-                                    .getAfterList())
-                            {
-                                if (slot instanceof FacesConfigNameSlot)
-                                {
-                                    o1Weight++;
-                                }
-                            }
-                        }
-                        if (o2.getOrdering() != null)
-                        {
-                            for (OrderSlot slot : o2.getOrdering()
-                                    .getBeforeList())
-                            {
-                                if (slot instanceof FacesConfigNameSlot)
-                                {
-                                    o2Weight++;
-                                }
-                            }
-                            for (OrderSlot slot : o2.getOrdering()
-                                    .getAfterList())
-                            {
-                                if (slot instanceof FacesConfigNameSlot)
-                                {
-                                    o2Weight++;
-                                }
-                            }
-                        }
-                        return o2Weight - o1Weight;
-                    }
-                });
-        
-        List<FacesConfig> postOrderedList = new LinkedList<FacesConfig>();
-        List<FacesConfig> othersList = new ArrayList<FacesConfig>();
-        
-        List<String> nameBeforeStack = new ArrayList<String>();
-        List<String> nameAfterStack = new ArrayList<String>();
-        
-        boolean[] visitedSlots = new boolean[appFilteredConfigResources.size()];
-        
-        //2. Scan and resolve conflicts
-        for (int i = 0; i < appFilteredConfigResources.size(); i++)
-        {
-            if (!visitedSlots[i])
-            {
-                resolveConflicts(appFilteredConfigResources, i, visitedSlots, 
-                        nameBeforeStack, nameAfterStack, postOrderedList, othersList, false);
-            }
-        }
-        
-        //Add othersList to postOrderedList so <before><others/></before> and <after><others/></after>
-        //ordering conditions are handled at last if there are not referenced by anyone
-        postOrderedList.addAll(othersList);
-        
-        return postOrderedList;
-    }
-        
-    private void resolveConflicts(final List<FacesConfig> appConfigResources, int index, boolean[] visitedSlots,
-            List<String> nameBeforeStack, List<String> nameAfterStack, List<FacesConfig> postOrderedList,
-            List<FacesConfig> othersList, boolean indexReferenced) throws FacesException
-    {
-        FacesConfig facesConfig = appConfigResources.get(index);
-        
-        if (nameBeforeStack.contains(facesConfig.getName()))
-        {
-            //Already referenced, just return. Later if there exists a
-            //circular reference, it will be detected and solved.
-            return;
-        }
-        
-        if (nameAfterStack.contains(facesConfig.getName()))
-        {
-            //Already referenced, just return. Later if there exists a
-            //circular reference, it will be detected and solved.
-            return;
-        }
-        
-        if (facesConfig.getOrdering() != null)
-        {
-            boolean pointingResource = false;
-            
-            //Deal with before restrictions first
-            for (OrderSlot slot : facesConfig.getOrdering().getBeforeList())
-            {
-                if (slot instanceof FacesConfigNameSlot)
-                {
-                    FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
-                    //The resource pointed is not added yet?
-                    boolean alreadyAdded = false;
-                    for (FacesConfig res : postOrderedList)
-                    {
-                        if (nameSlot.getName().equals(res.getName()))
-                        {
-                            alreadyAdded = true;
-                            break;
-                        }
-                    }
-                    if (!alreadyAdded)
-                    {
-                        int indexSlot = -1;
-                        //Find it
-                        for (int i = 0; i < appConfigResources.size(); i++)
-                        {
-                            FacesConfig resource = appConfigResources.get(i);
-                            if (resource.getName() != null && nameSlot.getName().equals(resource.getName()))
-                            {
-                                indexSlot = i;
-                                break;
-                            }
-                        }
-                        
-                        //Resource founded on appConfigResources
-                        if (indexSlot != -1)
-                        {
-                            pointingResource = true;
-                            //Add to nameStac
-                            nameBeforeStack.add(facesConfig.getName());
-                            
-                            resolveConflicts(appConfigResources, indexSlot, visitedSlots, 
-                                    nameBeforeStack, nameAfterStack, postOrderedList,
-                                    othersList,true);
-                            
-                            nameBeforeStack.remove(facesConfig.getName());
-                        }
-                    }
-                    else
-                    {
-                        pointingResource = true;
-                    }
-                }
-            }
-            
-            for (OrderSlot slot : facesConfig.getOrdering().getAfterList())
-            {
-                if (slot instanceof FacesConfigNameSlot)
-                {
-                    FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
-                    //The resource pointed is not added yet?
-                    boolean alreadyAdded = false;
-                    for (FacesConfig res : postOrderedList)
-                    {
-                        if (nameSlot.getName().equals(res.getName()))
-                        {
-                            alreadyAdded = true;
-                            break;
-                        }
-                    }
-                    if (!alreadyAdded)
-                    {
-                        int indexSlot = -1;
-                        //Find it
-                        for (int i = 0; i < appConfigResources.size(); i++)
-                        {
-                            FacesConfig resource = appConfigResources.get(i);
-                            if (resource.getName() != null && nameSlot.getName().equals(resource.getName()))
-                            {
-                                indexSlot = i;
-                                break;
-                            }
-                        }
-                        
-                        //Resource founded on appConfigResources
-                        if (indexSlot != -1)
-                        {
-                            pointingResource = true;
-                            //Add to nameStac
-                            nameAfterStack.add(facesConfig.getName());
-                            
-                            resolveConflicts(appConfigResources, indexSlot, visitedSlots, 
-                                    nameBeforeStack, nameAfterStack, postOrderedList,
-                                    othersList,true);
-                            
-                            nameAfterStack.remove(facesConfig.getName());
-                        }
-                    }
-                    else
-                    {
-                        pointingResource = true;
-                    }
-                }
-            }
-            
-            if (facesConfig.getOrdering().getBeforeList().isEmpty() &&
-                facesConfig.getOrdering().getAfterList().isEmpty())
-            {
-                //Fits in the category "others", put at beginning
-                postOrderedList.add(0,appConfigResources.get(index));
-            }
-            else if (pointingResource || indexReferenced)
-            {
-                //If the node points to other or is referenced from other,
-                //add to the postOrderedList at the end
-                postOrderedList.add(appConfigResources.get(index));                    
-            }
-            else
-            {
-                //Add to othersList
-                othersList.add(appConfigResources.get(index));
-            }
-        }
-        else
-        {
-            //Add at start of the list, since does not have any ordering
-            //instructions and on the next step makes than "before others" and "after others"
-            //works correctly
-            postOrderedList.add(0,appConfigResources.get(index));
-        }
-        //Set the node as visited
-        visitedSlots[index] = true;
-    }    
-    
-    private FacesConfig getFacesConfig(List<FacesConfig> appConfigResources, String name)
-    {
-        for (FacesConfig cfg: appConfigResources)
-        {
-            if (cfg.getName() != null && name.equals(cfg.getName()))
-            {
-                return cfg;
-            }
-        }
-        return null;
-    }
-    
-    private boolean containsResourceInSlot(List<OrderSlot> slots, String name)
-    {
-        for (OrderSlot slot: slots)
-        {
-            if (slot instanceof FacesConfigNameSlot)
-            {
-                FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
-                if (name.equals(nameSlot.getName()))
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
     private void configureFactories()
     {
-        FacesConfigDispenser<FacesConfig> dispenser = getDispenser();
+        FacesConfigData dispenser = getDispenser();
         setFactories(FactoryFinder.APPLICATION_FACTORY, dispenser.getApplicationFactoryIterator(),
                      DEFAULT_APPLICATION_FACTORY);
         setFactories(FactoryFinder.EXCEPTION_HANDLER_FACTORY, dispenser.getExceptionHandlerFactoryIterator(),
@@ -1940,7 +647,7 @@ public class FacesConfigurator
     {
         Application application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
 
-        FacesConfigDispenser<FacesConfig> dispenser = getDispenser();
+        FacesConfigData dispenser = getDispenser();
         application.setActionListener(ClassUtils.buildApplicationObject(ActionListener.class,
                                                            dispenser.getActionListenerIterator(), null));
 
@@ -2141,7 +848,7 @@ public class FacesConfigurator
     {
         RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
 
-        FacesConfigDispenser<FacesConfig> dispenser = getDispenser();
+        FacesConfigData dispenser = getDispenser();
         for (ManagedBean bean : dispenser.getManagedBeans())
         {
             if (log.isLoggable(Level.WARNING) && runtimeConfig.getManagedBean(bean.getManagedBeanName()) != null)
@@ -2222,7 +929,7 @@ public class FacesConfigurator
     {
         RenderKitFactory renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
 
-        FacesConfigDispenser<FacesConfig> dispenser = getDispenser();
+        FacesConfigData dispenser = getDispenser();
         for (String renderKitId : dispenser.getRenderKitIds())
         {
             Collection<String> renderKitClass = dispenser.getRenderKitClasses(renderKitId);

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java?rev=1039554&r1=1039553&r2=1039554&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java Fri Nov 26 20:32:39 2010
@@ -36,7 +36,7 @@ import javax.faces.el.VariableResolver;
 
 import org.apache.myfaces.config.element.ManagedBean;
 import org.apache.myfaces.config.element.NavigationRule;
-import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
+import org.apache.myfaces.config.element.ResourceBundle;
 
 /**
  * Holds all configuration information (from the faces-config xml files) that is needed later during runtime. The config
@@ -74,8 +74,8 @@ public class RuntimeConfig
 
     private VariableResolver _variableResolverChainHead;
 
-    private final Map<String, org.apache.myfaces.config.impl.digester.elements.Converter> _converterClassNameToConfigurationMap =
-        new ConcurrentHashMap<String, org.apache.myfaces.config.impl.digester.elements.Converter>();
+    private final Map<String, org.apache.myfaces.config.element.Converter> _converterClassNameToConfigurationMap =
+        new ConcurrentHashMap<String, org.apache.myfaces.config.element.Converter>();
     
     private NamedEventManager _namedEventManager;
 
@@ -152,7 +152,7 @@ public class RuntimeConfig
 
     
     public final void addConverterConfiguration(final String converterClassName,
-            final org.apache.myfaces.config.impl.digester.elements.Converter configuration)
+            final org.apache.myfaces.config.element.Converter configuration)
     {
         checkNull(converterClassName, "converterClassName");
         checkEmpty(converterClassName, "converterClassName");
@@ -161,9 +161,9 @@ public class RuntimeConfig
         _converterClassNameToConfigurationMap.put(converterClassName, configuration);
     }
     
-    public org.apache.myfaces.config.impl.digester.elements.Converter getConverterConfiguration(String converterClassName)
+    public org.apache.myfaces.config.element.Converter getConverterConfiguration(String converterClassName)
     {
-        return (org.apache.myfaces.config.impl.digester.elements.Converter)_converterClassNameToConfigurationMap.get(converterClassName);
+        return (org.apache.myfaces.config.element.Converter)_converterClassNameToConfigurationMap.get(converterClassName);
     }
     
     private void checkNull(final Object param, final String paramName)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java?rev=1039554&r1=1039553&r2=1039554&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java Fri Nov 26 20:32:39 2010
@@ -83,20 +83,17 @@ public class AnnotationConfigurator
 {
     //private static final Log log = LogFactory.getLog(AnnotationConfigurator.class);
     private static final Logger log = Logger.getLogger(AnnotationConfigurator.class.getName());
-    
-    private final ExternalContext _externalContext;
 
     /**
      * <p>The render kit factory for this application.</p>
      */
     private RenderKitFactory rkFactory = null;
 
-    public AnnotationConfigurator(ExternalContext externalContext)
+    public AnnotationConfigurator()
     {
-        _externalContext = externalContext;
     }
 
-    public FacesConfig createFacesConfig(boolean metadataComplete)
+    public FacesConfig createFacesConfig(ExternalContext _externalContext, boolean metadataComplete)
     {
         if (!metadataComplete)
         {
@@ -215,7 +212,8 @@ public class AnnotationConfigurator
                                 + ", " + clazz.getName() + ")");
                     }
                     
-                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit = facesConfig.getRenderKit(renderKitId);
+                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
+                       (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
                     if (renderKit == null)
                     {
                         renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
@@ -440,7 +438,8 @@ public class AnnotationConfigurator
                              clazz.getName() + ")");
                     }
                     
-                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit = facesConfig.getRenderKit(renderKitId);
+                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
+                        (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
                     if (renderKit == null)
                     {
                         renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/AbsoluteOrdering.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/AbsoluteOrdering.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/AbsoluteOrdering.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/AbsoluteOrdering.java Fri Nov 26 20:32:39 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.element;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class AbsoluteOrdering implements Serializable
+{
+    
+    /**
+     * 
+     * @return
+     */
+    public abstract List<OrderSlot> getOrderList();
+    
+}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Application.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Application.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Application.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Application.java Fri Nov 26 20:32:39 2010
@@ -0,0 +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.config.element;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class Application implements Serializable
+{
+
+    public abstract List<String> getActionListener();
+
+    public abstract List<String> getDefaultRenderkitId();
+    
+    public abstract List<String> getDefaultValidatorIds();
+    
+    public abstract List<String> getMessageBundle();
+
+    public abstract List<String> getNavigationHandler();
+    
+    public abstract List<String> getPartialTraversal ();
+    
+    public abstract List<String> getResourceHandler();
+    
+    public abstract List<SystemEventListener> getSystemEventListeners ();
+    
+    public abstract List<String> getViewHandler();
+
+    public abstract List<String> getStateManager();
+
+    public abstract List<String> getPropertyResolver();
+
+    public abstract List<String> getVariableResolver();
+
+    public abstract List<LocaleConfig> getLocaleConfig();
+
+    public abstract List<String> getElResolver();
+
+    public abstract List<ResourceBundle> getResourceBundle();
+
+    public abstract boolean isDefaultValidatorsPresent();
+
+}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Attribute.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Attribute.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Attribute.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Attribute.java Fri Nov 26 20:32:39 2010
@@ -0,0 +1,46 @@
+/*
+ * 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.element;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class Attribute implements Serializable
+{
+    public abstract Collection<? extends String> getDescriptions();
+
+    public abstract Collection<? extends String> getDisplayNames();
+
+    public abstract Collection<? extends String> getIcons();
+
+    public abstract String getAttributeName();
+
+    public abstract String getAttributeClass();
+
+    public abstract String getDefaultValue();
+
+    public abstract String getSuggestedValue();
+
+    public abstract Collection<? extends String> getAttributeExtensions();
+}

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java?rev=1039554&r1=1039553&r2=1039554&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java Fri Nov 26 20:32:39 2010
@@ -18,12 +18,16 @@
  */
 package org.apache.myfaces.config.element;
 
+import java.io.Serializable;
+
 /**
  * Model for <behavior> config element.
  */
 
-public interface Behavior
+public abstract class Behavior implements Serializable
 {
-    public String getBehaviorId ();
-    public String getBehaviorClass ();
+    public abstract String getBehaviorId ();
+    
+    public abstract String getBehaviorClass ();
+    
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ClientBehaviorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ClientBehaviorRenderer.java?rev=1039554&r1=1039553&r2=1039554&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ClientBehaviorRenderer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ClientBehaviorRenderer.java Fri Nov 26 20:32:39 2010
@@ -18,14 +18,16 @@
  */
 package org.apache.myfaces.config.element;
 
+import java.io.Serializable;
+
 /**
  * Config holder for <client-behavior-renderer> element.
  */
 
-public interface ClientBehaviorRenderer
+public abstract class ClientBehaviorRenderer implements Serializable
 {
-    public String getRendererClass();
+    public abstract String getRendererClass();
 
-    public String getRendererType();
+    public abstract String getRendererType();
 
 }
\ No newline at end of file

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Component.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Component.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Component.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Component.java Fri Nov 26 20:32:39 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.element;
+
+import java.io.Serializable;
+
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class Component implements Serializable
+{
+
+    public abstract String getComponentType();
+
+    public abstract String getComponentClass();
+}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ConfigOthersSlot.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ConfigOthersSlot.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ConfigOthersSlot.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ConfigOthersSlot.java Fri Nov 26 20:32:39 2010
@@ -0,0 +1,31 @@
+/*
+ * 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.element;
+
+import java.io.Serializable;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class ConfigOthersSlot extends OrderSlot implements Serializable
+{
+
+}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Converter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Converter.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Converter.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Converter.java Fri Nov 26 20:32:39 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.element;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class Converter implements Serializable
+{
+    public abstract String getConverterId();
+
+    public abstract String getForClass();
+
+    public abstract String getConverterClass();
+
+    public abstract Collection<? extends Property> getProperties();
+    
+    public abstract Collection<? extends Attribute> getAttributes();
+}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java?rev=1039554&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java Fri Nov 26 20:32:39 2010
@@ -0,0 +1,63 @@
+/*
+ * 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.element;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
+ */
+public abstract class FacesConfig implements Serializable
+{
+    public abstract List<Application> getApplications();
+
+    public abstract List<Factory> getFactories();
+
+    public abstract Map<String, String> getComponents();
+
+    public abstract List<Converter> getConverters();
+
+    public abstract List<ManagedBean> getManagedBeans();
+
+    public abstract List<NavigationRule> getNavigationRules();
+
+    public abstract List<RenderKit> getRenderKits();
+
+    public abstract List<String> getLifecyclePhaseListener();
+
+    public abstract Map<String, String> getValidators();
+    
+    public abstract List<Behavior> getBehaviors ();
+    
+    public abstract List<NamedEvent> getNamedEvents ();
+    
+    public abstract RenderKit getRenderKit(String renderKitId);
+    
+    public abstract String getName();
+    
+    public abstract AbsoluteOrdering getAbsoluteOrdering();
+
+    public abstract Ordering getOrdering();
+
+    public abstract String getMetadataComplete();
+
+    public abstract String getVersion ();
+}