myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r511499 - in /myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config: FacesConfigDispenser.java FacesConfigValidator.java FacesConfigurator.java RuntimeConfig.java
Date Sun, 25 Feb 2007 13:04:50 GMT
Author: mbr
Date: Sun Feb 25 05:04:50 2007
New Revision: 511499

URL: http://svn.apache.org/viewvc?view=rev&rev=511499
Log:
added faces-config el-resolver handling
work in progress for MYFACES-1274

Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigValidator.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java?view=diff&rev=511499&r1=511498&r2=511499
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
Sun Feb 25 05:04:50 2007
@@ -21,7 +21,7 @@
 import org.apache.myfaces.config.impl.digester.elements.Converter;
 import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
 
-import javax.faces.event.PhaseListener;
+import javax.el.ELResolver;
 
 import java.util.Iterator;
 
@@ -173,7 +173,12 @@
     public Iterator<String> getLifecyclePhaseListeners();
 
     /**
-     * @return
+     * @return Iterator over {@link ResourceBundle}
      */
     public Iterator<ResourceBundle> getResourceBundles();
+
+    /**
+     * @return Iterator over {@link ELResolver} implementation class names
+     */
+    public Iterator<String> getElResolvers();
 }

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigValidator.java?view=diff&rev=511499&r1=511498&r2=511499
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigValidator.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigValidator.java
Sun Feb 25 05:04:50 2007
@@ -40,7 +40,7 @@
         // hidden 
     }
 
-    public static List validate(ExternalContext ctx, String ctxPath){
+    public static List<String> validate(ExternalContext ctx, String ctxPath){
         
         RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(ctx);
         
@@ -50,16 +50,16 @@
                                 managedBeansMap.values() == null ? null :
                                     managedBeansMap.values().iterator();
         
-        Iterator navRules = runtimeConfig.getNavigationRules() == null ? 
+        Iterator<NavigationRule> navRules = runtimeConfig.getNavigationRules() == null
? 
                             null : runtimeConfig.getNavigationRules().iterator();
         
         return validate(managedBeans, navRules, ctxPath);
         
     }
     
-    public static List validate(Iterator managedBeans, Iterator navRules, String ctxPath){
+    public static List<String> validate(Iterator managedBeans, Iterator<NavigationRule>
navRules, String ctxPath){
         
-        List list = new ArrayList();
+        List<String> list = new ArrayList<String>();
         
         if(navRules != null)
             validateNavRules(navRules, list, ctxPath);
@@ -70,11 +70,11 @@
         return list;
     }
 
-    private static void validateNavRules(Iterator navRules, List list, String ctxPath){
+    private static void validateNavRules(Iterator<NavigationRule> navRules, List<String>
list, String ctxPath){
         
         while(navRules.hasNext()){
             
-            NavigationRule navRule = (NavigationRule) navRules.next();
+            NavigationRule navRule = navRules.next();
             
             validateNavRule(navRule, list, ctxPath);
             
@@ -82,7 +82,7 @@
         
     }
     
-    private static void validateNavRule(NavigationRule navRule, List list, String ctxPath){
+    private static void validateNavRule(NavigationRule navRule, List<String> list,
String ctxPath){
         
         String fromId = navRule.getFromViewId();
         String filePath = ctxPath + fromId;
@@ -107,7 +107,7 @@
         
     }
     
-    private static void validateManagedBeans(Iterator managedBeans, List list){
+    private static void validateManagedBeans(Iterator managedBeans, List<String> list){
         
         while(managedBeans.hasNext()){
             
@@ -119,7 +119,7 @@
         
     }
 
-    private static void validateManagedBean(ManagedBean managedBean, List list){
+    private static void validateManagedBean(ManagedBean managedBean, List<String> list){
         
         String className = managedBean.getManagedBeanClassName();
         

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?view=diff&rev=511499&r1=511498&r2=511499
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
Sun Feb 25 05:04:50 2007
@@ -29,6 +29,8 @@
 import org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl;
 import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
 import org.apache.myfaces.context.FacesContextFactoryImpl;
+import org.apache.myfaces.el.DefaultPropertyResolver;
+import org.apache.myfaces.el.VariableResolverImpl;
 import org.apache.myfaces.lifecycle.LifecycleFactoryImpl;
 import org.apache.myfaces.renderkit.RenderKitFactoryImpl;
 import org.apache.myfaces.renderkit.html.HtmlRenderKitImpl;
@@ -37,8 +39,10 @@
 import org.apache.myfaces.shared_impl.util.StateUtils;
 import org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory;
 import org.apache.myfaces.shared_impl.util.serial.SerialFactory;
+
 import org.xml.sax.SAXException;
 
+import javax.el.ELResolver;
 import javax.faces.FacesException;
 import javax.faces.FactoryFinder;
 import javax.faces.application.Application;
@@ -81,6 +85,7 @@
  * @author Manfred Geiler (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
+@SuppressWarnings("deprecation")
 public class FacesConfigurator
 {
     private static final Log log = LogFactory.getLog(FacesConfigurator.class);
@@ -109,6 +114,8 @@
     private final ExternalContext _externalContext;
     private FacesConfigUnmarshaller _unmarshaller;
     private FacesConfigDispenser _dispenser;
+
+    private RuntimeConfig _runtimeConfig;
     private static final String JAR_EXTENSION = ".jar";
     private static final String META_INF_MANIFEST_SUFFIX = "!/META-INF/MANIFEST.MF";
     private static final String JAR_PREFIX = "jar:";
@@ -569,8 +576,7 @@
 
         application.setNavigationHandler((NavigationHandler) getApplicationObject(NavigationHandler.class,
dispenser
                 .getNavigationHandlerIterator(), application.getNavigationHandler()));
-        application.setPropertyResolver((PropertyResolver) getApplicationObject(PropertyResolver.class,
dispenser
-                .getPropertyResolverIterator(), application.getPropertyResolver()));
+        
         application.setStateManager((StateManager) getApplicationObject(StateManager.class,
dispenser
                 .getStateManagerIterator(), application.getStateManager()));
         List<Locale> locales = new ArrayList<Locale>();
@@ -580,8 +586,6 @@
         }
         application.setSupportedLocales(locales);
 
-        application.setVariableResolver((VariableResolver) getApplicationObject(VariableResolver.class,
dispenser
-                .getVariableResolverIterator(), application.getVariableResolver()));
         application.setViewHandler((ViewHandler) getApplicationObject(ViewHandler.class,
dispenser
                 .getViewHandlerIterator(), application.getViewHandler()));
 
@@ -627,6 +631,31 @@
             String validatorId = (String) it.next();
             application.addValidator(validatorId, dispenser.getValidatorClass(validatorId));
         }
+
+        RuntimeConfig runtimeConfig = getRuntimeConfig();
+        
+        runtimeConfig.setPropertyResolverChainHead((PropertyResolver) getApplicationObject(PropertyResolver.class,
dispenser
+                .getPropertyResolverIterator(), new DefaultPropertyResolver()));
+        
+        runtimeConfig.setVariableResolverChainHead((VariableResolver) getApplicationObject(VariableResolver.class,
dispenser
+                .getVariableResolverIterator(), new VariableResolverImpl()));
+    }
+
+    /**
+     * @return
+     */
+    protected RuntimeConfig getRuntimeConfig()
+    {
+        if(_runtimeConfig == null) 
+        {
+            _runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
+        }
+        return _runtimeConfig;
+    }
+    
+    public void setRuntimeConfig(RuntimeConfig runtimeConfig)
+    {
+        _runtimeConfig = runtimeConfig;
     }
 
     private Object getApplicationObject(Class interfaceClass, Iterator classNamesIterator,
Object defaultObject)
@@ -715,6 +744,11 @@
         for (Iterator<ResourceBundle> iter = dispenser.getResourceBundles(); iter.hasNext();)
         {
             runtimeConfig.addResourceBundle(iter.next());
+        }
+        
+        for (Iterator<String> iter = dispenser.getElResolvers(); iter.hasNext();)
+        {
+            runtimeConfig.addFacesConfigElResolver((ELResolver) ClassUtils.newInstance(iter.next(),
ELResolver.class));
         }
     }
 

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java?view=diff&rev=511499&r1=511498&r2=511499
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
Sun Feb 25 05:04:50 2007
@@ -21,7 +21,12 @@
 import org.apache.myfaces.config.element.NavigationRule;
 import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
 
+import javax.el.CompositeELResolver;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
 import javax.faces.context.ExternalContext;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.VariableResolver;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -30,48 +35,53 @@
 import java.util.Map;
 
 /**
- * Holds all configuration information (from the faces-config xml files) that is
- * needed later during runtime. The config information in this class is only
- * available to the MyFaces core implementation classes (i.e. the myfaces source
- * tree). See MyfacesConfig for config parameters that can be used for shared or
- * component classes.
+ * Holds all configuration information (from the faces-config xml files) that is needed later
during runtime. The config
+ * information in this class is only available to the MyFaces core implementation classes
(i.e. the myfaces source
+ * tree). See MyfacesConfig for config parameters that can be used for shared or component
classes.
  * 
  * @author Manfred Geiler (latest modification by $Author$)
- * @version $Revision$ $Date: 2006-05-29 05:59:46 +0200 (Mo, 29 Mai
- *          2006) $
+ * @version $Revision$ $Date$
  */
+@SuppressWarnings("deprecation")
 public class RuntimeConfig
 {
     private static final Log log = LogFactory.getLog(RuntimeConfig.class);
 
-    private static final String APPLICATION_MAP_PARAM_NAME = RuntimeConfig.class
-            .getName();
+    private static final String APPLICATION_MAP_PARAM_NAME = RuntimeConfig.class.getName();
 
     private final Collection<NavigationRule> _navigationRules = new ArrayList<NavigationRule>();
     private final Map<String, ManagedBean> _managedBeans = new HashMap<String, ManagedBean>();
     private boolean _navigationRulesChanged = false;
     private final Map<String, ResourceBundle> _resourceBundles = new HashMap<String,
ResourceBundle>();
 
-    public static RuntimeConfig getCurrentInstance(
-            ExternalContext externalContext)
+    private CompositeELResolver facesConfigElResolvers;
+    private CompositeELResolver applicationElResolvers;
+
+    private VariableResolver _variableResolver;
+    private PropertyResolver _propertyResolver;
+
+    private ExpressionFactory _expressionFactory;
+
+    private PropertyResolver _propertyResolverChainHead;
+
+    private VariableResolver _variableResolverChainHead;
+
+    public static RuntimeConfig getCurrentInstance(ExternalContext externalContext)
     {
-        RuntimeConfig runtimeConfig = (RuntimeConfig) externalContext
-                .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
+        RuntimeConfig runtimeConfig = (RuntimeConfig) externalContext.getApplicationMap().get(
+                APPLICATION_MAP_PARAM_NAME);
         if (runtimeConfig == null)
         {
             runtimeConfig = new RuntimeConfig();
-            externalContext.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME,
-                    runtimeConfig);
+            externalContext.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, runtimeConfig);
         }
         return runtimeConfig;
     }
 
     /**
-     * Return the navigation rules that can be used by the NavigationHandler
-     * implementation.
+     * Return the navigation rules that can be used by the NavigationHandler implementation.
      * 
-     * @return a Collection of
-     *         {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
+     * @return a Collection of {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
      */
     public Collection<NavigationRule> getNavigationRules()
     {
@@ -96,11 +106,9 @@
     }
 
     /**
-     * Return the managed bean info that can be used by the VariableResolver
-     * implementation.
+     * Return the managed bean info that can be used by the VariableResolver implementation.
      * 
-     * @return a
-     *         {@link org.apache.myfaces.config.element.ManagedBean ManagedBean}
+     * @return a {@link org.apache.myfaces.config.element.ManagedBean ManagedBean}
      */
     public ManagedBean getManagedBean(String name)
     {
@@ -118,8 +126,7 @@
     }
 
     /**
-     * Return the resourcebundle which was configured in faces config by var
-     * name
+     * Return the resourcebundle which was configured in faces config by var name
      * 
      * @param name
      *            the name of the resource bundle (content of var)
@@ -147,15 +154,89 @@
         String var = bundle.getVar();
         if (_resourceBundles.containsKey(var) && log.isWarnEnabled())
         {
-            log
-                    .warn("Another resource bundle for var '" + var
-                            + "' with base name '"
-                            + _resourceBundles.get(var).getBaseName()
-                            + "' is already registered. '"
-                            + _resourceBundles.get(var).getBaseName()
-                            + "' will be replaced with '"
-                            + bundle.getBaseName() + "'.");
+            log.warn("Another resource bundle for var '" + var + "' with base name '"
+                    + _resourceBundles.get(var).getBaseName() + "' is already registered.
'"
+                    + _resourceBundles.get(var).getBaseName() + "' will be replaced with
'" + bundle.getBaseName()
+                    + "'.");
         }
         _resourceBundles.put(var, bundle);
+    }
+
+    public void addFacesConfigElResolver(ELResolver resolver)
+    {
+        if (facesConfigElResolvers == null)
+        {
+            facesConfigElResolvers = new CompositeELResolver();
+        }
+        facesConfigElResolvers.add(resolver);
+    }
+
+    public ELResolver getFacesConfigElResolvers()
+    {
+        return facesConfigElResolvers;
+    }
+
+    public void addApplicationElResolver(ELResolver resolver)
+    {
+        if (applicationElResolvers == null)
+        {
+            applicationElResolvers = new CompositeELResolver();
+        }
+        applicationElResolvers.add(resolver);
+    }
+
+    public ELResolver getApplicationElResolvers()
+    {
+        return applicationElResolvers;
+    }
+
+    public void setVariableResolver(VariableResolver variableResolver)
+    {
+        _variableResolver = variableResolver;
+    }
+
+    public VariableResolver getVariableResolver()
+    {
+        return _variableResolver;
+    }
+
+    public void setPropertyResolver(PropertyResolver propertyResolver)
+    {
+        _propertyResolver = propertyResolver;
+    }
+
+    public PropertyResolver getPropertyResolver()
+    {
+        return _propertyResolver;
+    }
+
+    public ExpressionFactory getExpressionFactory()
+    {
+        return _expressionFactory;
+    }
+
+    public void setExpressionFactory(ExpressionFactory expressionFactory)
+    {
+        _expressionFactory = expressionFactory;
+    }
+
+    public void setPropertyResolverChainHead(PropertyResolver resolver)
+    {
+        _propertyResolverChainHead = resolver;
+    }
+
+    public PropertyResolver getPropertyResolverChainHead()
+    {
+        return _propertyResolverChainHead;
+    }
+
+    public void setVariableResolverChainHead(VariableResolver resolver)
+    {
+        _variableResolverChainHead = resolver;
+    }
+
+    public VariableResolver getVariableResolverChainHead()
+    {
+        return _variableResolverChainHead;
     }
 }



Mime
View raw message