FAQ
Hi Leo,

In this commit you add a class called AnnotationProviderWrapper, which
extends AnnotationProvider and implements
FacesWrapper<AnnotationProvider>.

However, AnnotationProvider itself does already implement
FacesWrapper<AnnotationProvider>, although not delegating to the
wrapped AnnotationProvider. With the AnnotationProviderWrapper in
place, it makes no sense to me to have AnnotationProvider implementing
FacesWrapper<AnnotationProvider>. Actually, it confused me.

IMO AnnotationProvider should not implement
FacesWrapper<AnnotationProvider>. wdyt?

Regards,
Jakob

2010/12/7 <lu4242@apache.org>:
Author: lu4242
Date: Tue Dec  7 18:03:04 2010
New Revision: 1043151

URL: http://svn.apache.org/viewvc?rev=1043151&view=rev
Log:
MYFACES-2945 Make a way to get the FacesConfig from a provider

Added:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java Tue Dec  7 18:03:04 2010
@@ -18,10 +18,8 @@
*/
package org.apache.myfaces.config;

-import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
@@ -59,6 +57,7 @@ import org.apache.myfaces.shared_impl.ut
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.spi.ServiceProviderFinderFactory;
import org.xml.sax.SAXException;

@@ -72,7 +71,7 @@ public class DefaultFacesConfigurationPr

private static final String STANDARD_FACES_CONFIG_RESOURCE = "META-INF/standard-faces-config.xml";

-    private static final String META_INF_SERVICES_RESOURCE_PREFIX = "META-INF/services/";
+    //private static final String META_INF_SERVICES_RESOURCE_PREFIX = "META-INF/services/";

private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";

@@ -96,8 +95,6 @@ public class DefaultFacesConfigurationPr

private AnnotationConfigurator _annotationConfigurator;

-    private FacesConfigDispenser _dispenser;
-
protected void setUnmarshaller(ExternalContext ectx, FacesConfigUnmarshaller<? extends FacesConfig> unmarshaller)
{
_unmarshaller = unmarshaller;
@@ -113,28 +110,6 @@ public class DefaultFacesConfigurationPr
return _unmarshaller;
}

-    /**
-     * @param dispenser
-     *            the dispenser to set
-     */
-    protected void setDispenser(FacesConfigDispenser dispenser)
-    {
-        _dispenser = dispenser;
-    }
-
-    /**
-     * @return the dispenser
-     */
-    protected FacesConfigDispenser getDispenser()
-    {
-        if (_dispenser == null)
-        {
-            _dispenser = new DigesterFacesConfigDispenserImpl();
-        }
-
-        return _dispenser;
-    }
-
protected void setAnnotationConfigurator(AnnotationConfigurator configurator)
{
_annotationConfigurator = configurator;
@@ -149,8 +124,8 @@ public class DefaultFacesConfigurationPr
return _annotationConfigurator;
}

-
-    protected FacesConfig getStandardFacesConfig(ExternalContext ectx)
+    @Override
+    public FacesConfig getStandardFacesConfig(ExternalContext ectx)
{
try
{
@@ -182,8 +157,8 @@ public class DefaultFacesConfigurationPr
}
}

-
-    protected FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete)
+    @Override
+    public FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete)
{
return getAnnotationConfigurator().createFacesConfig(ectx, metadataComplete);
}
@@ -191,7 +166,8 @@ public class DefaultFacesConfigurationPr
/**
* This method performs part of the factory search outlined in section 10.2.6.1.
*/
-    protected FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
+    @Override
+    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
{
try
{
@@ -201,7 +177,7 @@ public class DefaultFacesConfigurationPr

for (String factoryName : FACTORY_NAMES)
{
-                List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(ectx).getServiceProviderList(factoryName);
+                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx).getServiceProviderList(factoryName);

for (String className : classList)
{
@@ -255,7 +231,8 @@ public class DefaultFacesConfigurationPr
/**
* This method fixes MYFACES-208
*/
-    protected List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx)
+    @Override
+    public List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx)
{
List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
try
@@ -298,7 +275,8 @@ public class DefaultFacesConfigurationPr
return appConfigResources;
}

-    protected List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
+    @Override
+    public List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
{
List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
try
@@ -365,7 +343,7 @@ public class DefaultFacesConfigurationPr
return configFilesList;
}

-    protected FacesConfig getWebAppFacesConfig(ExternalContext ectx)
+    public FacesConfig getWebAppFacesConfig(ExternalContext ectx)
{
try
{
@@ -410,7 +388,7 @@ public class DefaultFacesConfigurationPr
}
}

-    protected void orderAndFeedArtifacts(List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
+    protected void orderAndFeedArtifacts(FacesConfigDispenser dispenser, List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
throws FacesException
{
if (webAppConfig != null && webAppConfig.getAbsoluteOrdering() != null)
@@ -451,7 +429,7 @@ public class DefaultFacesConfigurationPr
//Add all mentioned in othersResources
for (FacesConfig resource : othersResources)
{
-                        getDispenser().feed(resource);
+                        dispenser.feed(resource);
}
}
else
@@ -463,7 +441,7 @@ public class DefaultFacesConfigurationPr
FacesConfig targetFacesConfig = getFacesConfig(appConfigResources, nameSlot.getName());
if (targetFacesConfig != null)
{
-                        getDispenser().feed(targetFacesConfig);
+                        dispenser.feed(targetFacesConfig);
}
}
}
@@ -498,13 +476,13 @@ public class DefaultFacesConfigurationPr
for (FacesConfig resource : sortedList)
{
//Feed
-                getDispenser().feed(resource);
+                dispenser.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);
+            dispenser.feed(webAppConfig);
}
}

@@ -1363,13 +1341,17 @@ public class DefaultFacesConfigurationPr
{
boolean metadataComplete = false;

-        setDispenser(new DigesterFacesConfigDispenserImpl());
+        FacesConfigurationProvider provider = FacesConfigurationProviderFactory.
+            getFacesConfigurationProviderFactory(_externalContext).
+                getFacesConfigurationProvider(_externalContext);
+
+        FacesConfigDispenser dispenser = new DigesterFacesConfigDispenserImpl();
//1. Feed standard-faces-config.xml first.
-        getDispenser().feed(getStandardFacesConfig(_externalContext));
+        dispenser.feed(provider.getStandardFacesConfig(_externalContext));

-        getDispenser().feed(getMetaInfServicesFacesConfig(_externalContext));
+        dispenser.feed(provider.getMetaInfServicesFacesConfig(_externalContext));

-        FacesConfig webAppFacesConfig = getWebAppFacesConfig(_externalContext);
+        FacesConfig webAppFacesConfig = provider.getWebAppFacesConfig(_externalContext);

//read metadata-complete attribute on WEB-INF/faces-config.xml
if(webAppFacesConfig != null)
@@ -1382,21 +1364,21 @@ public class DefaultFacesConfigurationPr
//metadata-complete can only be specified in faces-config.xml per the JSF 2.0 schema
}

-        FacesConfig annotationFacesConfig = getAnnotationsFacesConfig(_externalContext, metadataComplete);
+        FacesConfig annotationFacesConfig = provider.getAnnotationsFacesConfig(_externalContext, metadataComplete);

if (annotationFacesConfig != null)
{
-            getDispenser().feed(annotationFacesConfig);
+            dispenser.feed(annotationFacesConfig);
}

List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();

-        appConfigResources.addAll(getClassloaderFacesConfig(_externalContext));
-        appConfigResources.addAll(getContextSpecifiedFacesConfig(_externalContext));
+        appConfigResources.addAll(provider.getClassloaderFacesConfig(_externalContext));
+        appConfigResources.addAll(provider.getContextSpecifiedFacesConfig(_externalContext));

-        orderAndFeedArtifacts(appConfigResources,webAppFacesConfig);
+        orderAndFeedArtifacts(dispenser, appConfigResources,webAppFacesConfig);

-        return getDispenser();
+        return dispenser;
}



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=1043151&r1=1043150&r2=1043151&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 Tue Dec  7 18:03:04 2010
@@ -26,9 +26,6 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.CustomScoped;
import javax.faces.bean.ManagedBean;
@@ -42,17 +39,11 @@ import javax.faces.context.ExternalConte
import javax.faces.convert.FacesConverter;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.NamedEvent;
-import javax.faces.render.ClientBehaviorRenderer;
import javax.faces.render.FacesBehaviorRenderer;
import javax.faces.render.FacesRenderer;
-import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
import javax.faces.validator.FacesValidator;

-import org.apache.myfaces.config.FacesConfigDispenser;
-import org.apache.myfaces.config.NamedEventManager;
-import org.apache.myfaces.config.RuntimeConfig;
import org.apache.myfaces.config.impl.digester.elements.Behavior;
import org.apache.myfaces.config.impl.digester.elements.Converter;
import org.apache.myfaces.config.impl.digester.elements.FacesConfig;
@@ -97,7 +88,7 @@ public class AnnotationConfigurator
{
if (!metadataComplete)
{
-            AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(_externalContext).createAnnotationProvider(_externalContext);
+            AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(_externalContext).getAnnotationProvider(_externalContext);
Map<Class<? extends Annotation>,Set<Class<?>>> map = provider.getAnnotatedClasses(_externalContext);
return createFacesConfig(map);
}

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java Tue Dec  7 18:03:04 2010
@@ -52,6 +52,7 @@ import javax.faces.validator.FacesValida
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
import org.apache.myfaces.shared_impl.util.ClassUtils;
import org.apache.myfaces.spi.AnnotationProvider;
+import org.apache.myfaces.spi.AnnotationProviderFactory;
import org.apache.myfaces.view.facelets.util.Classpath;

/**
@@ -165,7 +166,8 @@ public class DefaultAnnotationProvider e
//2. Scan for annotations on classpath
try
{
-            classes = getAnnotatedMetaInfClasses(ctx, getBaseUrls());
+            AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(ctx).getAnnotationProvider(ctx);
+            classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls());
}
catch (IOException e)
{

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -156,7 +156,7 @@ public class DefaultLifecycleProviderFac
InvocationTargetException,
PrivilegedActionException
{
-                                List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
+                                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
Iterator<String> iter = classList.iterator();
while (iter.hasNext())
{
@@ -178,7 +178,7 @@ public class DefaultLifecycleProviderFac
}
else
{
-                List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
+                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
Iterator<String> iter = classList.iterator();
while (iter.hasNext())
{

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -84,4 +84,9 @@ public abstract class AnnotationProvider
}

public abstract AnnotationProvider createAnnotationProvider(ExternalContext externalContext);
+
+    public AnnotationProvider getAnnotationProvider(ExternalContext externalContext)
+    {
+        return createAnnotationProvider(externalContext);
+    }
}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java?rev=1043151&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java Tue Dec  7 18:03:04 2010
@@ -0,0 +1,54 @@
+/*
+ * 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.spi;
+
+import java.io.IOException;
+import java.io.ObjectInputStream.GetField;
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesWrapper;
+import javax.faces.context.ExternalContext;
+
+/**
+ *
+ * @since 2.0.3
+ * @author Leonardo Uribe
+ */
+public abstract class AnnotationProviderWrapper extends AnnotationProvider implements FacesWrapper<AnnotationProvider>
+{
+
+    public AnnotationProviderWrapper()
+    {
+
+    }
+
+    public Map<Class<? extends Annotation>,Set<Class<?>>> getAnnotatedClasses(ExternalContext ctx)
+    {
+        return getWrapped().getAnnotatedClasses(ctx);
+    }
+
+    public Set<URL> getBaseUrls() throws IOException
+    {
+        return getWrapped().getBaseUrls();
+    }
+
+}

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java Tue Dec  7 18:03:04 2010
@@ -18,8 +18,11 @@
*/
package org.apache.myfaces.spi;

+import java.util.List;
+
import javax.faces.context.ExternalContext;

+import org.apache.myfaces.config.element.FacesConfig;
import org.apache.myfaces.config.element.FacesConfigData;

/**
@@ -29,12 +32,65 @@ import org.apache.myfaces.config.element
* this information, preventing calculate it over and over each time the web application
* is started.
*
+ * <p>To wrap the default FacesConfigurationProvider, use a constructor like
+ * CustomFacesConfigurationProvider(FacesConfigurationProvider fcp)</p>
+ *
* @author Leonardo Uribe
* @since 2.0.3
*
*/
public abstract class FacesConfigurationProvider
{
+    /**
+     * Return the FacesConfig object model retrieved from MyFaces META-INF/standard-faces-config.xml file.
+     *
+     * @param ectx
+     * @return
+     */
+    public abstract FacesConfig getStandardFacesConfig(ExternalContext ectx);
+
+    /**
+     * Return the FacesConfig object model retrieved from locate all JSF factories from META-INF/services/[factory_key].
+     *
+     * The default implementation uses ServiceProviderFinder facilities to locate this SPI interfaces.
+     *
+     * @param ectx
+     * @return
+     */
+    public abstract FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx);
+
+    /**
+     * Return the FacesConfig object model retrieved from scanning annotations on the classpath.
+     *
+     * @param ectx
+     * @param metadataComplete
+     * @return
+     */
+    public abstract FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete);
+
+    /**
+     * Return the FacesConfig object model retrieved from resources under the path META-INF/faces-config.xml and META-INF/[prefix].faces-config.xml
+     *
+     * @param ectx
+     * @return
+     */
+    public abstract List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx);
+
+    /**
+     * Return the FacesConfig object model retrieved from javax.faces.CONFIG_FILES web config attribute
+     *
+     * @param ectx
+     * @return
+     */
+    public abstract List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx);
+
+    /**
+     * Return the FacesConfig object model retrieved from WEB-INF/faces-config.xml
+     *
+     * @param ectx
+     * @return
+     */
+    public abstract FacesConfig getWebAppFacesConfig(ExternalContext ectx);

/**
* Returns an object that collect all config information used by MyFaces

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java?rev=1043151&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java Tue Dec  7 18:03:04 2010
@@ -0,0 +1,79 @@
+/*
+ * 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.spi;
+
+import java.util.List;
+
+import javax.faces.FacesWrapper;
+import javax.faces.context.ExternalContext;
+
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.config.element.FacesConfigData;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class FacesConfigurationProviderWrapper
+    extends FacesConfigurationProvider
+    implements FacesWrapper<FacesConfigurationProvider>
+{
+
+    public FacesConfigurationProviderWrapper()
+    {
+
+    }
+
+    public FacesConfig getStandardFacesConfig(ExternalContext ectx)
+    {
+        return getWrapped().getStandardFacesConfig(ectx);
+    }
+
+    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
+    {
+        return getWrapped().getMetaInfServicesFacesConfig(ectx);
+    }
+
+    public FacesConfig getAnnotationsFacesConfig(ExternalContext ectx,
+            boolean metadataComplete)
+    {
+        return getWrapped().getAnnotationsFacesConfig(ectx, metadataComplete);
+    }
+
+    public List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx)
+    {
+        return getWrapped().getClassloaderFacesConfig(ectx);
+    }
+
+    public List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
+    {
+        return getWrapped().getContextSpecifiedFacesConfig(ectx);
+    }
+
+    public FacesConfig getWebAppFacesConfig(ExternalContext ectx)
+    {
+        return getWrapped().getWebAppFacesConfig(ectx);
+    }
+
+    public FacesConfigData getFacesConfigData(ExternalContext ectx)
+    {
+        return getWrapped().getFacesConfigData(ectx);
+    }
+}

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java Tue Dec  7 18:03:04 2010
@@ -46,16 +46,16 @@ public class ServiceProviderFinderFactor
* @param ectx
* @return
*/
-    public static ServiceProviderFinder getServiceLoaderFinder(ExternalContext ectx)
+    public static ServiceProviderFinder getServiceProviderFinder(ExternalContext ectx)
{
ServiceProviderFinder slp = (ServiceProviderFinder) ectx.getApplicationMap().get(SERVICE_PROVIDER_KEY);
if (slp == null)
{
-            slp = _getServiceLoaderFinderFromInitParam(ectx);
+            slp = _getServiceProviderFinderFromInitParam(ectx);
if (slp == null)
{
slp = new DefaultServiceProviderFinder();
-                setServiceLoaderFinder(ectx, slp);
+                setServiceProviderFinder(ectx, slp);
}
}
return slp;
@@ -73,12 +73,12 @@ public class ServiceProviderFinderFactor
* @param ectx
* @param slp
*/
-    public static void setServiceLoaderFinder(ExternalContext ectx, ServiceProviderFinder slp)
+    public static void setServiceProviderFinder(ExternalContext ectx, ServiceProviderFinder slp)
{
ectx.getApplicationMap().put(SERVICE_PROVIDER_KEY, slp);
}

-    public static void setServiceLoaderFinder(ServletContext ctx, ServiceProviderFinder slp)
+    public static void setServiceProviderFinder(ServletContext ctx, ServiceProviderFinder slp)
{
ctx.setAttribute(SERVICE_PROVIDER_KEY, slp);
}
@@ -88,7 +88,7 @@ public class ServiceProviderFinderFactor
* @param context
* @return
*/
-    private static ServiceProviderFinder _getServiceLoaderFinderFromInitParam(ExternalContext context)
+    private static ServiceProviderFinder _getServiceProviderFinderFromInitParam(ExternalContext context)
{
String initializerClassName = context.getInitParameter(SERVICE_PROVIDER_FINDER_PARAM);
if (initializerClassName != null)
@@ -100,7 +100,7 @@ public class ServiceProviderFinderFactor
if (!ServiceProviderFinder.class.isAssignableFrom(clazz))
{
throw new FacesException("Class " + clazz
-                            + " does not implement FacesInitializer");
+                            + " does not implement ServiceProviderFinder");
}

// create instance and return it
@@ -108,7 +108,7 @@ public class ServiceProviderFinderFactor
}
catch (ClassNotFoundException cnfe)
{
-                throw new FacesException("Could not find class of specified FacesInitializer", cnfe);
+                throw new FacesException("Could not find class of specified ServiceProviderFinder", cnfe);
}
}
return null;

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -44,12 +44,26 @@ public class DefaultAnnotationProviderFa

public static final String ANNOTATION_PROVIDER_LIST = AnnotationProvider.class.getName()+".LIST";

+    public static final String ANNOTATION_PROVIDER_INSTANCE = AnnotationProvider.class.getName()+".INSTANCE";
+
private Logger getLogger()
{
return Logger.getLogger(DefaultAnnotationProviderFactory.class.getName());
}

@Override
+    public AnnotationProvider getAnnotationProvider(ExternalContext externalContext)
+    {
+        AnnotationProvider annotationProvider = (AnnotationProvider) externalContext.getApplicationMap().get(ANNOTATION_PROVIDER_INSTANCE);
+        if (annotationProvider == null)
+        {
+            annotationProvider = createAnnotationProvider(externalContext);
+            externalContext.getApplicationMap().put(ANNOTATION_PROVIDER_INSTANCE, annotationProvider);
+        }
+        return annotationProvider;
+    }
+
+    @Override
public AnnotationProvider createAnnotationProvider(
ExternalContext externalContext)
{
@@ -115,7 +129,7 @@ public class DefaultAnnotationProviderFa
List<String> classList = (List<String>) externalContext.getApplicationMap().get(ANNOTATION_PROVIDER_LIST);
if (classList == null)
{
-            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(ANNOTATION_PROVIDER);
+            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(ANNOTATION_PROVIDER);
externalContext.getApplicationMap().put(ANNOTATION_PROVIDER_LIST, classList);
}
return SpiUtils.buildApplicationObject(externalContext, AnnotationProvider.class, classList, new DefaultAnnotationProvider());

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -115,7 +115,7 @@ public class DefaultFaceletConfigResourc
List<String> classList = (List<String>) externalContext.getApplicationMap().get(FACELET_CONFIG_PROVIDER_LIST);
if (classList == null)
{
-            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(FACELET_CONFIG_PROVIDER);
+            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(FACELET_CONFIG_PROVIDER);
externalContext.getApplicationMap().put(FACELET_CONFIG_PROVIDER_LIST, classList);
}


Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -115,7 +115,7 @@ public class DefaultFacesConfigResourceP
List<String> classList = (List<String>) externalContext.getApplicationMap().get(FACES_CONFIG_PROVIDER_LIST);
if (classList == null)
{
-            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(FACES_CONFIG_PROVIDER);
+            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(FACES_CONFIG_PROVIDER);
externalContext.getApplicationMap().put(FACES_CONFIG_PROVIDER_LIST, classList);
}


Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -44,6 +44,8 @@ public class DefaultFacesConfigurationPr
public static final String FACES_CONFIGURATION_PROVIDER = FacesConfigurationProvider.class.getName();

public static final String FACES_CONFIGURATION_PROVIDER_LIST = FacesConfigurationProvider.class.getName()+".LIST";
+
+    public static final String FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY = FacesConfigurationProvider.class.getName() + ".INSTANCE";

private Logger getLogger()
{
@@ -54,54 +56,59 @@ public class DefaultFacesConfigurationPr
public FacesConfigurationProvider getFacesConfigurationProvider(
ExternalContext externalContext)
{
-        FacesConfigurationProvider returnValue = null;
-        final ExternalContext extContext = externalContext;
-        try
+        FacesConfigurationProvider returnValue = (FacesConfigurationProvider) externalContext.getApplicationMap().get(FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY);
+        if (returnValue == null)
{
-            if (System.getSecurityManager() != null)
+            final ExternalContext extContext = externalContext;
+            try
{
-                returnValue = AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<FacesConfigurationProvider>()
-                        {
-                            public FacesConfigurationProvider run() throws ClassNotFoundException,
-                                    NoClassDefFoundError,
-                                    InstantiationException,
-                                    IllegalAccessException,
-                                    InvocationTargetException,
-                                    PrivilegedActionException
+                if (System.getSecurityManager() != null)
+                {
+                    returnValue = AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<FacesConfigurationProvider>()
{
-                                return resolveFacesConfigurationProviderFromService(extContext);
-                            }
-                        });
+                                public FacesConfigurationProvider run() throws ClassNotFoundException,
+                                        NoClassDefFoundError,
+                                        InstantiationException,
+                                        IllegalAccessException,
+                                        InvocationTargetException,
+                                        PrivilegedActionException
+                                {
+                                    return resolveFacesConfigurationProviderFromService(extContext);
+                                }
+                            });
+                }
+                else
+                {
+                    returnValue = resolveFacesConfigurationProviderFromService(extContext);
+                }
+                externalContext.getApplicationMap().put(FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY, returnValue);
}
-            else
+            catch (ClassNotFoundException e)
{
-                returnValue = resolveFacesConfigurationProviderFromService(extContext);
+                // ignore
+            }
+            catch (NoClassDefFoundError e)
+            {
+                // ignore
+            }
+            catch (InstantiationException e)
+            {
+                getLogger().log(Level.SEVERE, "", e);
+            }
+            catch (IllegalAccessException e)
+            {
+                getLogger().log(Level.SEVERE, "", e);
+            }
+            catch (InvocationTargetException e)
+            {
+                getLogger().log(Level.SEVERE, "", e);
+            }
+            catch (PrivilegedActionException e)
+            {
+                throw new FacesException(e);
}
}
-        catch (ClassNotFoundException e)
-        {
-            // ignore
-        }
-        catch (NoClassDefFoundError e)
-        {
-            // ignore
-        }
-        catch (InstantiationException e)
-        {
-            getLogger().log(Level.SEVERE, "", e);
-        }
-        catch (IllegalAccessException e)
-        {
-            getLogger().log(Level.SEVERE, "", e);
-        }
-        catch (InvocationTargetException e)
-        {
-            getLogger().log(Level.SEVERE, "", e);
-        }
-        catch (PrivilegedActionException e)
-        {
-            throw new FacesException(e);
-        }
+

return returnValue;
}
@@ -117,7 +124,7 @@ public class DefaultFacesConfigurationPr
List<String> classList = (List<String>) externalContext.getApplicationMap().get(FACES_CONFIGURATION_PROVIDER_LIST);
if (classList == null)
{
-            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(FACES_CONFIGURATION_PROVIDER);
+            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(FACES_CONFIGURATION_PROVIDER);
externalContext.getApplicationMap().put(FACES_CONFIGURATION_PROVIDER_LIST, classList);
}


Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java Tue Dec  7 18:03:04 2010
@@ -119,7 +119,7 @@ public class DefaultWebConfigProviderFac
List<String> classList = (List<String>) externalContext.getApplicationMap().get(WEB_CONFIG_PROVIDER_LIST);
if (classList == null)
{
-            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(WEB_CONFIG_PROVIDER);
+            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(WEB_CONFIG_PROVIDER);
externalContext.getApplicationMap().put(WEB_CONFIG_PROVIDER_LIST, classList);
}


Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java?rev=1043151&r1=1043150&r2=1043151&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java Tue Dec  7 18:03:04 2010
@@ -38,7 +38,7 @@ public final class SpiUtils

public static Object build(ExternalContext ectx, Class spiClass, String defaultImpl)
{
-        List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(ectx).getServiceProviderList(spiClass.getName());
+        List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx).getServiceProviderList(spiClass.getName());

if (classList != null && !classList.isEmpty())
{
@@ -54,7 +54,7 @@ public final class SpiUtils

public static <T> T buildApplicationObject(ExternalContext ectx, Class<T> interfaceClass, T defaultObject)
{
-        List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(ectx).getServiceProviderList(interfaceClass.getName());
+        List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx).getServiceProviderList(interfaceClass.getName());

if (classList != null && !classList.isEmpty())
{



--
Jakob Korherr

blog: http://www.jakobk.com
twitter: http://twitter.com/jakobkorherr
work: http://www.irian.at

Search Discussions

  • Jakob Korherr at Dec 8, 2010 at 1:38 pm
    Hi Leo,

    Thinking more about it, I see some problems here:

    All SPI factory classes except AnnotationProviderFactory and
    FacesConfigurationProviderFactory use
    ClassUtils.buildApplicationObject() in order to support a wrapping via
    constructor. However, those two use SpiUtils.build(), which allows no
    wrapping at all, because it only uses the first possible SPI
    implementation.

    IMHO AnnotationProviderFactory and FacesConfigurationProviderFactory
    should also use ClassUtils.buildApplicationObject() in order to even
    support wrapping!

    Regards,
    Jakob

    2010/12/8 Jakob Korherr <jakob.korherr@gmail.com>:
    Hi Leo,

    In this commit you add a class called AnnotationProviderWrapper, which
    extends AnnotationProvider and implements
    FacesWrapper<AnnotationProvider>.

    However, AnnotationProvider itself does already implement
    FacesWrapper<AnnotationProvider>, although not delegating to the
    wrapped AnnotationProvider. With the AnnotationProviderWrapper in
    place, it makes no sense to me to have AnnotationProvider implementing
    FacesWrapper<AnnotationProvider>. Actually, it confused me.

    IMO AnnotationProvider should not implement
    FacesWrapper<AnnotationProvider>. wdyt?

    Regards,
    Jakob

    2010/12/7  <lu4242@apache.org>:
    Author: lu4242
    Date: Tue Dec  7 18:03:04 2010
    New Revision: 1043151

    URL: http://svn.apache.org/viewvc?rev=1043151&view=rev
    Log:
    MYFACES-2945 Make a way to get the FacesConfig from a provider

    Added:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java
    Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java Tue Dec  7 18:03:04 2010
    @@ -18,10 +18,8 @@
    */
    package org.apache.myfaces.config;

    -import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    -import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.ArrayList;
    @@ -59,6 +57,7 @@ import org.apache.myfaces.shared_impl.ut
    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.spi.ServiceProviderFinderFactory;
    import org.xml.sax.SAXException;

    @@ -72,7 +71,7 @@ public class DefaultFacesConfigurationPr

    private static final String STANDARD_FACES_CONFIG_RESOURCE = "META-INF/standard-faces-config.xml";

    -    private static final String META_INF_SERVICES_RESOURCE_PREFIX = "META-INF/services/";
    +    //private static final String META_INF_SERVICES_RESOURCE_PREFIX = "META-INF/services/";

    private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";

    @@ -96,8 +95,6 @@ public class DefaultFacesConfigurationPr

    private AnnotationConfigurator _annotationConfigurator;

    -    private FacesConfigDispenser _dispenser;
    -
    protected void setUnmarshaller(ExternalContext ectx, FacesConfigUnmarshaller<? extends FacesConfig> unmarshaller)
    {
    _unmarshaller = unmarshaller;
    @@ -113,28 +110,6 @@ public class DefaultFacesConfigurationPr
    return _unmarshaller;
    }

    -    /**
    -     * @param dispenser
    -     *            the dispenser to set
    -     */
    -    protected void setDispenser(FacesConfigDispenser dispenser)
    -    {
    -        _dispenser = dispenser;
    -    }
    -
    -    /**
    -     * @return the dispenser
    -     */
    -    protected FacesConfigDispenser getDispenser()
    -    {
    -        if (_dispenser == null)
    -        {
    -            _dispenser = new DigesterFacesConfigDispenserImpl();
    -        }
    -
    -        return _dispenser;
    -    }
    -
    protected void setAnnotationConfigurator(AnnotationConfigurator configurator)
    {
    _annotationConfigurator = configurator;
    @@ -149,8 +124,8 @@ public class DefaultFacesConfigurationPr
    return _annotationConfigurator;
    }

    -
    -    protected FacesConfig getStandardFacesConfig(ExternalContext ectx)
    +    @Override
    +    public FacesConfig getStandardFacesConfig(ExternalContext ectx)
    {
    try
    {
    @@ -182,8 +157,8 @@ public class DefaultFacesConfigurationPr
    }
    }

    -
    -    protected FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete)
    +    @Override
    +    public FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete)
    {
    return getAnnotationConfigurator().createFacesConfig(ectx, metadataComplete);
    }
    @@ -191,7 +166,8 @@ public class DefaultFacesConfigurationPr
    /**
    * This method performs part of the factory search outlined in section 10.2.6.1.
    */
    -    protected FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
    +    @Override
    +    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
    {
    try
    {
    @@ -201,7 +177,7 @@ public class DefaultFacesConfigurationPr

    for (String factoryName : FACTORY_NAMES)
    {
    -                List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(ectx).getServiceProviderList(factoryName);
    +                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx).getServiceProviderList(factoryName);

    for (String className : classList)
    {
    @@ -255,7 +231,8 @@ public class DefaultFacesConfigurationPr
    /**
    * This method fixes MYFACES-208
    */
    -    protected List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx)
    +    @Override
    +    public List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx)
    {
    List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
    try
    @@ -298,7 +275,8 @@ public class DefaultFacesConfigurationPr
    return appConfigResources;
    }

    -    protected List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
    +    @Override
    +    public List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
    {
    List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
    try
    @@ -365,7 +343,7 @@ public class DefaultFacesConfigurationPr
    return configFilesList;
    }

    -    protected FacesConfig getWebAppFacesConfig(ExternalContext ectx)
    +    public FacesConfig getWebAppFacesConfig(ExternalContext ectx)
    {
    try
    {
    @@ -410,7 +388,7 @@ public class DefaultFacesConfigurationPr
    }
    }

    -    protected void orderAndFeedArtifacts(List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
    +    protected void orderAndFeedArtifacts(FacesConfigDispenser dispenser, List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
    throws FacesException
    {
    if (webAppConfig != null && webAppConfig.getAbsoluteOrdering() != null)
    @@ -451,7 +429,7 @@ public class DefaultFacesConfigurationPr
    //Add all mentioned in othersResources
    for (FacesConfig resource : othersResources)
    {
    -                        getDispenser().feed(resource);
    +                        dispenser.feed(resource);
    }
    }
    else
    @@ -463,7 +441,7 @@ public class DefaultFacesConfigurationPr
    FacesConfig targetFacesConfig = getFacesConfig(appConfigResources, nameSlot.getName());
    if (targetFacesConfig != null)
    {
    -                        getDispenser().feed(targetFacesConfig);
    +                        dispenser.feed(targetFacesConfig);
    }
    }
    }
    @@ -498,13 +476,13 @@ public class DefaultFacesConfigurationPr
    for (FacesConfig resource : sortedList)
    {
    //Feed
    -                getDispenser().feed(resource);
    +                dispenser.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);
    +            dispenser.feed(webAppConfig);
    }
    }

    @@ -1363,13 +1341,17 @@ public class DefaultFacesConfigurationPr
    {
    boolean metadataComplete = false;

    -        setDispenser(new DigesterFacesConfigDispenserImpl());
    +        FacesConfigurationProvider provider = FacesConfigurationProviderFactory.
    +            getFacesConfigurationProviderFactory(_externalContext).
    +                getFacesConfigurationProvider(_externalContext);
    +
    +        FacesConfigDispenser dispenser = new DigesterFacesConfigDispenserImpl();
    //1. Feed standard-faces-config.xml first.
    -        getDispenser().feed(getStandardFacesConfig(_externalContext));
    +        dispenser.feed(provider.getStandardFacesConfig(_externalContext));

    -        getDispenser().feed(getMetaInfServicesFacesConfig(_externalContext));
    +        dispenser.feed(provider.getMetaInfServicesFacesConfig(_externalContext));

    -        FacesConfig webAppFacesConfig = getWebAppFacesConfig(_externalContext);
    +        FacesConfig webAppFacesConfig = provider.getWebAppFacesConfig(_externalContext);

    //read metadata-complete attribute on WEB-INF/faces-config.xml
    if(webAppFacesConfig != null)
    @@ -1382,21 +1364,21 @@ public class DefaultFacesConfigurationPr
    //metadata-complete can only be specified in faces-config.xml per the JSF 2.0 schema
    }

    -        FacesConfig annotationFacesConfig = getAnnotationsFacesConfig(_externalContext, metadataComplete);
    +        FacesConfig annotationFacesConfig = provider.getAnnotationsFacesConfig(_externalContext, metadataComplete);

    if (annotationFacesConfig != null)
    {
    -            getDispenser().feed(annotationFacesConfig);
    +            dispenser.feed(annotationFacesConfig);
    }

    List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();

    -        appConfigResources.addAll(getClassloaderFacesConfig(_externalContext));
    -        appConfigResources.addAll(getContextSpecifiedFacesConfig(_externalContext));
    +        appConfigResources.addAll(provider.getClassloaderFacesConfig(_externalContext));
    +        appConfigResources.addAll(provider.getContextSpecifiedFacesConfig(_externalContext));

    -        orderAndFeedArtifacts(appConfigResources,webAppFacesConfig);
    +        orderAndFeedArtifacts(dispenser, appConfigResources,webAppFacesConfig);

    -        return getDispenser();
    +        return dispenser;
    }



    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=1043151&r1=1043150&r2=1043151&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 Tue Dec  7 18:03:04 2010
    @@ -26,9 +26,6 @@ import java.util.Set;
    import java.util.logging.Level;
    import java.util.logging.Logger;

    -import javax.faces.FacesException;
    -import javax.faces.FactoryFinder;
    -import javax.faces.application.Application;
    import javax.faces.bean.ApplicationScoped;
    import javax.faces.bean.CustomScoped;
    import javax.faces.bean.ManagedBean;
    @@ -42,17 +39,11 @@ import javax.faces.context.ExternalConte
    import javax.faces.convert.FacesConverter;
    import javax.faces.event.ComponentSystemEvent;
    import javax.faces.event.NamedEvent;
    -import javax.faces.render.ClientBehaviorRenderer;
    import javax.faces.render.FacesBehaviorRenderer;
    import javax.faces.render.FacesRenderer;
    -import javax.faces.render.RenderKit;
    import javax.faces.render.RenderKitFactory;
    -import javax.faces.render.Renderer;
    import javax.faces.validator.FacesValidator;

    -import org.apache.myfaces.config.FacesConfigDispenser;
    -import org.apache.myfaces.config.NamedEventManager;
    -import org.apache.myfaces.config.RuntimeConfig;
    import org.apache.myfaces.config.impl.digester.elements.Behavior;
    import org.apache.myfaces.config.impl.digester.elements.Converter;
    import org.apache.myfaces.config.impl.digester.elements.FacesConfig;
    @@ -97,7 +88,7 @@ public class AnnotationConfigurator
    {
    if (!metadataComplete)
    {
    -            AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(_externalContext).createAnnotationProvider(_externalContext);
    +            AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(_externalContext).getAnnotationProvider(_externalContext);
    Map<Class<? extends Annotation>,Set<Class<?>>> map = provider.getAnnotatedClasses(_externalContext);
    return createFacesConfig(map);
    }

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java Tue Dec  7 18:03:04 2010
    @@ -52,6 +52,7 @@ import javax.faces.validator.FacesValida
    import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
    import org.apache.myfaces.shared_impl.util.ClassUtils;
    import org.apache.myfaces.spi.AnnotationProvider;
    +import org.apache.myfaces.spi.AnnotationProviderFactory;
    import org.apache.myfaces.view.facelets.util.Classpath;

    /**
    @@ -165,7 +166,8 @@ public class DefaultAnnotationProvider e
    //2. Scan for annotations on classpath
    try
    {
    -            classes = getAnnotatedMetaInfClasses(ctx, getBaseUrls());
    +            AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(ctx).getAnnotationProvider(ctx);
    +            classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls());
    }
    catch (IOException e)
    {

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java Tue Dec  7 18:03:04 2010
    @@ -156,7 +156,7 @@ public class DefaultLifecycleProviderFac
    InvocationTargetException,
    PrivilegedActionException
    {
    -                                List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
    +                                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
    Iterator<String> iter = classList.iterator();
    while (iter.hasNext())
    {
    @@ -178,7 +178,7 @@ public class DefaultLifecycleProviderFac
    }
    else
    {
    -                List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
    +                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(extContext).getServiceProviderList(LIFECYCLE_PROVIDER);
    Iterator<String> iter = classList.iterator();
    while (iter.hasNext())
    {

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderFactory.java Tue Dec  7 18:03:04 2010
    @@ -84,4 +84,9 @@ public abstract class AnnotationProvider
    }

    public abstract AnnotationProvider createAnnotationProvider(ExternalContext externalContext);
    +
    +    public AnnotationProvider getAnnotationProvider(ExternalContext externalContext)
    +    {
    +        return createAnnotationProvider(externalContext);
    +    }
    }

    Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java?rev=1043151&view=auto
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java (added)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/AnnotationProviderWrapper.java Tue Dec  7 18:03:04 2010
    @@ -0,0 +1,54 @@
    +/*
    + * 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.spi;
    +
    +import java.io.IOException;
    +import java.io.ObjectInputStream.GetField;
    +import java.lang.annotation.Annotation;
    +import java.net.URL;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import javax.faces.FacesWrapper;
    +import javax.faces.context.ExternalContext;
    +
    +/**
    + *
    + * @since 2.0.3
    + * @author Leonardo Uribe
    + */
    +public abstract class AnnotationProviderWrapper extends AnnotationProvider implements FacesWrapper<AnnotationProvider>
    +{
    +
    +    public AnnotationProviderWrapper()
    +    {
    +
    +    }
    +
    +    public Map<Class<? extends Annotation>,Set<Class<?>>> getAnnotatedClasses(ExternalContext ctx)
    +    {
    +        return getWrapped().getAnnotatedClasses(ctx);
    +    }
    +
    +    public Set<URL> getBaseUrls() throws IOException
    +    {
    +        return getWrapped().getBaseUrls();
    +    }
    +
    +}

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProvider.java Tue Dec  7 18:03:04 2010
    @@ -18,8 +18,11 @@
    */
    package org.apache.myfaces.spi;

    +import java.util.List;
    +
    import javax.faces.context.ExternalContext;

    +import org.apache.myfaces.config.element.FacesConfig;
    import org.apache.myfaces.config.element.FacesConfigData;

    /**
    @@ -29,12 +32,65 @@ import org.apache.myfaces.config.element
    * this information, preventing calculate it over and over each time the web application
    * is started.
    *
    + * <p>To wrap the default FacesConfigurationProvider, use a constructor like
    + * CustomFacesConfigurationProvider(FacesConfigurationProvider fcp)</p>
    + *
    * @author Leonardo Uribe
    * @since 2.0.3
    *
    */
    public abstract class FacesConfigurationProvider
    {
    +    /**
    +     * Return the FacesConfig object model retrieved from MyFaces META-INF/standard-faces-config.xml file.
    +     *
    +     * @param ectx
    +     * @return
    +     */
    +    public abstract FacesConfig getStandardFacesConfig(ExternalContext ectx);
    +
    +    /**
    +     * Return the FacesConfig object model retrieved from locate all JSF factories from META-INF/services/[factory_key].
    +     *
    +     * The default implementation uses ServiceProviderFinder facilities to locate this SPI interfaces.
    +     *
    +     * @param ectx
    +     * @return
    +     */
    +    public abstract FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx);
    +
    +    /**
    +     * Return the FacesConfig object model retrieved from scanning annotations on the classpath.
    +     *
    +     * @param ectx
    +     * @param metadataComplete
    +     * @return
    +     */
    +    public abstract FacesConfig getAnnotationsFacesConfig(ExternalContext ectx, boolean metadataComplete);
    +
    +    /**
    +     * Return the FacesConfig object model retrieved from resources under the path META-INF/faces-config.xml and META-INF/[prefix].faces-config.xml
    +     *
    +     * @param ectx
    +     * @return
    +     */
    +    public abstract List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx);
    +
    +    /**
    +     * Return the FacesConfig object model retrieved from javax.faces.CONFIG_FILES web config attribute
    +     *
    +     * @param ectx
    +     * @return
    +     */
    +    public abstract List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx);
    +
    +    /**
    +     * Return the FacesConfig object model retrieved from WEB-INF/faces-config.xml
    +     *
    +     * @param ectx
    +     * @return
    +     */
    +    public abstract FacesConfig getWebAppFacesConfig(ExternalContext ectx);

    /**
    * Returns an object that collect all config information used by MyFaces

    Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java?rev=1043151&view=auto
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java (added)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/FacesConfigurationProviderWrapper.java Tue Dec  7 18:03:04 2010
    @@ -0,0 +1,79 @@
    +/*
    + * 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.spi;
    +
    +import java.util.List;
    +
    +import javax.faces.FacesWrapper;
    +import javax.faces.context.ExternalContext;
    +
    +import org.apache.myfaces.config.element.FacesConfig;
    +import org.apache.myfaces.config.element.FacesConfigData;
    +
    +/**
    + *
    + * @author Leonardo Uribe
    + * @since 2.0.3
    + */
    +public abstract class FacesConfigurationProviderWrapper
    +    extends FacesConfigurationProvider
    +    implements FacesWrapper<FacesConfigurationProvider>
    +{
    +
    +    public FacesConfigurationProviderWrapper()
    +    {
    +
    +    }
    +
    +    public FacesConfig getStandardFacesConfig(ExternalContext ectx)
    +    {
    +        return getWrapped().getStandardFacesConfig(ectx);
    +    }
    +
    +    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
    +    {
    +        return getWrapped().getMetaInfServicesFacesConfig(ectx);
    +    }
    +
    +    public FacesConfig getAnnotationsFacesConfig(ExternalContext ectx,
    +            boolean metadataComplete)
    +    {
    +        return getWrapped().getAnnotationsFacesConfig(ectx, metadataComplete);
    +    }
    +
    +    public List<FacesConfig> getClassloaderFacesConfig(ExternalContext ectx)
    +    {
    +        return getWrapped().getClassloaderFacesConfig(ectx);
    +    }
    +
    +    public List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
    +    {
    +        return getWrapped().getContextSpecifiedFacesConfig(ectx);
    +    }
    +
    +    public FacesConfig getWebAppFacesConfig(ExternalContext ectx)
    +    {
    +        return getWrapped().getWebAppFacesConfig(ectx);
    +    }
    +
    +    public FacesConfigData getFacesConfigData(ExternalContext ectx)
    +    {
    +        return getWrapped().getFacesConfigData(ectx);
    +    }
    +}

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/ServiceProviderFinderFactory.java Tue Dec  7 18:03:04 2010
    @@ -46,16 +46,16 @@ public class ServiceProviderFinderFactor
    * @param ectx
    * @return
    */
    -    public static ServiceProviderFinder getServiceLoaderFinder(ExternalContext ectx)
    +    public static ServiceProviderFinder getServiceProviderFinder(ExternalContext ectx)
    {
    ServiceProviderFinder slp = (ServiceProviderFinder) ectx.getApplicationMap().get(SERVICE_PROVIDER_KEY);
    if (slp == null)
    {
    -            slp = _getServiceLoaderFinderFromInitParam(ectx);
    +            slp = _getServiceProviderFinderFromInitParam(ectx);
    if (slp == null)
    {
    slp = new DefaultServiceProviderFinder();
    -                setServiceLoaderFinder(ectx, slp);
    +                setServiceProviderFinder(ectx, slp);
    }
    }
    return slp;
    @@ -73,12 +73,12 @@ public class ServiceProviderFinderFactor
    * @param ectx
    * @param slp
    */
    -    public static void setServiceLoaderFinder(ExternalContext ectx, ServiceProviderFinder slp)
    +    public static void setServiceProviderFinder(ExternalContext ectx, ServiceProviderFinder slp)
    {
    ectx.getApplicationMap().put(SERVICE_PROVIDER_KEY, slp);
    }

    -    public static void setServiceLoaderFinder(ServletContext ctx, ServiceProviderFinder slp)
    +    public static void setServiceProviderFinder(ServletContext ctx, ServiceProviderFinder slp)
    {
    ctx.setAttribute(SERVICE_PROVIDER_KEY, slp);
    }
    @@ -88,7 +88,7 @@ public class ServiceProviderFinderFactor
    * @param context
    * @return
    */
    -    private static ServiceProviderFinder _getServiceLoaderFinderFromInitParam(ExternalContext context)
    +    private static ServiceProviderFinder _getServiceProviderFinderFromInitParam(ExternalContext context)
    {
    String initializerClassName = context.getInitParameter(SERVICE_PROVIDER_FINDER_PARAM);
    if (initializerClassName != null)
    @@ -100,7 +100,7 @@ public class ServiceProviderFinderFactor
    if (!ServiceProviderFinder.class.isAssignableFrom(clazz))
    {
    throw new FacesException("Class " + clazz
    -                            + " does not implement FacesInitializer");
    +                            + " does not implement ServiceProviderFinder");
    }

    // create instance and return it
    @@ -108,7 +108,7 @@ public class ServiceProviderFinderFactor
    }
    catch (ClassNotFoundException cnfe)
    {
    -                throw new FacesException("Could not find class of specified FacesInitializer", cnfe);
    +                throw new FacesException("Could not find class of specified ServiceProviderFinder", cnfe);
    }
    }
    return null;

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultAnnotationProviderFactory.java Tue Dec  7 18:03:04 2010
    @@ -44,12 +44,26 @@ public class DefaultAnnotationProviderFa

    public static final String ANNOTATION_PROVIDER_LIST = AnnotationProvider.class.getName()+".LIST";

    +    public static final String ANNOTATION_PROVIDER_INSTANCE = AnnotationProvider.class.getName()+".INSTANCE";
    +
    private Logger getLogger()
    {
    return Logger.getLogger(DefaultAnnotationProviderFactory.class.getName());
    }

    @Override
    +    public AnnotationProvider getAnnotationProvider(ExternalContext externalContext)
    +    {
    +        AnnotationProvider annotationProvider = (AnnotationProvider) externalContext.getApplicationMap().get(ANNOTATION_PROVIDER_INSTANCE);
    +        if (annotationProvider == null)
    +        {
    +            annotationProvider = createAnnotationProvider(externalContext);
    +            externalContext.getApplicationMap().put(ANNOTATION_PROVIDER_INSTANCE, annotationProvider);
    +        }
    +        return annotationProvider;
    +    }
    +
    +    @Override
    public AnnotationProvider createAnnotationProvider(
    ExternalContext externalContext)
    {
    @@ -115,7 +129,7 @@ public class DefaultAnnotationProviderFa
    List<String> classList = (List<String>) externalContext.getApplicationMap().get(ANNOTATION_PROVIDER_LIST);
    if (classList == null)
    {
    -            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(ANNOTATION_PROVIDER);
    +            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(ANNOTATION_PROVIDER);
    externalContext.getApplicationMap().put(ANNOTATION_PROVIDER_LIST, classList);
    }
    return SpiUtils.buildApplicationObject(externalContext, AnnotationProvider.class, classList, new DefaultAnnotationProvider());

    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFaceletConfigResourceProviderFactory.java Tue Dec  7 18:03:04 201
    @@ -115,7 +115,7 @@ public class DefaultFaceletConfigResourc
    List<String> classList = (List<String>) externalContext.getApplicationMap().get(FACELET_CONFIG_PROVIDER_LIST);
    if (classList == null)
    {
    -            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(FACELET_CONFIG_PROVIDER);
    +            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(FACELET_CONFIG_PROVIDER);
    externalContext.getApplicationMap().put(FACELET_CONFIG_PROVIDER_LIST, classList);
    }


    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigResourceProviderFactory.java Tue Dec  7 18:03:04 2010
    @@ -115,7 +115,7 @@ public class DefaultFacesConfigResourceP
    List<String> classList = (List<String>) externalContext.getApplicationMap().get(FACES_CONFIG_PROVIDER_LIST);
    if (classList == null)
    {
    -            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(FACES_CONFIG_PROVIDER);
    +            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(FACES_CONFIG_PROVIDER);
    externalContext.getApplicationMap().put(FACES_CONFIG_PROVIDER_LIST, classList);
    }


    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultFacesConfigurationProviderFactory.java Tue Dec  7 18:03:04 2010
    @@ -44,6 +44,8 @@ public class DefaultFacesConfigurationPr
    public static final String FACES_CONFIGURATION_PROVIDER = FacesConfigurationProvider.class.getName();

    public static final String FACES_CONFIGURATION_PROVIDER_LIST = FacesConfigurationProvider.class.getName()+".LIST";
    +
    +    public static final String FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY = FacesConfigurationProvider.class.getName() + ".INSTANCE";

    private Logger getLogger()
    {
    @@ -54,54 +56,59 @@ public class DefaultFacesConfigurationPr
    public FacesConfigurationProvider getFacesConfigurationProvider(
    ExternalContext externalContext)
    {
    -        FacesConfigurationProvider returnValue = null;
    -        final ExternalContext extContext = externalContext;
    -        try
    +        FacesConfigurationProvider returnValue = (FacesConfigurationProvider) externalContext.getApplicationMap().get(FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY);
    +        if (returnValue == null)
    {
    -            if (System.getSecurityManager() != null)
    +            final ExternalContext extContext = externalContext;
    +            try
    {
    -                returnValue = AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<FacesConfigurationProvider>()
    -                        {
    -                            public FacesConfigurationProvider run() throws ClassNotFoundException,
    -                                    NoClassDefFoundError,
    -                                    InstantiationException,
    -                                    IllegalAccessException,
    -                                    InvocationTargetException,
    -                                    PrivilegedActionException
    +                if (System.getSecurityManager() != null)
    +                {
    +                    returnValue = AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<FacesConfigurationProvider>()
    {
    -                                return resolveFacesConfigurationProviderFromService(extContext);
    -                            }
    -                        });
    +                                public FacesConfigurationProvider run() throws ClassNotFoundException,
    +                                        NoClassDefFoundError,
    +                                        InstantiationException,
    +                                        IllegalAccessException,
    +                                        InvocationTargetException,
    +                                        PrivilegedActionException
    +                                {
    +                                    return resolveFacesConfigurationProviderFromService(extContext);
    +                                }
    +                            });
    +                }
    +                else
    +                {
    +                    returnValue = resolveFacesConfigurationProviderFromService(extContext);
    +                }
    +                externalContext.getApplicationMap().put(FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY, returnValue);
    }
    -            else
    +            catch (ClassNotFoundException e)
    {
    -                returnValue = resolveFacesConfigurationProviderFromService(extContext);
    +                // ignore
    +            }
    +            catch (NoClassDefFoundError e)
    +            {
    +                // ignore
    +            }
    +            catch (InstantiationException e)
    +            {
    +                getLogger().log(Level.SEVERE, "", e);
    +            }
    +            catch (IllegalAccessException e)
    +            {
    +                getLogger().log(Level.SEVERE, "", e);
    +            }
    +            catch (InvocationTargetException e)
    +            {
    +                getLogger().log(Level.SEVERE, "", e);
    +            }
    +            catch (PrivilegedActionException e)
    +            {
    +                throw new FacesException(e);
    }
    }
    -        catch (ClassNotFoundException e)
    -        {
    -            // ignore
    -        }
    -        catch (NoClassDefFoundError e)
    -        {
    -            // ignore
    -        }
    -        catch (InstantiationException e)
    -        {
    -            getLogger().log(Level.SEVERE, "", e);
    -        }
    -        catch (IllegalAccessException e)
    -        {
    -            getLogger().log(Level.SEVERE, "", e);
    -        }
    -        catch (InvocationTargetException e)
    -        {
    -            getLogger().log(Level.SEVERE, "", e);
    -        }
    -        catch (PrivilegedActionException e)
    -        {
    -            throw new FacesException(e);
    -        }
    +

    return returnValue;
    }
    @@ -117,7 +124,7 @@ public class DefaultFacesConfigurationPr
    List<String> classList = (List<String>) externalContext.getApplicationMap().get(FACES_CONFIGURATION_PROVIDER_LIST);
    if (classList == null)
    {
    -            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(FACES_CONFIGURATION_PROVIDER);
    +            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(FACES_CONFIGURATION_PROVIDER);
    externalContext.getApplicationMap().put(FACES_CONFIGURATION_PROVIDER_LIST, classList);
    }


    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/DefaultWebConfigProviderFactory.java Tue Dec  7 18:03:04 2010
    @@ -119,7 +119,7 @@ public class DefaultWebConfigProviderFac
    List<String> classList = (List<String>) externalContext.getApplicationMap().get(WEB_CONFIG_PROVIDER_LIST);
    if (classList == null)
    {
    -            classList = ServiceProviderFinderFactory.getServiceLoaderFinder(externalContext).getServiceProviderList(WEB_CONFIG_PROVIDER);
    +            classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(WEB_CONFIG_PROVIDER);
    externalContext.getApplicationMap().put(WEB_CONFIG_PROVIDER_LIST, classList);
    }


    Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java
    URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java?rev=1043151&r1=1043150&r2=1043151&view=diff
    ==============================================================================
    --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java (original)
    +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/spi/impl/SpiUtils.java Tue Dec  7 18:03:04 2010
    @@ -38,7 +38,7 @@ public final class SpiUtils

    public static Object build(ExternalContext ectx, Class spiClass, String defaultImpl)
    {
    -        List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(ectx).getServiceProviderList(spiClass.getName());
    +        List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx).getServiceProviderList(spiClass.getName());

    if (classList != null && !classList.isEmpty())
    {
    @@ -54,7 +54,7 @@ public final class SpiUtils

    public static <T> T buildApplicationObject(ExternalContext ectx, Class<T> interfaceClass, T defaultObject)
    {
    -        List<String> classList = ServiceProviderFinderFactory.getServiceLoaderFinder(ectx).getServiceProviderList(interfaceClass.getName());
    +        List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx).getServiceProviderList(interfaceClass.getName());

    if (classList != null && !classList.isEmpty())
    {



    --
    Jakob Korherr

    blog: http://www.jakobk.com
    twitter: http://twitter.com/jakobkorherr
    work: http://www.irian.at


    --
    Jakob Korherr

    blog: http://www.jakobk.com
    twitter: http://twitter.com/jakobkorherr
    work: http://www.irian.at

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriesmyfaces
postedDec 8, '10 at 11:02a
activeDec 8, '10 at 1:38p
posts2
users1
websitemyfaces.apache.org

1 user in discussion

Jakob Korherr: 2 posts

People

Translate

site design / logo © 2019 Grokbase