myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sless...@apache.org
Subject svn commit: r696520 - in /myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces: application/ config/ config/impl/digester/ config/impl/digester/elements/
Date Wed, 17 Sep 2008 23:55:46 GMT
Author: slessard
Date: Wed Sep 17 16:55:46 2008
New Revision: 696520

URL: http://svn.apache.org/viewvc?rev=696520&view=rev
Log:
Added some Java 5 generic, added ResourceHandler config support.

Modified:
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Application.java

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=696520&r1=696519&r2=696520&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
Wed Sep 17 16:55:46 2008
@@ -23,10 +23,12 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.el.CompositeELResolver;
 import javax.el.ELContext;
@@ -53,6 +55,9 @@
 import javax.faces.el.ValueBinding;
 import javax.faces.el.VariableResolver;
 import javax.faces.event.ActionListener;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import javax.faces.event.SystemEventListenerHolder;
 import javax.faces.validator.Validator;
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -79,12 +84,13 @@
 
 /**
  * DOCUMENT ME!
- *
+ * 
  * @author Manfred Geiler (latest modification by $Author$)
  * @author Anton Koinov
  * @author Thomas Spiegl
  * @author Stan Silvert
- * @version $Revision$ $Date$
+ * @version $Revision$ $Date: 2008-09-13 19:10:53 -0400 (sam., 13 sept.
+ *          2008) $
  */
 @SuppressWarnings("deprecation")
 public class ApplicationImpl extends Application
@@ -99,7 +105,8 @@
     private final static ThreadLocal<RuntimeConfig> initializingRuntimeConfig = new
ThreadLocal<RuntimeConfig>();
 
     // ~ Instance fields
-    // ----------------------------------------------------------------------------
+    //--------------------------------------------------------------------------
+    // --
 
     private Collection<Locale> _supportedLocales = Collections.emptySet();
     private Locale _defaultLocale;
@@ -121,6 +128,7 @@
     private final Map<String, org.apache.myfaces.config.impl.digester.elements.Converter>
_converterClassNameToConfigurationMap = new ConcurrentHashMap<String, org.apache.myfaces.config.impl.digester.elements.Converter>();
     private final Map<String, Class> _componentClassMap = new ConcurrentHashMap<String,
Class>();
     private final Map<String, Class> _validatorClassMap = new ConcurrentHashMap<String,
Class>();
+    private final Map<Class<? extends SystemEvent>, SystemListenerEntry> _systemEventListenerClassMap
= new ConcurrentHashMap<Class<? extends SystemEvent>, SystemListenerEntry>();
 
     private final RuntimeConfig _runtimeConfig;
 
@@ -131,7 +139,8 @@
     private ProjectStage _projectStage;
 
     // ~ Constructors
-    // -------------------------------------------------------------------------------
+    //--------------------------------------------------------------------------
+    // -----
 
     public ApplicationImpl()
     {
@@ -142,26 +151,29 @@
     {
         if (initializingRuntimeConfig.get() == null)
         {
-            //It may happen that the current thread value
-            //for initializingRuntimeConfig is not set 
-            //(note that this value is final, so it just 
-            //allow set only once per thread).
-            //So the better for this case is try to get
-            //the value using RuntimeConfig.getCurrentInstance()
-            //instead throw an IllegalStateException (only fails if
-            //the constructor is called before setInitializingRuntimeConfig).
-            //From other point of view, AbstractFacesInitializer do 
-            //the same as below, so there is not problem if
-            //we do this here and this is the best place to do
-            //this.
-            //log.info("initializingRuntimeConfig.get() == null, so loading from ExternalContext");
-            ApplicationImpl.setInitializingRuntimeConfig(
-                    RuntimeConfig.getCurrentInstance(
-                            FacesContext.getCurrentInstance()
-                            .getExternalContext()));
-
-            //throw new IllegalStateException("The runtime config instance which is created
while initialize myfaces "
-            //        + "must be set through ApplicationImpl.setInitializingRuntimeConfig");
+            // It may happen that the current thread value
+            // for initializingRuntimeConfig is not set
+            // (note that this value is final, so it just
+            // allow set only once per thread).
+            // So the better for this case is try to get
+            // the value using RuntimeConfig.getCurrentInstance()
+            // instead throw an IllegalStateException (only fails if
+            // the constructor is called before setInitializingRuntimeConfig).
+            // From other point of view, AbstractFacesInitializer do
+            // the same as below, so there is not problem if
+            // we do this here and this is the best place to do
+            // this.
+            // log.info(
+            // "initializingRuntimeConfig.get() == null, so loading from ExternalContext"
+            // );
+            ApplicationImpl.setInitializingRuntimeConfig(RuntimeConfig.getCurrentInstance(FacesContext
+                    .getCurrentInstance().getExternalContext()));
+
+            // throw new IllegalStateException(
+            // "The runtime config instance which is created while initialize myfaces "
+            // +
+            // "must be set through ApplicationImpl.setInitializingRuntimeConfig"
+            // );
         }
         return initializingRuntimeConfig.get();
     }
@@ -193,7 +205,8 @@
     }
 
     // ~ Methods
-    // ------------------------------------------------------------------------------------
+    //--------------------------------------------------------------------------
+    // ----------
 
     @Override
     public final void addELResolver(final ELResolver resolver)
@@ -211,7 +224,8 @@
     @Override
     public final ELResolver getELResolver()
     {
-        // we don't need synchronization here since it is ok to have multiple instances of
the elresolver
+        // we don't need synchronization here since it is ok to have multiple
+        // instances of the elresolver
         if (elResolver == null)
         {
             elResolver = createFacesResolver();
@@ -241,8 +255,9 @@
     }
 
     @Override
-    public final java.util.ResourceBundle getResourceBundle(final FacesContext facesContext,
final String name) throws FacesException,
-            NullPointerException
+    public final java.util.ResourceBundle getResourceBundle(final FacesContext facesContext,
final String name)
+                                                                                        
                      throws FacesException,
+                                                                                        
                      NullPointerException
     {
 
         checkNull(facesContext, "facesContext");
@@ -285,7 +300,7 @@
     }
 
     java.util.ResourceBundle getResourceBundle(final String name, final Locale locale, final
ClassLoader loader)
-            throws MissingResourceException
+                                                                                        
                       throws MissingResourceException
     {
         return java.util.ResourceBundle.getBundle(name, locale, loader);
     }
@@ -301,8 +316,9 @@
     }
 
     @Override
-    public final UIComponent createComponent(final ValueExpression componentExpression, final
FacesContext facesContext,
-            final String componentType) throws FacesException, NullPointerException
+    public final UIComponent createComponent(final ValueExpression componentExpression,
+                                             final FacesContext facesContext, 
+                                             final String componentType) throws FacesException,
NullPointerException
     {
 
         checkNull(componentExpression, "componentExpression");
@@ -346,7 +362,8 @@
     }
 
     @Override
-    public final Object evaluateExpressionGet(final FacesContext context, final String expression,
final Class expectedType) throws ELException
+    public final Object evaluateExpressionGet(final FacesContext context, final String expression,
+                                              final Class expectedType) throws ELException
     {
         ELContext elContext = context.getELContext();
         return getExpressionFactory().createValueExpression(elContext, expression, expectedType).getValue(elContext);
@@ -355,12 +372,32 @@
     @Override
     public final void addELContextListener(final ELContextListener listener)
     {
-
         synchronized (_elContextListeners)
         {
             _elContextListeners.add(listener);
         }
     }
+    
+    @Override
+    public void publishEvent(Class<? extends SystemEvent> systemEventClass, SystemEventListenerHolder
source)
+    {
+        checkNull(systemEventClass, "systemEventClass");
+        checkNull(source, "source");
+        
+        SystemEvent event = null;
+        if (source instanceof SystemEventListenerHolder)
+        {
+            SystemEventListenerHolder holder = (SystemEventListenerHolder)source;
+            event = _traverseListenerList(holder.getListenersForEventClass(systemEventClass),
systemEventClass, 
+                                          source, event);
+        }
+        
+        SystemListenerEntry systemListenerEntry  = _systemEventListenerClassMap.get(systemEventClass);
+        if (systemListenerEntry != null)
+        {
+            systemListenerEntry.publish(systemEventClass, source, event);
+        }     
+    }
 
     @Override
     public final void removeELContextListener(final ELContextListener listener)
@@ -485,12 +522,15 @@
     @Override
     public ProjectStage getProjectStage()
     {
-        // If the value has already been determined by a previous call to this method, simply
return that value.
+        // If the value has already been determined by a previous call to this
+        // method, simply return that value.
         if (_projectStage == null)
         {
             String stageName = null;
-            // Look for a JNDI environment entry under the key given by the value of
-            // ProjectStage.PROJECT_STAGE_JNDI_NAME (return type of java.lang.String).
+            // Look for a JNDI environment entry under the key given by the
+            // value of
+            // ProjectStage.PROJECT_STAGE_JNDI_NAME (return type of
+            // java.lang.String).
             try
             {
                 Context ctx = new InitialContext();
@@ -499,12 +539,12 @@
                 {
                     if (temp instanceof String)
                     {
-                        stageName = (String)temp;
+                        stageName = (String) temp;
                     }
                     else
                     {
-                        log.error("JNDI lookup for key " + ProjectStage.PROJECT_STAGE_JNDI_NAME
+
-                                  " should return a java.lang.String value");
+                        log.error("JNDI lookup for key " + ProjectStage.PROJECT_STAGE_JNDI_NAME
+                                + " should return a java.lang.String value");
                     }
                 }
             }
@@ -514,8 +554,10 @@
             }
 
             /*
-             * If found, continue with the algorithm below, otherwise, look for an entry
in the initParamMap of the
-             * ExternalContext from the current FacesContext with the key ProjectStage.PROJECT_STAGE_PARAM_NAME
+             * If found, continue with the algorithm below, otherwise, look for
+             * an entry in the initParamMap of the ExternalContext from the
+             * current FacesContext with the key
+             * ProjectStage.PROJECT_STAGE_PARAM_NAME
              */
             if (stageName == null)
             {
@@ -527,8 +569,10 @@
             if (stageName != null)
             {
                 /*
-                 * see if an enum constant can be obtained by calling ProjectStage.valueOf(),
passing the value from the
-                 * initParamMap. If this succeeds without exception, save the value and return
it.
+                 * see if an enum constant can be obtained by calling
+                 * ProjectStage.valueOf(), passing the value from the
+                 * initParamMap. If this succeeds without exception, save the
+                 * value and return it.
                  */
                 try
                 {
@@ -548,10 +592,12 @@
                 }
             }
 
-            /* If not found, or any of the previous attempts to discover the enum constant
value have failed, log a
-             * descriptive error message, assign the value as ProjectStage.Production and
return it.
+            /*
+             * If not found, or any of the previous attempts to discover the
+             * enum constant value have failed, log a descriptive error message,
+             * assign the value as ProjectStage.Production and return it.
              */
-            
+
             _projectStage = ProjectStage.Production;
         }
 
@@ -645,6 +691,41 @@
     }
 
     @Override
+    public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, Class
sourceClass,
+                                 SystemEventListener listener)
+    {
+        checkNull(systemEventClass, "systemEventClass");
+        checkNull(listener, "listener");
+
+        SystemListenerEntry systemListenerEntry;
+        synchronized (_systemEventListenerClassMap)
+        {
+            systemListenerEntry = _systemEventListenerClassMap.get(systemEventClass);
+            if (systemListenerEntry == null)
+            {
+                systemListenerEntry = new SystemListenerEntry();
+                _systemEventListenerClassMap.put(systemEventClass, systemListenerEntry);
+            }
+        }
+
+        systemListenerEntry.addListener(listener, sourceClass);
+    }
+    
+    @Override
+    public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass,

+                                     Class sourceClass, SystemEventListener listener)
+    {
+        checkNull(systemEventClass, "systemEventClass");
+        checkNull(listener, "listener");
+        
+        SystemListenerEntry systemListenerEntry = _systemEventListenerClassMap.get(systemEventClass);
+        if (systemListenerEntry != null)
+        {
+            systemListenerEntry.removeListener(listener, sourceClass);
+        }
+    }
+
+    @Override
     public final ViewHandler getViewHandler()
     {
         return _viewHandler;
@@ -709,8 +790,9 @@
         }
     }
 
-    public final void addConverterConfiguration(final String converterClassName,
-            final org.apache.myfaces.config.impl.digester.elements.Converter configuration)
+    public final void addConverterConfiguration(
+                                                final String converterClassName,
+                                                final org.apache.myfaces.config.impl.digester.elements.Converter
configuration)
     {
         checkNull(converterClassName, "converterClassName");
         checkEmpty(converterClassName, "converterClassName");
@@ -764,12 +846,13 @@
     }
 
     /**
-     * @deprecated Use createComponent(ValueExpression, FacesContext, String) instead.
+     * @deprecated Use createComponent(ValueExpression, FacesContext, String)
+     *             instead.
      */
     @Deprecated
     @Override
     public final UIComponent createComponent(final ValueBinding valueBinding, final FacesContext
facesContext,
-            final String componentType) throws FacesException
+                                             final String componentType) throws FacesException
     {
 
         checkNull(valueBinding, "valueBinding");
@@ -786,30 +869,32 @@
      * Return an instance of the converter class that has been registered under
      * the specified id.
      * <p>
-     * Converters are registered via faces-config.xml files, and can also be registered
-     * via the addConverter(String id, Class converterClass) method on this class. Here
-     * the the appropriate Class definition is found, then an instance is created and
-     * returned.
+     * Converters are registered via faces-config.xml files, and can also be
+     * registered via the addConverter(String id, Class converterClass) method
+     * on this class. Here the the appropriate Class definition is found, then
+     * an instance is created and returned.
      * <p>
-     * A converter registered via a config file can have any number of nested attribute or
-     * property tags. The JSF specification is very vague about what effect these nested
-     * tags have. This method ignores nested attribute definitions, but for each nested
-     * property tag the corresponding setter is invoked on the new Converter instance
-     * passing the property's defaultValuer. Basic typeconversion is done so the target
-     * properties on the Converter instance can be String, int, boolean, etc. Note that:
+     * A converter registered via a config file can have any number of nested
+     * attribute or property tags. The JSF specification is very vague about
+     * what effect these nested tags have. This method ignores nested attribute
+     * definitions, but for each nested property tag the corresponding setter is
+     * invoked on the new Converter instance passing the property's
+     * defaultValuer. Basic typeconversion is done so the target properties on
+     * the Converter instance can be String, int, boolean, etc. Note that:
      * <ol>
-     * <li>the Sun Mojarra JSF implemenation ignores nested property tags completely,
so
-     * this behaviour cannot be relied on across implementations.
-     * <li>there is no equivalent functionality for converter classes registered via
-     * the Application.addConverter api method.
+     * <li>the Sun Mojarra JSF implemenation ignores nested property tags
+     * completely, so this behaviour cannot be relied on across implementations.
+     * <li>there is no equivalent functionality for converter classes registered
+     * via the Application.addConverter api method.
      * </ol>
      * <p>
-     * Note that this method is most commonly called from the standard f:attribute tag.
-     * As an alternative, most components provide a "converter" attribute which uses an
-     * EL expression to create a Converter instance, in which case this method is not
-     * invoked at all. The converter attribute allows the returned Converter instance to
-     * be configured via normal dependency-injection, and is generally a better choice
-     * than using this method.
+     * Note that this method is most commonly called from the standard
+     * f:attribute tag. As an alternative, most components provide a "converter"
+     * attribute which uses an EL expression to create a Converter instance, in
+     * which case this method is not invoked at all. The converter attribute
+     * allows the returned Converter instance to be configured via normal
+     * dependency-injection, and is generally a better choice than using this
+     * method.
      */
     @Override
     public final Converter createConverter(final String converterId)
@@ -818,9 +903,9 @@
         checkEmpty(converterId, "converterId");
 
         final Class converterClass = _converterIdToClassMap.get(converterId);
-        if(converterClass == null)
+        if (converterClass == null)
         {
-            throw new FacesException("Could not find any registered converter-class by converterId
: "+converterId);
+            throw new FacesException("Could not find any registered converter-class by converterId
: " + converterId);
         }
 
         try
@@ -853,7 +938,8 @@
 
         // Get EnumConverter for enum classes with no special converter, check
         // here as recursive call with java.lang.Enum will not work
-        if (converterClassName == null && targetClass.isEnum()) {
+        if (converterClassName == null && targetClass.isEnum())
+        {
             converterClassName = _converterClassNameToClassMap.get(Enum.class);
         }
 
@@ -985,12 +1071,14 @@
      */
     @Deprecated
     @Override
-    public final MethodBinding createMethodBinding(final String reference, Class[] params)
throws ReferenceSyntaxException
+    public final MethodBinding createMethodBinding(final String reference, Class[] params)
+                                                                                        
 throws ReferenceSyntaxException
     {
         checkNull(reference, "reference");
         checkEmpty(reference, "reference");
 
-        // TODO: this check should be performed by the expression factory. It is a requirement
of the TCK
+        // TODO: this check should be performed by the expression factory. It is
+        // a requirement of the TCK
         if (!(reference.startsWith("#{") && reference.endsWith("}")))
         {
             throw new ReferenceSyntaxException("Invalid method reference: '" + reference
+ "'");
@@ -1004,7 +1092,7 @@
         try
         {
             methodExpression = getExpressionFactory().createMethodExpression(threadELContext(),
reference,
-                    Object.class, params);
+                                                                             Object.class,
params);
         }
         catch (ELException e)
         {
@@ -1109,4 +1197,174 @@
             throw new NullPointerException("String " + paramName + " cannot be empty.");
         }
     }
+
+    private static SystemEvent _createEvent(Class<? extends SystemEvent> systemEventClass,
Object source,
+                                            SystemEvent event)
+    {
+        if (event == null)
+        {
+            try
+            {
+                Constructor<? extends SystemEvent> constructor = systemEventClass.getConstructor(Object.class);
+                event = constructor.newInstance(source);
+            }
+            catch (Exception e)
+            {
+                throw new FacesException("Couldn't instanciate system event of type " + systemEventClass.getName(),
e);
+            }
+        }
+
+        return event;
+    }
+
+    private static SystemEvent _traverseListenerList(List<? extends SystemEventListener>
listeners,
+                                                     Class<? extends SystemEvent> systemEventClass,
Object source,
+                                                     SystemEvent event)
+    {
+        if (listeners != null && !listeners.isEmpty())
+        {
+            for (SystemEventListener listener : listeners)
+            {
+                // Call
+                // SystemEventListener.isListenerForSource(java.lang.Object),
+                // passing the source argument.
+                // If this returns false, take no action on the listener.
+                if (listener.isListenerForSource(source))
+                {
+                    // Otherwise, if the event to be passed to the listener
+                    // instances has not yet been constructed,
+                    // construct the event, passing source as the argument to
+                    // the one-argument constructor that takes
+                    // an Object. This same event instance must be passed to all
+                    // listener instances.
+                    event = _createEvent(systemEventClass, source, event);
+
+                    // Call SystemEvent.isAppropriateListener(javax.faces.event.
+                    // FacesListener), passing the listener
+                    // instance as the argument. If this returns false, take no
+                    // action on the listener.
+                    if (event.isAppropriateListener(listener))
+                    {
+                        // Call SystemEvent.processListener(javax.faces.event.
+                        // FacesListener), passing the listener
+                        // instance.
+                        event.processListener(listener);
+                    }
+                }
+            }
+        }
+
+        return event;
+    }
+
+    private static class SystemListenerEntry
+    {
+        private List<SystemEventListener> _lstSystemEventListener;
+        private Map<Class<?>, List<SystemEventListener>> _sourceClassMap;
+
+        public SystemListenerEntry()
+        {
+        }
+
+        public void addListener(SystemEventListener listener)
+        {
+            assert listener != null;
+
+            addListenerNoDuplicate(getAnySourceListenersNotNull(), listener);
+        }
+
+        public void addListener(SystemEventListener listener, Class<?> source)
+        {
+            assert listener != null;
+
+            if (source == null)
+            {
+                addListener(listener);
+            }
+            else
+            {
+                addListenerNoDuplicate(getSpecificSourceListenersNotNull(source), listener);
+            }
+        }
+
+        public void removeListener(SystemEventListener listener)
+        {
+            assert listener != null;
+            
+            if (_lstSystemEventListener != null)
+            {
+                _lstSystemEventListener.remove(listener);
+            }
+        }
+
+        public void removeListener(SystemEventListener listener, Class<?> sourceClass)
+        {
+            assert listener != null;
+            
+            if (sourceClass == null)
+            {
+                removeListener(listener);
+            }
+            else
+            {
+                if (_sourceClassMap != null)
+                {
+                    List<SystemEventListener> listeners = _sourceClassMap.get(sourceClass);
+                    if (listeners != null)
+                    {
+                        listeners.remove(listener);
+                    }
+                }
+            }
+        }
+
+        public void publish(Class<? extends SystemEvent> systemEventClass, Object source,
SystemEvent event)
+        {
+            if (source != null && _sourceClassMap != null)
+            {
+                event = _traverseListenerList(_sourceClassMap.get(source.getClass()), systemEventClass,
source, event);
+            }
+
+            _traverseListenerList(_lstSystemEventListener, systemEventClass, source, event);
+        }
+
+        private void addListenerNoDuplicate(List<SystemEventListener> listeners, SystemEventListener
listener)
+        {
+            if (!listeners.contains(listener))
+            {
+                listeners.add(listener);
+            }
+        }
+
+        private synchronized List<SystemEventListener> getAnySourceListenersNotNull()
+        {
+            if (_lstSystemEventListener == null)
+            {
+                // TODO: Check if modification occurs often or not, might have to use a synchronized

+                //       list instead
+                _lstSystemEventListener = new CopyOnWriteArrayList<SystemEventListener>();
+            }
+
+            return _lstSystemEventListener;
+        }
+
+        private synchronized List<SystemEventListener> getSpecificSourceListenersNotNull(Class<?>
sourceClass)
+        {
+            if (_sourceClassMap == null)
+            {
+                _sourceClassMap = new ConcurrentHashMap<Class<?>, List<SystemEventListener>>();
+            }
+
+            List<SystemEventListener> list = _sourceClassMap.get(sourceClass);
+            if (list == null)
+            {
+                // TODO: Check if modification occurs often or not, might have to use a synchronized

+                //       list instead
+                list = new CopyOnWriteArrayList<SystemEventListener>();
+                _sourceClassMap.put(sourceClass, list);
+            }
+
+            return list;
+        }
+    }
 }

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java?rev=696520&r1=696519&r2=696520&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
Wed Sep 17 16:55:46 2008
@@ -99,6 +99,9 @@
 
     /** @return Iterator over StateManager class names*/
     public Iterator getStateManagerIterator();
+    
+    /** @return Iterator over ResourceHandler class names*/
+    public Iterator getResourceHandlerIterator();
 
     /** @return Iterator over PropertyResolver class names */
     public Iterator<String> getPropertyResolverIterator();

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=696520&r1=696519&r2=696520&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
Wed Sep 17 16:55:46 2008
@@ -47,6 +47,7 @@
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
 import javax.faces.application.NavigationHandler;
+import javax.faces.application.ResourceHandler;
 import javax.faces.application.StateManager;
 import javax.faces.application.ViewHandler;
 import javax.faces.context.ExternalContext;
@@ -636,11 +637,12 @@
 
     private void configureApplication()
     {
-        Application application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
-                .getApplication();
+        Application application = 
+            ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+        
         FacesConfigDispenser dispenser = getDispenser();
-        application.setActionListener((ActionListener) getApplicationObject(ActionListener.class,
dispenser
-                .getActionListenerIterator(), null));
+        application.setActionListener((ActionListener) getApplicationObject(ActionListener.class,

+                dispenser.getActionListenerIterator(), null));
 
         if (dispenser.getDefaultLocale() != null)
         {
@@ -657,20 +659,25 @@
             application.setMessageBundle(dispenser.getMessageBundle());
         }
 
-        application.setNavigationHandler((NavigationHandler) getApplicationObject(NavigationHandler.class,
dispenser
-                .getNavigationHandlerIterator(), application.getNavigationHandler()));
+        application.setNavigationHandler((NavigationHandler) getApplicationObject(NavigationHandler.class,

+                dispenser.getNavigationHandlerIterator(), application.getNavigationHandler()));
+        
+        application.setStateManager((StateManager) getApplicationObject(StateManager.class,

+                dispenser.getStateManagerIterator(), application.getStateManager()));
         
-        application.setStateManager((StateManager) getApplicationObject(StateManager.class,
dispenser
-                .getStateManagerIterator(), application.getStateManager()));
+        application.setResourceHandler((ResourceHandler) getApplicationObject(ResourceHandler.class,

+                dispenser.getResourceHandlerIterator(), application.getResourceHandler()));
+                                                                
         List<Locale> locales = new ArrayList<Locale>();
         for (Iterator it = dispenser.getSupportedLocalesIterator(); it.hasNext();)
         {
             locales.add(LocaleUtils.toLocale((String) it.next()));
         }
+        
         application.setSupportedLocales(locales);
 
-        application.setViewHandler((ViewHandler) getApplicationObject(ViewHandler.class,
dispenser
-                .getViewHandlerIterator(), application.getViewHandler()));
+        application.setViewHandler((ViewHandler) getApplicationObject(ViewHandler.class,
+                dispenser.getViewHandlerIterator(), application.getViewHandler()));
 
         for (Iterator it = dispenser.getComponentTypes(); it.hasNext();)
         {
@@ -689,8 +696,8 @@
             String converterClass = (String) it.next();
             try
             {
-                application.addConverter(ClassUtils.simpleClassForName(converterClass), dispenser
-                        .getConverterClassByClass(converterClass));
+                application.addConverter(ClassUtils.simpleClassForName(converterClass), 
+                    dispenser.getConverterClassByClass(converterClass));
             }
             catch (Exception ex)
             {
@@ -704,8 +711,8 @@
             {
                 String converterClassName = (String) it.next();
 
-                ((ApplicationImpl) application).addConverterConfiguration(converterClassName,
dispenser
-                        .getConverterConfiguration(converterClassName));
+                ((ApplicationImpl) application).addConverterConfiguration(converterClassName,

+                     dispenser.getConverterConfiguration(converterClassName));
             }
         }
 
@@ -717,11 +724,11 @@
 
         RuntimeConfig runtimeConfig = getRuntimeConfig();
         
-        runtimeConfig.setPropertyResolverChainHead((PropertyResolver) getApplicationObject(PropertyResolver.class,
dispenser
-                .getPropertyResolverIterator(), new DefaultPropertyResolver()));
+        runtimeConfig.setPropertyResolverChainHead((PropertyResolver) getApplicationObject(PropertyResolver.class,

+                dispenser.getPropertyResolverIterator(), new DefaultPropertyResolver()));
         
-        runtimeConfig.setVariableResolverChainHead((VariableResolver) getApplicationObject(VariableResolver.class,
dispenser
-                .getVariableResolverIterator(), new VariableResolverImpl()));
+        runtimeConfig.setVariableResolverChainHead((VariableResolver) getApplicationObject(VariableResolver.class,

+                dispenser.getVariableResolverIterator(), new VariableResolverImpl()));
     }
 
     /**
@@ -741,14 +748,15 @@
         _runtimeConfig = runtimeConfig;
     }
 
-    private Object getApplicationObject(Class interfaceClass, Iterator classNamesIterator,
Object defaultObject)
+    @SuppressWarnings("unchecked")
+    private <T> T getApplicationObject(Class<T> interfaceClass, Iterator<String>
classNamesIterator, T defaultObject)
     {
-        Object current = defaultObject;
+        T current = defaultObject;
 
         while (classNamesIterator.hasNext())
         {
             String implClassName = (String) classNamesIterator.next();
-            Class implClass = ClassUtils.simpleClassForName(implClassName);
+            Class<T> implClass = ClassUtils.simpleClassForName(implClassName);
 
             // check, if class is of expected interface type
             if (!interfaceClass.isAssignableFrom(implClass))
@@ -766,7 +774,7 @@
                 // let's check if class supports the decorator pattern
                 try
                 {
-                    Constructor delegationConstructor = implClass.getConstructor(new Class[]
{ interfaceClass });
+                    Constructor<T> delegationConstructor = implClass.getConstructor(new
Class[] { interfaceClass });
                     // impl class supports decorator pattern,
                     try
                     {

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java?rev=696520&r1=696519&r2=696520&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
Wed Sep 17 16:55:46 2008
@@ -61,6 +61,7 @@
     private String messageBundle;
     private List<String> navigationHandlers = new ArrayList<String>();
     private List<String> viewHandlers = new ArrayList<String>();
+    private List<String> resourceHandlers = new ArrayList<String>();
     private List<String> stateManagers = new ArrayList<String>();
     private List<String> propertyResolver = new ArrayList<String>();
     private List<String> variableResolver = new ArrayList<String>();
@@ -116,6 +117,7 @@
             }
             actionListeners.addAll(application.getActionListener());
             navigationHandlers.addAll(application.getNavigationHandler());
+            resourceHandlers.addAll(application.getResourceHandler());
             viewHandlers.addAll(application.getViewHandler());
             stateManagers.addAll(application.getStateManager());
             propertyResolver.addAll(application.getPropertyResolver());
@@ -281,6 +283,15 @@
     }
 
     /**
+     * @return Iterator over ResourceHandler class names
+     */
+    public Iterator<String> getResourceHandlerIterator()
+    {
+        List<String> handlers = new ArrayList<String>(resourceHandlers);
+        return handlers.iterator();
+    }
+
+    /**
      * @return Iterator over ViewHandler class names
      */
     public Iterator<String> getViewHandlerIterator()

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java?rev=696520&r1=696519&r2=696520&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
Wed Sep 17 16:55:46 2008
@@ -56,6 +56,7 @@
         digester.addCallMethod("faces-config/application/default-render-kit-id", "addDefaultRenderkitId",
0);
         digester.addCallMethod("faces-config/application/message-bundle", "addMessageBundle",
0);
         digester.addCallMethod("faces-config/application/navigation-handler", "addNavigationHandler",
0);
+        digester.addCallMethod("faces-config/application/resource-handler", "addResourceHandler",
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);

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Application.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Application.java?rev=696520&r1=696519&r2=696520&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Application.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Application.java
Wed Sep 17 16:55:46 2008
@@ -31,6 +31,7 @@
     private final List<String> defaultRenderkitId = new ArrayList<String>();
     private final List<String> messageBundle = new ArrayList<String>();
     private final List<String> navigationHandler = new ArrayList<String>();
+    private final List<String> resourceHandler = new ArrayList<String>();
     private final List<String> viewHandler = new ArrayList<String>();
     private final List<String> stateManager = new ArrayList<String>();
     private final List<String> propertyResolver = new ArrayList<String>();
@@ -79,6 +80,11 @@
         localeConfig.add(config);
     }
 
+    public void addResourceHandler(String handler)
+    {
+        resourceHandler.add(handler);
+    }
+
     public void addViewHandler(String handler)
     {
         viewHandler.add(handler);
@@ -114,6 +120,11 @@
         return navigationHandler;
     }
 
+    public List<String> getResourceHandler()
+    {
+        return resourceHandler;
+    }
+
     public List<String> getViewHandler()
     {
         return viewHandler;



Mime
View raw message