geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1048917 [1/2] - in /geronimo/server/trunk/plugins/myfaces: geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/ geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ geronimo-myfaces/src/main/java/org/apache...
Date Tue, 14 Dec 2010 03:13:10 GMT
Author: xuhaihong
Date: Tue Dec 14 03:13:09 2010
New Revision: 1048917

URL: http://svn.apache.org/viewvc?rev=1048917&view=rev
Log:
GERONIMO-5713 MyFaces 2.0.3 Integration

Added:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java   (with props)
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java   (with props)
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java   (with props)
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java   (with props)
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java   (with props)
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/info/
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/info/GeronimoFacesConfigData.java   (with props)
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/info/GeronimoFacesConfigurationMergerFactory.java   (with props)
Removed:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/annotation/
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/GeronimoFacesConfigResourceProviderFactory.java
Modified:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoStartupServletContextListener.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java?rev=1048917&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java (added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java Tue Dec 14 03:13:09 2010
@@ -0,0 +1,140 @@
+/**
+ *  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.geronimo.myfaces.deployment;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.context.ExternalContext;
+
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.spi.FacesConfigurationProvider;
+import org.apache.myfaces.spi.ServiceProviderFinderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Geronimo only uses this in the deployment process, all the parsing, sorting and merging work will be done.
+ * @version $Rev$ $Date$
+ */
+public class GeronimoFacesConfigurationProvider extends FacesConfigurationProvider {
+
+    private static final Logger logger = LoggerFactory.getLogger(GeronimoFacesConfigurationProvider.class);
+
+    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 FacesConfig annotationsFacesConfig;
+
+    private List<FacesConfig> classloaderFacesConfigs;
+
+    private List<FacesConfig> contextSpecifiedFacesConfigs;
+
+    private FacesConfig webAppFacesConfig;
+
+    private FacesConfig standardFacesConfig;
+
+    public GeronimoFacesConfigurationProvider(FacesConfig standardFacesConfig, FacesConfig webAppFacesConfig, FacesConfig annotationsFacesConfig, List<FacesConfig> classloaderFacesConfigs,
+            List<FacesConfig> contextSpecifiedFacesConfigs) {
+        this.annotationsFacesConfig = annotationsFacesConfig;
+        this.classloaderFacesConfigs = classloaderFacesConfigs;
+        this.contextSpecifiedFacesConfigs = contextSpecifiedFacesConfigs;
+        this.webAppFacesConfig = webAppFacesConfig;
+        this.standardFacesConfig = standardFacesConfig;
+    }
+
+    @Override
+    public FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete) {
+        return annotationsFacesConfig;
+    }
+
+    @Override
+    public List<FacesConfig> getClassloaderFacesConfig(ExternalContext externalContext) {
+        return classloaderFacesConfigs;
+    }
+
+    @Override
+    public List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext externalContext) {
+        return contextSpecifiedFacesConfigs;
+    }
+
+    @Override
+    public FacesConfig getStandardFacesConfig(ExternalContext externalContext) {
+        return standardFacesConfig;
+    }
+
+    @Override
+    public FacesConfig getWebAppFacesConfig(ExternalContext externalContext) {
+        return webAppFacesConfig;
+    }
+
+    @Override
+    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext externalContext) {
+        try {
+            org.apache.myfaces.config.impl.digester.elements.FacesConfig facesConfig = new org.apache.myfaces.config.impl.digester.elements.FacesConfig();
+            org.apache.myfaces.config.impl.digester.elements.Factory factory = new org.apache.myfaces.config.impl.digester.elements.Factory();
+
+            facesConfig.addFactory(factory);
+
+            for (String factoryName : FACTORY_NAMES) {
+                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(factoryName);
+
+                for (String className : classList) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("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);
+                    }
+                }
+            }
+            return facesConfig;
+        } catch (Throwable e) {
+            throw new FacesException(e);
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java?rev=1048917&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java (added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java Tue Dec 14 03:13:09 2010
@@ -0,0 +1,45 @@
+/**
+ *  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.geronimo.myfaces.deployment;
+
+import java.util.List;
+
+import javax.faces.context.ExternalContext;
+
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.spi.FacesConfigurationProvider;
+import org.apache.myfaces.spi.FacesConfigurationProviderFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoFacesConfigurationProviderFactory extends FacesConfigurationProviderFactory {
+
+    private FacesConfigurationProvider facesConfigurationProvider;
+
+    public GeronimoFacesConfigurationProviderFactory(FacesConfig standardFacesConfig, FacesConfig webAppFacesConfig, FacesConfig annotationsFacesConfig, List<FacesConfig> classloaderFacesConfigs,
+            List<FacesConfig> contextSpecifiedFacesConfigs) {
+        facesConfigurationProvider = new GeronimoFacesConfigurationProvider(standardFacesConfig, webAppFacesConfig, annotationsFacesConfig, classloaderFacesConfigs, contextSpecifiedFacesConfigs);
+    }
+
+    @Override
+    public FacesConfigurationProvider getFacesConfigurationProvider(ExternalContext arg0) {
+        return facesConfigurationProvider;
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/GeronimoFacesConfigurationProviderFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java?rev=1048917&r1=1048916&r2=1048917&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java Tue Dec 14 03:13:09 2010
@@ -37,17 +37,15 @@ import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
-import javax.faces.bean.ManagedBean;
 import javax.faces.component.FacesComponent;
 import javax.faces.component.behavior.FacesBehavior;
+import javax.faces.context.ExternalContext;
 import javax.faces.convert.FacesConverter;
 import javax.faces.event.NamedEvent;
 import javax.faces.render.FacesBehaviorRenderer;
 import javax.faces.render.FacesRenderer;
 import javax.faces.validator.FacesValidator;
 import javax.faces.webapp.FacesServlet;
-import javax.xml.bind.JAXBException;
-import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
@@ -71,19 +69,26 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.util.IOUtils;
 import org.apache.geronimo.kernel.util.JarUtils;
+import org.apache.geronimo.myfaces.FacesConfigDigester;
 import org.apache.geronimo.myfaces.LifecycleProviderGBean;
 import org.apache.geronimo.myfaces.config.resource.ConfigurationResource;
+import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
+import org.apache.geronimo.myfaces.info.GeronimoFacesConfigData;
 import org.apache.geronimo.myfaces.webapp.GeronimoStartupServletContextListener;
 import org.apache.geronimo.myfaces.webapp.MyFacesWebAppContext;
 import org.apache.geronimo.web.info.WebAppInfo;
-import org.apache.openejb.jee.FacesConfig;
-import org.apache.openejb.jee.FacesManagedBean;
-import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.myfaces.config.annotation.AnnotationConfigurator;
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.config.element.ManagedBean;
+import org.apache.myfaces.spi.FacesConfigurationMerger;
+import org.apache.myfaces.spi.FacesConfigurationMergerFactory;
+import org.apache.myfaces.spi.FacesConfigurationProviderFactory;
 import org.apache.openejb.jee.ParamValue;
 import org.apache.openejb.jee.Servlet;
 import org.apache.openejb.jee.WebApp;
 import org.apache.xbean.finder.BundleAnnotationFinder;
 import org.apache.xbean.finder.ClassFinder;
+import org.apache.xbean.osgi.bundle.util.BundleClassLoader;
 import org.apache.xbean.osgi.bundle.util.DiscoveryRange;
 import org.apache.xbean.osgi.bundle.util.ResourceDiscoveryFilter;
 import org.apache.xmlbeans.XmlObject;
@@ -113,6 +118,10 @@ public class MyFacesModuleBuilderExtensi
 
     private static final String FACES_SERVLET_NAME = FacesServlet.class.getName();
 
+    private FacesConfigDigester defaultFacesConfigUnmarshaller = new FacesConfigDigester();
+
+    private FacesConfig standardFacesConfig;
+
     public static final EARContext.Key<Set<ConfigurationResource>> JSF_META_INF_CONFIGURATION_RESOURCES = new EARContext.Key<Set<ConfigurationResource>>() {
 
         @Override
@@ -127,6 +136,7 @@ public class MyFacesModuleBuilderExtensi
         this.defaultEnvironment = defaultEnvironment;
         this.providerFactoryNameQuery = providerFactoryNameQuery;
         this.namingBuilders = namingBuilders;
+        this.standardFacesConfig = getStandardFacesConfig();
     }
 
     public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
@@ -199,22 +209,12 @@ public class MyFacesModuleBuilderExtensi
 
         XmlObject jettyWebApp = webModule.getVendorDD();
 
-        FacesConfig defaultWebAppFacesConfig = getDefaultWebAppFacesConfig(webModule);
-        Set<ConfigurationResource> metaInfConfigurationResources = JSF_META_INF_CONFIGURATION_RESOURCES.get(earContext.getGeneralData());
-        Map<Class<? extends Annotation>, Set<Class>> annotationClassSetMap = null;
-        if (!defaultWebAppFacesConfig.isMetadataComplete()) {
-            annotationClassSetMap = scanJSFAnnotations(earContext, webModule, bundle, metaInfConfigurationResources);
-        }
-
+        //Parse default web application faces configuration file WEB-INF/faces-config.xml
+        FacesConfig webAppFacesConfig = getWebAppFacesConfig(webModule);
 
-        AbstractName myFacesWebAppContextName = moduleContext.getNaming().createChildName(moduleName, "myFacesWebAppContext", "MyFacesWebAppContext");
-        GBeanData myFacesWebAppContextData = new GBeanData(myFacesWebAppContextName, MyFacesWebAppContext.class);
-        myFacesWebAppContextData.setAttribute("annotationClassSetMap", annotationClassSetMap);
-        myFacesWebAppContextData.setAttribute("metaInfConfigurationResources", metaInfConfigurationResources);
-
-        List<FacesConfig> facesConfigs = new ArrayList<FacesConfig>();
-        facesConfigs.add(defaultWebAppFacesConfig);
-        facesConfigs.addAll(getContextFacesConfigs(webApp, webModule));
+        //Parse all faces-config.xml files found in META-INF folder
+        Set<ConfigurationResource> metaInfConfigurationResources = JSF_META_INF_CONFIGURATION_RESOURCES.get(earContext.getGeneralData());
+        List<FacesConfig> metaInfFacesConfigs = new ArrayList<FacesConfig>(metaInfConfigurationResources.size());
         for (ConfigurationResource configurationResource : metaInfConfigurationResources) {
             URL url;
             try {
@@ -227,10 +227,62 @@ public class MyFacesModuleBuilderExtensi
                 throw new DeploymentException("Fail to read the faces Configuration file " + configurationResource.getConfigurationResourcePath()
                         + (configurationResource.getJarFilePath() == null ? "" : " from jar file " + configurationResource.getJarFilePath()));
             }
-            facesConfigs.add(parseConfigFile(url, bundle));
+            metaInfFacesConfigs.add(parseConfigFile(url, url.toExternalForm()));
+        }
+
+        //Parse all faces-config.xml files found in classloader hierarchy
+        List<FacesConfig> classloaderFacesConfigs = new ArrayList<FacesConfig>();
+        classloaderFacesConfigs.addAll(metaInfFacesConfigs);
+        ServiceReference ref = null;
+        try {
+            ref = bundle.getBundleContext().getServiceReference(ConfigRegistry.class.getName());
+            ConfigRegistry configRegistry = (ConfigRegistry) bundle.getBundleContext().getService(ref);
+            for (URL url : configRegistry.getRegisteredConfigUrls()) {
+                classloaderFacesConfigs.add(parseConfigFile(url, url.toExternalForm()));
+            }
+        } finally {
+            if (ref != null) {
+                bundle.getBundleContext().ungetService(ref);
+            }
+        }
+
+        //Parse all context faces-config.xml files configured in web.xml file
+        List<FacesConfig> contextSpecifiedFacesConfigs = getContextFacesConfigs(webApp, webModule);
+
+        //Scan annotations if required
+        FacesConfig annotationsFacesConfig = null;
+        if (webAppFacesConfig == null || !Boolean.parseBoolean(webAppFacesConfig.getMetadataComplete())) {
+            annotationsFacesConfig = getJSFAnnotationFacesConfig(earContext, webModule, bundle, metaInfConfigurationResources);
+        }
+
+        AbstractName myFacesWebAppContextName = moduleContext.getNaming().createChildName(moduleName, "myFacesWebAppContext", "MyFacesWebAppContext");
+        GBeanData myFacesWebAppContextData = new GBeanData(myFacesWebAppContextName, MyFacesWebAppContext.class);
+
+        ClassLoader deploymentClassLoader = new BundleClassLoader(bundle);
+        ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(deploymentClassLoader);
+            StandaloneExternalContext standaloneExternalContext = new StandaloneExternalContext(deploymentClassLoader);
+            FacesConfigurationProviderFactory.setFacesConfigurationProviderFactory(standaloneExternalContext, new GeronimoFacesConfigurationProviderFactory(standardFacesConfig, webAppFacesConfig,
+                    annotationsFacesConfig, classloaderFacesConfigs, contextSpecifiedFacesConfigs));
+            FacesConfigurationMerger facesConfigurationMerger = FacesConfigurationMergerFactory.getFacesConfigurationMergerFactory(standaloneExternalContext).getFacesConfigurationMerger(
+                    standaloneExternalContext);
+            myFacesWebAppContextData.setAttribute("facesConfigData", new GeronimoFacesConfigData(facesConfigurationMerger.getFacesConfigData(standaloneExternalContext)));
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldContextClassLoader);
         }
 
-        ClassFinder classFinder = createMyFacesClassFinder(facesConfigs, annotationClassSetMap != null ? annotationClassSetMap.get(ManagedBean.class) : null, bundle);
+        List<FacesConfig> namingFacesConfigs = new ArrayList<FacesConfig>();
+        if (webAppFacesConfig != null) {
+            namingFacesConfigs.add(webAppFacesConfig);
+        }
+        if (annotationsFacesConfig != null) {
+            namingFacesConfigs.add(annotationsFacesConfig);
+        }
+        namingFacesConfigs.addAll(contextSpecifiedFacesConfigs);
+        namingFacesConfigs.addAll(metaInfFacesConfigs);
+
+        ClassFinder classFinder = createMyFacesClassFinder(namingFacesConfigs, bundle);
         webModule.setClassFinder(classFinder);
 
         namingBuilders.buildNaming(webApp, jettyWebApp, webModule, buildingContext);
@@ -252,7 +304,7 @@ public class MyFacesModuleBuilderExtensi
 
     }
 
-    protected Map<Class<? extends Annotation>, Set<Class>> scanJSFAnnotations(EARContext earContext, Module module, Bundle bundle, Set<ConfigurationResource> metaInfConfigurationResources) throws DeploymentException {
+    protected FacesConfig getJSFAnnotationFacesConfig(EARContext earContext, Module module, Bundle bundle, Set<ConfigurationResource> metaInfConfigurationResources) throws DeploymentException {
         ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
         try {
             PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
@@ -262,7 +314,7 @@ public class MyFacesModuleBuilderExtensi
                     requiredJarFiles.add(configurationResource.getJarFilePath());
                 }
             }
-            Map<Class<? extends Annotation>, Set<Class>> annotationClassSetMap = new HashMap<Class<? extends Annotation>, Set<Class>>();
+            final Map<Class<? extends Annotation>, Set<Class<?>>> annotationClassSetMap = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();
             BundleAnnotationFinder bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, new ResourceDiscoveryFilter() {
 
                 @Override
@@ -282,15 +334,21 @@ public class MyFacesModuleBuilderExtensi
                 }
 
             });
-            annotationClassSetMap.put(FacesComponent.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(FacesComponent.class)));
-            annotationClassSetMap.put(FacesConverter.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(FacesConverter.class)));
-            annotationClassSetMap.put(FacesValidator.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(FacesValidator.class)));
-            annotationClassSetMap.put(FacesRenderer.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(FacesRenderer.class)));
-            annotationClassSetMap.put(ManagedBean.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(ManagedBean.class)));
-            annotationClassSetMap.put(NamedEvent.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(NamedEvent.class)));
-            annotationClassSetMap.put(FacesBehavior.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(FacesBehavior.class)));
-            annotationClassSetMap.put(FacesBehaviorRenderer.class, new HashSet<Class>(bundleAnnotationFinder.findAnnotatedClasses(FacesBehaviorRenderer.class)));
-            return annotationClassSetMap;
+            annotationClassSetMap.put(FacesComponent.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(FacesComponent.class)));
+            annotationClassSetMap.put(FacesConverter.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(FacesConverter.class)));
+            annotationClassSetMap.put(FacesValidator.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(FacesValidator.class)));
+            annotationClassSetMap.put(FacesRenderer.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(FacesRenderer.class)));
+            annotationClassSetMap.put(javax.faces.bean.ManagedBean.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(javax.faces.bean.ManagedBean.class)));
+            annotationClassSetMap.put(NamedEvent.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(NamedEvent.class)));
+            annotationClassSetMap.put(FacesBehavior.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(FacesBehavior.class)));
+            annotationClassSetMap.put(FacesBehaviorRenderer.class, new HashSet(bundleAnnotationFinder.findAnnotatedClasses(FacesBehaviorRenderer.class)));
+            return new AnnotationConfigurator() {
+
+                @Override
+                public org.apache.myfaces.config.impl.digester.elements.FacesConfig createFacesConfig(ExternalContext externalContext, boolean metaComplete) {
+                    return createFacesConfig(annotationClassSetMap);
+                }
+            }.createFacesConfig(null, false);
         } catch (Exception e) {
             throw new DeploymentException("Fail to scan JSF annotations", e);
         } finally {
@@ -298,14 +356,12 @@ public class MyFacesModuleBuilderExtensi
         }
     }
 
-    protected FacesConfig getDefaultWebAppFacesConfig(WebModule webModule) throws DeploymentException {
+    protected FacesConfig getWebAppFacesConfig(WebModule webModule) throws DeploymentException {
         URL url = webModule.getDeployable().getResource("WEB-INF/faces-config.xml");
         if (url != null) {
-            Bundle bundle = webModule.getEarContext().getDeploymentBundle();
-            return parseConfigFile(url, bundle);
-        } else {
-            return new FacesConfig();
+            return parseConfigFile(url, "/WEB-INF/faces-config.xml");
         }
+        return null;
     }
 
     protected List<FacesConfig> getContextFacesConfigs(WebApp webApp, WebModule webModule) throws DeploymentException {
@@ -314,7 +370,6 @@ public class MyFacesModuleBuilderExtensi
                 List<FacesConfig> contextFacesConfigs = new ArrayList<FacesConfig>();
                 String configFiles = paramValue.getParamValue().trim();
                 StringTokenizer st = new StringTokenizer(configFiles, ",", false);
-                Bundle bundle = webModule.getEarContext().getDeploymentBundle();
                 while (st.hasMoreTokens()) {
                     String configfile = st.nextToken().trim();
                     if (!configfile.equals("")) {
@@ -325,7 +380,7 @@ public class MyFacesModuleBuilderExtensi
                         if (url == null) {
                             throw new DeploymentException("Could not locate config file " + configfile + " configured with " + FacesServlet.CONFIG_FILES_ATTR + " in the web.xml");
                         } else {
-                            contextFacesConfigs.add(parseConfigFile(url, bundle));
+                            contextFacesConfigs.add(parseConfigFile(url, configfile));
                         }
                     }
                 }
@@ -335,11 +390,21 @@ public class MyFacesModuleBuilderExtensi
         return Collections.<FacesConfig> emptyList();
     }
 
-    protected ClassFinder createMyFacesClassFinder(List<FacesConfig> facesConfigs, Set<Class> annotatedManagedBeanClasses, Bundle bundle) throws DeploymentException {
+    protected FacesConfig getStandardFacesConfig() {
+        try {
+            //TODO A better way to find the standard faces configuration file ?
+            return parseConfigFile(FacesConfig.class.getClassLoader().getResource("META-INF/standard-faces-config.xml"), "META-INF/standard-faces-config.xml");
+        } catch (DeploymentException e) {
+            log.warn("Fail to load the standard faces config file META-INF/standard-faces-config.xml", e);
+            return null;
+        }
+    }
+
+    protected ClassFinder createMyFacesClassFinder(List<FacesConfig> facesConfigs, Bundle bundle) throws DeploymentException {
         List<Class> managedBeanClasses = new ArrayList<Class>();
         for (FacesConfig facesConfig : facesConfigs) {
-            for (FacesManagedBean managedBean : facesConfig.getManagedBean()) {
-                String className = managedBean.getManagedBeanClass().trim();
+            for (ManagedBean managedBean : facesConfig.getManagedBeans()) {
+                String className = managedBean.getManagedBeanClassName().trim();
                 Class<?> clas;
                 try {
                     clas = bundle.loadClass(className);
@@ -352,14 +417,6 @@ public class MyFacesModuleBuilderExtensi
                 }
             }
         }
-        if (annotatedManagedBeanClasses != null) {
-            for (Class<?> clas : annotatedManagedBeanClasses) {
-                while (clas != null) {
-                    managedBeanClasses.add(clas);
-                    clas = clas.getSuperclass();
-                }
-            }
-        }
         return new ClassFinder(managedBeanClasses);
     }
 
@@ -429,19 +486,6 @@ public class MyFacesModuleBuilderExtensi
                 }
             }
         }
-        //default WEB-INF/faces-config.xml is handled by myfaces no matter what we do???
-//        //4. WEB-INF folder
-//        baseDirectory = new File(earContext.getBaseDir() + File.separator + "WEB-INF");
-//        if (baseDirectory.exists() && baseDirectory.isDirectory()) {
-//            for (File file : baseDirectory.listFiles()) {
-//                String fileName = file.getName();
-//                if (fileName.equals("faces-config.xml") || fileName.endsWith(".faces-config.xml")) {
-//                    //TODO Double check the relative jar file path once EAR is really supported
-//                    String filePath = "WEB-INF/" + fileName;
-//                    metaInfConfigurationResources.add(new ConfigurationResource(null, filePath, filePath));
-//                }
-//            }
-//        }
         return metaInfConfigurationResources;
     }
 
@@ -454,20 +498,18 @@ public class MyFacesModuleBuilderExtensi
         return false;
     }
 
-    private FacesConfig parseConfigFile(URL url, Bundle bundle) throws DeploymentException {
-        log.debug("parseConfigFile( " + url.toString() + " ): Entry");
+    private FacesConfig parseConfigFile(URL url, String systemId) throws DeploymentException {
+        if (log.isDebugEnabled()) {
+            log.debug("parseConfigFile( " + url.toString() + " ): Entry");
+        }
         InputStream in = null;
         try {
             in = url.openStream();
-            return (FacesConfig) JaxbJavaee.unmarshalJavaee(FacesConfig.class, in);
-        } catch (ParserConfigurationException e) {
-            throw new DeploymentException("Could not parse alleged faces-config.xml at " + url.toString(), e);
+            return defaultFacesConfigUnmarshaller.getFacesConfig(in, systemId);
+        } catch (IOException e) {
+            throw new DeploymentException("Error reading jsf configuration file " + url, e);
         } catch (SAXException e) {
-            throw new DeploymentException("Could not parse alleged faces-config.xml at " + url.toString(), e);
-        } catch (JAXBException e) {
-            throw new DeploymentException("Could not parse alleged faces-config.xml at " + url.toString(), e);
-        } catch (IOException ioe) {
-            throw new DeploymentException("Error reading jsf configuration file " + url, ioe);
+            throw new DeploymentException("Error reading jsf configuration file " + url, e);
         } finally {
             IOUtils.close(in);
         }

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java?rev=1048917&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java (added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java Tue Dec 14 03:13:09 2010
@@ -0,0 +1,235 @@
+/**
+ *  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.geronimo.myfaces.deployment;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.ExternalContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * DummyExternalContext is only used in the deployment process.
+ * @version $Rev$ $Date$
+ */
+public class StandaloneExternalContext extends ExternalContext {
+
+    private static final Logger logger = LoggerFactory.getLogger(StandaloneExternalContext.class);
+
+    private Map<String, Object> applicationMap = new HashMap<String, Object>();
+
+    private ClassLoader classLoader;
+
+    public StandaloneExternalContext(ClassLoader classLoader) {
+        this.classLoader = classLoader;
+    }
+
+    @Override
+    public void dispatch(String arg0) throws IOException {
+
+    }
+
+    @Override
+    public String encodeActionURL(String arg0) {
+        return null;
+    }
+
+    @Override
+    public String encodeNamespace(String arg0) {
+        return null;
+    }
+
+    @Override
+    public String encodeResourceURL(String arg0) {
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> getApplicationMap() {
+        return applicationMap;
+    }
+
+    @Override
+    public String getAuthType() {
+        return null;
+    }
+
+    @Override
+    public Object getContext() {
+        return null;
+    }
+
+    @Override
+    public String getInitParameter(String arg0) {
+        return null;
+    }
+
+    @Override
+    public Map getInitParameterMap() {
+        return null;
+    }
+
+    @Override
+    public String getRemoteUser() {
+        return null;
+    }
+
+    @Override
+    public Object getRequest() {
+        return null;
+    }
+
+    @Override
+    public String getRequestContextPath() {
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> getRequestCookieMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String> getRequestHeaderMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String[]> getRequestHeaderValuesMap() {
+        return null;
+    }
+
+    @Override
+    public Locale getRequestLocale() {
+        return null;
+    }
+
+    @Override
+    public Iterator<Locale> getRequestLocales() {
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> getRequestMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String> getRequestParameterMap() {
+        return null;
+    }
+
+    @Override
+    public Iterator<String> getRequestParameterNames() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String[]> getRequestParameterValuesMap() {
+        return null;
+    }
+
+    @Override
+    public String getRequestPathInfo() {
+        return null;
+    }
+
+    @Override
+    public String getRequestServletPath() {
+        return null;
+    }
+
+    @Override
+    public URL getResource(String path) throws MalformedURLException {
+        return classLoader.getResource(path);
+    }
+
+    @Override
+    public InputStream getResourceAsStream(String path) {
+        return classLoader.getResourceAsStream(path);
+    }
+
+    @Override
+    public Set<String> getResourcePaths(String path) {
+        try {
+            Enumeration<URL> en = classLoader.getResources(path);
+            Set<String> paths = new HashSet<String>();
+            while (en.hasMoreElements()) {
+                paths.add(en.nextElement().toURI().toString());
+            }
+            return paths;
+        } catch (IOException e) {
+            logger.warn("Fail to getResourcePaths " + path, e);
+            return null;
+        } catch (URISyntaxException e) {
+            logger.warn("Fail to getResourcePaths " + path, e);
+            return null;
+        }
+    }
+
+    @Override
+    public Object getResponse() {
+        return null;
+    }
+
+    @Override
+    public Object getSession(boolean arg0) {
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> getSessionMap() {
+        return null;
+    }
+
+    @Override
+    public Principal getUserPrincipal() {
+        return null;
+    }
+
+    @Override
+    public boolean isUserInRole(String arg0) {
+        return false;
+    }
+
+    @Override
+    public void log(String arg0, Throwable arg1) {
+    }
+
+    @Override
+    public void log(String arg0) {
+    }
+
+    @Override
+    public void redirect(String arg0) throws IOException {
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/StandaloneExternalContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java?rev=1048917&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java (added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java Tue Dec 14 03:13:09 2010
@@ -0,0 +1,322 @@
+/**
+ *  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.geronimo.myfaces;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.digester.Digester;
+import org.apache.myfaces.config.impl.digester.elements.AbsoluteOrdering;
+import org.apache.myfaces.config.impl.digester.elements.Application;
+import org.apache.myfaces.config.impl.digester.elements.Attribute;
+import org.apache.myfaces.config.impl.digester.elements.Behavior;
+import org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer;
+import org.apache.myfaces.config.impl.digester.elements.ConfigOthersSlot;
+import org.apache.myfaces.config.impl.digester.elements.Converter;
+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.ListEntries;
+import org.apache.myfaces.config.impl.digester.elements.LocaleConfig;
+import org.apache.myfaces.config.impl.digester.elements.ManagedBean;
+import org.apache.myfaces.config.impl.digester.elements.ManagedProperty;
+import org.apache.myfaces.config.impl.digester.elements.MapEntries;
+import org.apache.myfaces.config.impl.digester.elements.NavigationCase;
+import org.apache.myfaces.config.impl.digester.elements.NavigationRule;
+import org.apache.myfaces.config.impl.digester.elements.Ordering;
+import org.apache.myfaces.config.impl.digester.elements.Property;
+import org.apache.myfaces.config.impl.digester.elements.Redirect;
+import org.apache.myfaces.config.impl.digester.elements.RenderKit;
+import org.apache.myfaces.config.impl.digester.elements.Renderer;
+import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
+import org.apache.myfaces.config.impl.digester.elements.SystemEventListener;
+import org.apache.myfaces.config.impl.digester.elements.ViewParam;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FacesConfigDigester {
+
+    private Digester digester;
+
+    private static final InputSource EMPTY_INPUT_SOURCE = new InputSource(new ByteArrayInputStream(new byte[0]));
+
+    public FacesConfigDigester() {
+        digester = new Digester();
+        // TODO: validation set to false during implementation of 1.2
+        digester.setValidating(false);
+        digester.setNamespaceAware(true);
+        digester.setEntityResolver(new EntityResolver() {
+
+            @Override
+            public InputSource resolveEntity(String arg0, String arg1) throws SAXException, IOException {
+                return EMPTY_INPUT_SOURCE;
+            }
+
+        });
+        //digester.setUseContextClassLoader(true);
+        digester.setClassLoader(FacesConfig.class.getClassLoader());
+
+        digester.addObjectCreate("faces-config", FacesConfig.class);
+        // 2.0 specific start
+        digester.addSetProperties("faces-config", "metadata-complete", "metadataComplete");
+        digester.addSetProperties("faces-config", "version", "version");
+        // 2.0 specific end
+        // 2.0 config ordering name start
+        digester.addCallMethod("faces-config/name", "setName", 0);
+        digester.addObjectCreate("faces-config/ordering", Ordering.class);
+        digester.addSetNext("faces-config/ordering", "setOrdering");
+        digester.addObjectCreate("faces-config/ordering/before/name", FacesConfigNameSlot.class);
+        digester.addSetNext("faces-config/ordering/before/name", "addBeforeSlot");
+        digester.addCallMethod("faces-config/ordering/before/name", "setName", 0);
+        digester.addObjectCreate("faces-config/ordering/before/others", ConfigOthersSlot.class);
+        digester.addSetNext("faces-config/ordering/before/others", "addBeforeSlot");
+
+        digester.addObjectCreate("faces-config/ordering/after/name", FacesConfigNameSlot.class);
+        digester.addSetNext("faces-config/ordering/after/name", "addAfterSlot");
+        digester.addCallMethod("faces-config/ordering/after/name", "setName", 0);
+        digester.addObjectCreate("faces-config/ordering/after/others", ConfigOthersSlot.class);
+        digester.addSetNext("faces-config/ordering/after/others", "addAfterSlot");
+
+        digester.addObjectCreate("faces-config/absolute-ordering", AbsoluteOrdering.class);
+        digester.addSetNext("faces-config/absolute-ordering", "setAbsoluteOrdering");
+        digester.addObjectCreate("faces-config/absolute-ordering/name", FacesConfigNameSlot.class);
+        digester.addSetNext("faces-config/absolute-ordering/name", "addOrderSlot");
+        digester.addCallMethod("faces-config/absolute-ordering/name", "setName", 0);
+        digester.addObjectCreate("faces-config/absolute-ordering/others", ConfigOthersSlot.class);
+        digester.addSetNext("faces-config/absolute-ordering/others", "addOrderSlot");
+        // 2.0 config ordering name end
+
+        digester.addObjectCreate("faces-config/application", Application.class);
+        digester.addSetNext("faces-config/application", "addApplication");
+        digester.addCallMethod("faces-config/application/action-listener", "addActionListener", 0);
+        digester.addCallMethod("faces-config/application/default-render-kit-id", "addDefaultRenderkitId", 0);
+        digester.addCallMethod("faces-config/application/default-validators", "setDefaultValidatorsPresent");
+        digester.addCallMethod("faces-config/application/default-validators/validator-id", "addDefaultValidatorId", 0);
+        digester.addCallMethod("faces-config/application/message-bundle", "addMessageBundle", 0);
+        digester.addCallMethod("faces-config/application/navigation-handler", "addNavigationHandler", 0);
+        digester.addCallMethod("faces-config/application/partial-traversal", "addPartialTraversal", 0);
+        digester.addCallMethod("faces-config/application/view-handler", "addViewHandler", 0);
+        digester.addCallMethod("faces-config/application/state-manager", "addStateManager", 0);
+        digester.addCallMethod("faces-config/application/property-resolver", "addPropertyResolver", 0);
+        digester.addCallMethod("faces-config/application/variable-resolver", "addVariableResolver", 0);
+        digester.addObjectCreate("faces-config/application/locale-config", LocaleConfig.class);
+        digester.addSetNext("faces-config/application/locale-config", "addLocaleConfig");
+        digester.addCallMethod("faces-config/application/locale-config/default-locale", "setDefaultLocale", 0);
+        digester.addCallMethod("faces-config/application/locale-config/supported-locale", "addSupportedLocale", 0);
+
+        // 1.2 specific start
+        digester.addCallMethod("faces-config/application/el-resolver", "addElResolver", 0);
+        digester.addObjectCreate("faces-config/application/resource-bundle", ResourceBundle.class);
+        digester.addSetNext("faces-config/application/resource-bundle", "addResourceBundle");
+        digester.addCallMethod("faces-config/application/resource-bundle/base-name", "setBaseName", 0);
+        digester.addCallMethod("faces-config/application/resource-bundle/var", "setVar", 0);
+        digester.addCallMethod("faces-config/application/resource-bundle/display-name", "setDisplayName", 0);
+        // 1.2 specific end
+
+        // 2.0 specific start
+        digester.addObjectCreate("faces-config/application/system-event-listener", SystemEventListener.class);
+        digester.addSetNext("faces-config/application/system-event-listener", "addSystemEventListener");
+        digester.addCallMethod("faces-config/application/system-event-listener/system-event-listener-class", "setSystemEventListenerClass", 0);
+        digester.addCallMethod("faces-config/application/system-event-listener/system-event-class", "setSystemEventClass", 0);
+        digester.addCallMethod("faces-config/application/system-event-listener/source-class", "setSourceClass", 0);
+        digester.addCallMethod("faces-config/application/resource-handler", "addResourceHandler", 0);
+        digester.addCallMethod("faces-config/factory/exception-handler-factory", "addExceptionHandlerFactory", 0);
+        digester.addCallMethod("faces-config/factory/external-context-factory", "addExternalContextFactory", 0);
+        digester.addCallMethod("faces-config/factory/view-declaration-language-factory", "addViewDeclarationLanguageFactory", 0);
+        digester.addCallMethod("faces-config/factory/partial-view-context-factory", "addPartialViewContextFactory", 0);
+        digester.addCallMethod("faces-config/factory/tag-handler-delegate-factory", "addTagHandlerDelegateFactory", 0);
+        digester.addCallMethod("faces-config/factory/visit-context-factory", "addVisitContextFactory", 0);
+        // 2.0 specific end
+
+        digester.addObjectCreate("faces-config/factory", Factory.class);
+        digester.addSetNext("faces-config/factory", "addFactory");
+        digester.addCallMethod("faces-config/factory/application-factory", "addApplicationFactory", 0);
+        digester.addCallMethod("faces-config/factory/faces-context-factory", "addFacesContextFactory", 0);
+        digester.addCallMethod("faces-config/factory/lifecycle-factory", "addLifecycleFactory", 0);
+        digester.addCallMethod("faces-config/factory/render-kit-factory", "addRenderkitFactory", 0);
+
+        digester.addCallMethod("faces-config/component", "addComponent", 2);
+        digester.addCallParam("faces-config/component/component-type", 0);
+        digester.addCallParam("faces-config/component/component-class", 1);
+
+        digester.addObjectCreate("faces-config/converter", Converter.class);
+        digester.addSetNext("faces-config/converter", "addConverter");
+        digester.addCallMethod("faces-config/converter/converter-id", "setConverterId", 0);
+        digester.addCallMethod("faces-config/converter/converter-for-class", "setForClass", 0);
+        digester.addCallMethod("faces-config/converter/converter-class", "setConverterClass", 0);
+        digester.addObjectCreate("faces-config/converter/attribute", Attribute.class);
+        digester.addSetNext("faces-config/converter/attribute", "addAttribute");
+        digester.addCallMethod("faces-config/converter/attribute/description", "addDescription", 0);
+        digester.addCallMethod("faces-config/converter/attribute/display-name", "addDisplayName", 0);
+        digester.addCallMethod("faces-config/converter/attribute/icon", "addIcon", 0);
+        digester.addCallMethod("faces-config/converter/attribute/attribute-name", "setAttributeName", 0);
+        digester.addCallMethod("faces-config/converter/attribute/attribute-class", "setAttributeClass", 0);
+        digester.addCallMethod("faces-config/converter/attribute/default-value", "setDefaultValue", 0);
+        digester.addCallMethod("faces-config/converter/attribute/suggested-value", "setSuggestedValue", 0);
+        digester.addCallMethod("faces-config/converter/attribute/attribute-extension", "addAttributeExtension", 0);
+        digester.addObjectCreate("faces-config/converter/property", Property.class);
+        digester.addSetNext("faces-config/converter/property", "addProperty");
+        digester.addCallMethod("faces-config/converter/property/description", "addDescription", 0);
+        digester.addCallMethod("faces-config/converter/property/display-name", "addDisplayName", 0);
+        digester.addCallMethod("faces-config/converter/property/icon", "addIcon", 0);
+        digester.addCallMethod("faces-config/converter/property/property-name", "setPropertyName", 0);
+        digester.addCallMethod("faces-config/converter/property/property-class", "setPropertyClass", 0);
+        digester.addCallMethod("faces-config/converter/property/default-value", "setDefaultValue", 0);
+        digester.addCallMethod("faces-config/converter/property/suggested-value", "setSuggestedValue", 0);
+        digester.addCallMethod("faces-config/converter/property/property-extension", "addPropertyExtension", 0);
+
+        digester.addObjectCreate("faces-config/managed-bean", ManagedBean.class);
+        digester.addSetProperties("faces-config/managed-bean", "eager", "eager");
+        digester.addSetNext("faces-config/managed-bean", "addManagedBean");
+        digester.addCallMethod("faces-config/managed-bean/description", "setDescription", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-bean-name", "setName", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-bean-class", "setBeanClass", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-bean-scope", "setScope", 0);
+        digester.addObjectCreate("faces-config/managed-bean/managed-property", ManagedProperty.class);
+        digester.addSetNext("faces-config/managed-bean/managed-property", "addProperty");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/property-name", "setPropertyName", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-property/property-class", "setPropertyClass", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-property/null-value", "setNullValue");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/value", "setValue", 0);
+        digester.addObjectCreate("faces-config/managed-bean/managed-property/map-entries", MapEntries.class);
+        digester.addSetNext("faces-config/managed-bean/managed-property/map-entries", "setMapEntries");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/map-entries/key-class", "setKeyClass", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-property/map-entries/value-class", "setValueClass", 0);
+        digester.addObjectCreate("faces-config/managed-bean/managed-property/map-entries/map-entry", MapEntries.Entry.class);
+        digester.addSetNext("faces-config/managed-bean/managed-property/map-entries/map-entry", "addEntry");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/map-entries/map-entry/key", "setKey", 0);
+        digester.addCallMethod("faces-config/managed-bean/managed-property/map-entries/map-entry/null-value", "setNullValue");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/map-entries/map-entry/value", "setValue", 0);
+        digester.addObjectCreate("faces-config/managed-bean/managed-property/list-entries", ListEntries.class);
+        digester.addSetNext("faces-config/managed-bean/managed-property/list-entries", "setListEntries");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/list-entries/value-class", "setValueClass", 0);
+        digester.addObjectCreate("faces-config/managed-bean/managed-property/list-entries/null-value", ListEntries.Entry.class);
+        digester.addSetNext("faces-config/managed-bean/managed-property/list-entries/null-value", "addEntry");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/list-entries/null-value", "setNullValue");
+        digester.addObjectCreate("faces-config/managed-bean/managed-property/list-entries/value", ListEntries.Entry.class);
+        digester.addSetNext("faces-config/managed-bean/managed-property/list-entries/value", "addEntry");
+        digester.addCallMethod("faces-config/managed-bean/managed-property/list-entries/value", "setValue", 0);
+        digester.addObjectCreate("faces-config/managed-bean/map-entries", MapEntries.class);
+        digester.addSetNext("faces-config/managed-bean/map-entries", "setMapEntries");
+        digester.addCallMethod("faces-config/managed-bean/map-entries/key-class", "setKeyClass", 0);
+        digester.addCallMethod("faces-config/managed-bean/map-entries/value-class", "setValueClass", 0);
+        digester.addObjectCreate("faces-config/managed-bean/map-entries/map-entry", MapEntries.Entry.class);
+        digester.addSetNext("faces-config/managed-bean/map-entries/map-entry", "addEntry");
+        digester.addCallMethod("faces-config/managed-bean/map-entries/map-entry/key", "setKey", 0);
+        digester.addCallMethod("faces-config/managed-bean/map-entries/map-entry/null-value", "setNullValue");
+        digester.addCallMethod("faces-config/managed-bean/map-entries/map-entry/value", "setValue", 0);
+        digester.addObjectCreate("faces-config/managed-bean/list-entries", ListEntries.class);
+        digester.addSetNext("faces-config/managed-bean/list-entries", "setListEntries");
+        digester.addCallMethod("faces-config/managed-bean/list-entries/value-class", "setValueClass", 0);
+        digester.addObjectCreate("faces-config/managed-bean/list-entries/null-value", ListEntries.Entry.class);
+        digester.addSetNext("faces-config/managed-bean/list-entries/null-value", "addEntry");
+        digester.addCallMethod("faces-config/managed-bean/list-entries/null-value", "setNullValue");
+        digester.addObjectCreate("faces-config/managed-bean/list-entries/value", ListEntries.Entry.class);
+        digester.addSetNext("faces-config/managed-bean/list-entries/value", "addEntry");
+        digester.addCallMethod("faces-config/managed-bean/list-entries/value", "setValue", 0);
+
+        digester.addObjectCreate("faces-config/navigation-rule", NavigationRule.class);
+        digester.addSetNext("faces-config/navigation-rule", "addNavigationRule");
+        digester.addCallMethod("faces-config/navigation-rule/from-view-id", "setFromViewId", 0);
+        digester.addObjectCreate("faces-config/navigation-rule/navigation-case", NavigationCase.class);
+        digester.addSetNext("faces-config/navigation-rule/navigation-case", "addNavigationCase");
+        digester.addCallMethod("faces-config/navigation-rule/navigation-case/from-action", "setFromAction", 0);
+        digester.addCallMethod("faces-config/navigation-rule/navigation-case/from-outcome", "setFromOutcome", 0);
+        digester.addCallMethod("faces-config/navigation-rule/navigation-case/if", "setIf", 0);
+        digester.addCallMethod("faces-config/navigation-rule/navigation-case/to-view-id", "setToViewId", 0);
+        digester.addObjectCreate("faces-config/navigation-rule/navigation-case/redirect", Redirect.class);
+        digester.addSetProperties("faces-config/navigation-rule/navigation-case/redirect", "include-view-params", "includeViewParams");
+        digester.addSetNext("faces-config/navigation-rule/navigation-case/redirect", "setRedirect");
+        digester.addObjectCreate("faces-config/navigation-rule/navigation-case/redirect/view-param", ViewParam.class);
+        digester.addSetNext("faces-config/navigation-rule/navigation-case/redirect/view-param", "addViewParam");
+        digester.addCallMethod("faces-config/navigation-rule/navigation-case/redirect/view-param/name", "setName", 0);
+        digester.addCallMethod("faces-config/navigation-rule/navigation-case/redirect/view-param/value", "setValue", 0);
+
+        digester.addObjectCreate("faces-config/render-kit", RenderKit.class);
+        digester.addSetNext("faces-config/render-kit", "addRenderKit");
+        digester.addCallMethod("faces-config/render-kit/render-kit-id", "setId", 0);
+        //digester.addCallMethod("faces-config/render-kit/render-kit-class", "setRenderKitClass", 0);
+        digester.addCallMethod("faces-config/render-kit/render-kit-class", "addRenderKitClass", 0);
+        digester.addObjectCreate("faces-config/render-kit/renderer", Renderer.class);
+        digester.addSetNext("faces-config/render-kit/renderer", "addRenderer");
+        digester.addCallMethod("faces-config/render-kit/renderer/component-family", "setComponentFamily", 0);
+        digester.addCallMethod("faces-config/render-kit/renderer/renderer-type", "setRendererType", 0);
+        digester.addCallMethod("faces-config/render-kit/renderer/renderer-class", "setRendererClass", 0);
+        digester.addObjectCreate("faces-config/render-kit/client-behavior-renderer", ClientBehaviorRenderer.class);
+        digester.addSetNext("faces-config/render-kit/client-behavior-renderer", "addClientBehaviorRenderer");
+        digester.addCallMethod("faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-type", "setRendererType", 0);
+        digester.addCallMethod("faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-class", "setRendererClass", 0);
+
+        // 2.0 behavior start
+        digester.addObjectCreate("faces-config/behavior", Behavior.class);
+        digester.addSetNext("faces-config/behavior", "addBehavior");
+        digester.addCallMethod("faces-config/behavior/behavior-id", "setBehaviorId", 0);
+        digester.addCallMethod("faces-config/behavior/behavior-class", "setBehaviorClass", 0);
+        digester.addObjectCreate("faces-config/behavior/attribute", Attribute.class);
+        digester.addSetNext("faces-config/behavior/attribute", "addAttribute");
+        digester.addCallMethod("faces-config/behavior/attribute/description", "addDescription", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/display-name", "addDisplayName", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/icon", "addIcon", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/attribute-name", "setAttributeName", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/attribute-class", "setAttributeClass", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/default-value", "setDefaultValue", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/suggested-value", "setSuggestedValue", 0);
+        digester.addCallMethod("faces-config/behavior/attribute/attribute-extension", "addAttributeExtension", 0);
+        digester.addObjectCreate("faces-config/behavior/property", Property.class);
+        digester.addSetNext("faces-config/behavior/property", "addProperty");
+        digester.addCallMethod("faces-config/behavior/property/description", "addDescription", 0);
+        digester.addCallMethod("faces-config/behavior/property/display-name", "addDisplayName", 0);
+        digester.addCallMethod("faces-config/behavior/property/icon", "addIcon", 0);
+        digester.addCallMethod("faces-config/behavior/property/property-name", "setPropertyName", 0);
+        digester.addCallMethod("faces-config/behavior/property/property-class", "setPropertyClass", 0);
+        digester.addCallMethod("faces-config/behavior/property/default-value", "setDefaultValue", 0);
+        digester.addCallMethod("faces-config/behavior/property/suggested-value", "setSuggestedValue", 0);
+        digester.addCallMethod("faces-config/behavior/property/property-extension", "addPropertyExtension", 0);
+        // 2.0 behavior end
+
+        digester.addCallMethod("faces-config/lifecycle/phase-listener", "addLifecyclePhaseListener", 0);
+
+        digester.addCallMethod("faces-config/validator", "addValidator", 2);
+        digester.addCallParam("faces-config/validator/validator-id", 0);
+        digester.addCallParam("faces-config/validator/validator-class", 1);
+    }
+
+    public FacesConfig getFacesConfig(InputStream in, String systemId) throws IOException, SAXException {
+        InputSource is = new InputSource(in);
+        is.setSystemId(systemId);
+
+        // Fix for http://issues.apache.org/jira/browse/MYFACES-236
+        FacesConfig config = (FacesConfig) digester.parse(is);
+
+        for (org.apache.myfaces.config.element.Application application : config.getApplications()) {
+            for (org.apache.myfaces.config.element.LocaleConfig localeConfig : application.getLocaleConfig()) {
+                if (!localeConfig.getSupportedLocales().contains(localeConfig.getDefaultLocale())) {
+                    localeConfig.getSupportedLocales().add(localeConfig.getDefaultLocale());
+                }
+            }
+        }
+
+        return config;
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/FacesConfigDigester.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java?rev=1048917&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java (added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java Tue Dec 14 03:13:09 2010
@@ -0,0 +1,90 @@
+/**
+ *  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.geronimo.myfaces;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.myfaces.spi.ServiceProviderFinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Service provider finder is used to find those SPI factory classes, currently, we use a static fixed map to hold the default provider
+ * classes, might need to provider methods for registering new providers.
+ * @version $Rev$ $Date$
+ */
+public class GeronimoServiceProviderFinder extends ServiceProviderFinder {
+
+    private static final Logger logger = LoggerFactory.getLogger(GeronimoServiceProviderFinder.class);
+
+    private Map<String, List<String>> spiProvidersMap = new HashMap<String, List<String>>();
+
+    private static final String META_INF_SERVICE_PREFIX = "META-INF/services";
+
+    private ClassLoader classLoader;
+
+    public GeronimoServiceProviderFinder(Map<String, List<String>> spiProvidersMap, ClassLoader classLoader) {
+        this.classLoader = classLoader;
+        this.spiProvidersMap = spiProvidersMap;
+    }
+
+    @Override
+    public List<String> getServiceProviderList(String spiClass) {
+        List<String> providers = spiProvidersMap.get(spiClass);
+        return providers == null ? searchByClassLoader(spiClass) : providers;
+    }
+
+    private List<String> searchByClassLoader(String spiClass) {
+        Enumeration<URL> en;
+        try {
+            en = classLoader.getResources(META_INF_SERVICE_PREFIX + "/" + spiClass);
+        } catch (IOException e) {
+            logger.warn("Fail to scan META-INF/services/" + spiClass, e);
+            return Collections.<String> emptyList();
+        }
+        List<String> spiProviderClasses = new ArrayList<String>();
+        while (en.hasMoreElements()) {
+            BufferedReader bufferedReader = null;
+            try {
+                bufferedReader = new BufferedReader(new InputStreamReader(en.nextElement().openStream(), "UTF-8"));
+                String line = null;
+                while ((line = bufferedReader.readLine()) != null) {
+                    line = line.trim();
+                    if (!line.isEmpty() && !line.startsWith("#")) {
+                        spiProviderClasses.add(line);
+                    }
+                }
+            } catch (IOException e) {
+                logger.warn("Fail to scan META-INF/services/" + spiClass, e);
+            } finally {
+                IOUtils.close(bufferedReader);
+            }
+        }
+        return spiProviderClasses;
+    }
+}

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoServiceProviderFinder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java?rev=1048917&r1=1048916&r2=1048917&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java Tue Dec 14 03:13:09 2010
@@ -73,6 +73,10 @@ public class Activator implements Bundle
         registryRegistration.unregister();
 	}
 
+    public BundleContext getBundleContext() {
+        return context;
+    }
+
 	void log(int level, String message) {
 	    synchronized (logServices) {
 	        for (LogService log : logServices) {

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java?rev=1048917&r1=1048916&r2=1048917&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java Tue Dec 14 03:13:09 2010
@@ -20,7 +20,6 @@ package org.apache.geronimo.myfaces.conf
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
-import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.BundleTrackerCustomizer;
 

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java?rev=1048917&r1=1048916&r2=1048917&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java Tue Dec 14 03:13:09 2010
@@ -20,15 +20,27 @@
 
 package org.apache.geronimo.myfaces.config.resource.osgi;
 
+import java.io.InputStream;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.myfaces.FacesConfigDigester;
 import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
+import org.apache.geronimo.system.configuration.DependencyManager;
+import org.apache.myfaces.config.element.FacesConfig;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
 
+
 /**
  * @version $Rev:$ $Date:$
  */
@@ -37,6 +49,10 @@ public class ConfigRegistryImpl implemen
 
     private final Set<URL> urls = new HashSet<URL>();
 
+    private Map<Long, FacesConfig> bundleIdFacesConfigMap = new ConcurrentHashMap<Long, FacesConfig>();
+
+    private FacesConfigDigester facesConfigDigester = new FacesConfigDigester();
+
     public ConfigRegistryImpl(Activator activator) {
         this.activator = activator;
     }
@@ -47,6 +63,14 @@ public class ConfigRegistryImpl implemen
         if (url != null) {
             log(LogService.LOG_DEBUG, "found META-INF/faces-config.xml");
             urls.add(url);
+            InputStream in = null;
+            try {
+                in = url.openStream();
+                bundleIdFacesConfigMap.put(bundle.getBundleId(), facesConfigDigester.getFacesConfig(in, url.toExternalForm()));
+            } catch (Exception e) {
+            } finally {
+                IOUtils.close(in);
+            }
         }
         return url;
     }
@@ -54,8 +78,9 @@ public class ConfigRegistryImpl implemen
     public void removeBundle(Bundle bundle, Object object) {
         log(LogService.LOG_DEBUG, "unregistering bundle for META-INF/faces-config.xml " + bundle.getSymbolicName() + " url: " + object);
         if (object != null) {
-            urls.remove((URL)object);
+            urls.remove(object);
         }
+        bundleIdFacesConfigMap.remove(bundle.getBundleId());
     }
 
     @Override
@@ -63,6 +88,36 @@ public class ConfigRegistryImpl implemen
         return Collections.unmodifiableSet(urls);
     }
 
+    public Set<URL> getDependentConfigUrls(Bundle bundle) {
+        return null;
+    }
+
+    public List<FacesConfig> getDependentFacesConfigs(Bundle bundle) {
+        BundleContext bundleContext = activator.getBundleContext();
+        ServiceReference serviceReference = null;
+        try {
+            serviceReference = bundleContext.getServiceReference(DependencyManager.class.getName());
+            if (serviceReference == null) {
+                return Collections.<FacesConfig> emptyList();
+            }
+            DependencyManager dependencyManager = (DependencyManager) bundleContext.getService(serviceReference);
+            List<Bundle> dependentBundles = dependencyManager.getDependentBundles(bundle);
+            List<FacesConfig> dependentFacesConfigs = new ArrayList<FacesConfig>();
+            for (Bundle dependentBundle : dependentBundles) {
+                FacesConfig facesConfig = bundleIdFacesConfigMap.get(dependentBundle.getBundleId());
+                if (facesConfig != null) {
+                    dependentFacesConfigs.add(facesConfig);
+                }
+            }
+            return dependentFacesConfigs;
+        } finally {
+            if (serviceReference != null) {
+                bundleContext.ungetService(serviceReference);
+            }
+        }
+    }
+
+
     private void log(int level, String message) {
         activator.log(level, message);
     }



Mime
View raw message