You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ss...@apache.org on 2006/05/29 05:59:49 UTC

svn commit: r410018 [2/4] - in /myfaces/core/trunk: api/src/main/java/javax/faces/application/ api/src/main/java/javax/faces/component/ api/src/main/java/javax/faces/context/ api/src/main/java/javax/faces/convert/ api/src/main/java/javax/faces/el/ api/...

Added: myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java (added)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java Sun May 28 20:59:46 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 javax.faces.event;
+
+import javax.el.ELContext;
+import javax.el.MethodExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+
+/**
+ * See Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ *
+ * @author Stan Silvert
+ */
+public class MethodExpressionActionListener implements ActionListener, StateHolder {
+    
+    private MethodExpression methodExpression;
+    
+    private boolean isTransient = false;
+    
+    /** Creates a new instance of MethodExpressionActionListener */
+    public MethodExpressionActionListener() {
+    }
+    
+    public MethodExpressionActionListener(MethodExpression methodExpression) {
+        this.methodExpression = methodExpression;
+    }
+
+    public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
+        try {
+            Object[] params = new Object[]{actionEvent};
+            methodExpression.invoke(elContext(), params);
+        } catch (Exception e) {
+            throw new AbortProcessingException(e);
+        }
+    }
+    
+    private ELContext elContext() {
+        return FacesContext.getCurrentInstance().getELContext();
+    }
+    
+    public void restoreState(FacesContext context, Object state) {
+        methodExpression = (MethodExpression)methodExpression;
+    }
+
+    public Object saveState(FacesContext context) {
+        return methodExpression;
+    }
+
+    public void setTransient(boolean newTransientValue) {
+        isTransient = newTransientValue;
+    }
+
+    public boolean isTransient() {
+        return isTransient;
+    }
+    
+}

Added: myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionValueChangeListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionValueChangeListener.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionValueChangeListener.java (added)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/event/MethodExpressionValueChangeListener.java Sun May 28 20:59:46 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 javax.faces.event;
+
+import javax.el.ELContext;
+import javax.el.MethodExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+
+/**
+ * See Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ *
+ * @author Stan Silvert
+ */
+public class MethodExpressionValueChangeListener implements ValueChangeListener, StateHolder {
+    
+    private MethodExpression methodExpression;
+    
+    private boolean isTransient = false;
+    
+    /** Creates a new instance of MethodExpressionValueChangeListener */
+    public MethodExpressionValueChangeListener() {
+    }
+    
+    public MethodExpressionValueChangeListener(MethodExpression methodExpression) {
+        this.methodExpression = methodExpression;
+    }
+    
+    public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
+        try {
+            Object[] params = new Object[]{event};
+            methodExpression.invoke(elContext(), params);
+        } catch (Exception e) {
+            throw new AbortProcessingException(e);
+        }
+    }
+    
+    private ELContext elContext() {
+        return FacesContext.getCurrentInstance().getELContext();
+    }
+    
+    public void restoreState(FacesContext context, Object state) {
+        methodExpression = (MethodExpression)methodExpression;
+    }
+
+    public Object saveState(FacesContext context) {
+        return methodExpression;
+    }
+
+    public void setTransient(boolean newTransientValue) {
+        isTransient = newTransientValue;
+    }
+
+    public boolean isTransient() {
+        return isTransient;
+    }
+
+}

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/render/ResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/render/ResponseStateManager.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/render/ResponseStateManager.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/render/ResponseStateManager.java Sun May 28 20:59:46 2006
@@ -23,17 +23,58 @@
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Manfred Geiler (latest modification by $Author$)
+ * @author Stan Silvert
  * @version $Revision$ $Date$
  */
 public abstract class ResponseStateManager
 {
-    public abstract void writeState(FacesContext context,
-                                    StateManager.SerializedView state)
-            throws IOException;
+    public static final String RENDER_KIT_ID_PARAM = "javax.faces.RenderKitId";
+    public static final String VIEW_STATE_PARAM = "javax.faces.ViewState";
+    
+    // TODO: figure out if this is suppossed to be abstract.  JavaDoc doesn't say.
+    public abstract void writeState(FacesContext context, Object state) throws IOException;
+    
+    /**
+     * @deprecated
+     */
+    public void writeState(FacesContext context,
+                           StateManager.SerializedView state)
+            throws IOException {
+        // does nothing as per JSF 1.2 javadoc
+    }
 
-    public abstract Object getTreeStructureToRestore(FacesContext context,
-                                                     String viewId);
+    /**
+     * @since 1.2
+     */
+    public Object getState(FacesContext context, String viewId) {
+        Object[] structureAndState = new Object[2];
+        structureAndState[0] = getTreeStructureToRestore(context, viewId);
+        structureAndState[1] = getComponentStateToRestore(context);
+        return structureAndState;
+    }
+    
+    
+    /**
+     * @deprecated
+     */
+    public Object getTreeStructureToRestore(FacesContext context,
+                                             String viewId) {
+        return null;
+    }
+    
 
-    public abstract Object getComponentStateToRestore(FacesContext context);
+    /**
+     * @deprecated
+     */
+    public Object getComponentStateToRestore(FacesContext context) {
+        return null;
+    }
+    
+    /**
+     * @since 1.2
+     */
+    public boolean isPostback(FacesContext context) {
+        return context.getExternalContext().getRequestParameterMap().size() > 0;
+    }
 
 }

Added: myfaces/core/trunk/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java (added)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java Sun May 28 20:59:46 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 javax.faces.validator;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ *
+ * @author Stan Silvert
+ */
+public class MethodExpressionValidator implements Validator, StateHolder {
+    
+    private MethodExpression methodExpression;
+    
+    private boolean isTransient = false;
+    
+    /** Creates a new instance of MethodExpressionValidator */
+    public MethodExpressionValidator() {
+    }
+    
+    public MethodExpressionValidator(MethodExpression methodExpression) {
+        if (methodExpression == null) throw new NullPointerException("methodExpression can not be null.");
+        
+        this.methodExpression = methodExpression;
+    }
+
+    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
+        Object[] params = new Object[3];
+        params[0] = context;
+        params[1] = component;
+        params[2] = value;
+        
+        try {
+            methodExpression.invoke(context.getELContext(), params);
+        } catch (ELException e) {
+            throw new ValidatorException(new FacesMessage(), e);
+        }
+    }
+
+    public void restoreState(FacesContext context, Object state) {
+        methodExpression = (MethodExpression)state;
+    }
+
+    public Object saveState(FacesContext context) {
+        return methodExpression;
+    }
+
+    public void setTransient(boolean newTransientValue) {
+        isTransient = newTransientValue;
+    }
+
+    public boolean isTransient() {
+        return isTransient;
+    }
+    
+}

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java Sun May 28 20:59:46 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.myfaces.application;
 
+import javax.servlet.ServletContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Sun May 28 20:59:46 2006
@@ -15,12 +15,29 @@
  */
 package org.apache.myfaces.application;
 
+import java.lang.reflect.Constructor;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELContextListener;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspFactory;
 import org.apache.myfaces.application.jsp.JspStateManagerImpl;
 import org.apache.myfaces.application.jsp.JspViewHandlerImpl;
-import org.apache.myfaces.el.MethodBindingImpl;
-import org.apache.myfaces.el.PropertyResolverImpl;
-import org.apache.myfaces.el.ValueBindingImpl;
-import org.apache.myfaces.el.VariableResolverImpl;
+import org.apache.myfaces.el.NullPropertyResolver;
+import org.apache.myfaces.el.NullVariableResolver;
+import org.apache.myfaces.el.convert.MethodExpressionToMethodBinding;
+import org.apache.myfaces.el.convert.ValueBindingToValueExpression;
+import org.apache.myfaces.el.convert.ValueExpressionToValueBinding;
+import org.apache.myfaces.el.unified.resolver.ResolverForFaces;
+import org.apache.myfaces.el.unified.resolver.ResolverForJSP;
+import org.apache.myfaces.el.convert.ELResolverToPropertyResolver;
+import org.apache.myfaces.el.convert.ELResolverToVariableResolver;
 import org.apache.myfaces.shared_impl.util.BiLevelCacheMap;
 import org.apache.myfaces.shared_impl.util.ClassUtils;
 import org.apache.myfaces.config.impl.digester.elements.Property;
@@ -49,28 +66,19 @@
  * @author Manfred Geiler (latest modification by $Author$)
  * @author Anton Koinov
  * @author Thomas Spiegl
+ * @author Stan Silvert
  * @version $Revision$ $Date$
  */
 public class ApplicationImpl
-    extends Application
-{
+        extends Application {
     private static final Log log = LogFactory.getLog(ApplicationImpl.class);
-
+    
     //~ Instance fields ----------------------------------------------------------------------------
-
-    private final Map            _valueBindingCache =
-        new BiLevelCacheMap(90)
-        {
-            protected Object newInstance(Object key)
-            {
-                return new ValueBindingImpl(ApplicationImpl.this, (String) key);
-            }
-        };
-
+    
     private Collection           _supportedLocales = Collections.EMPTY_SET;
     private Locale               _defaultLocale;
     private String               _messageBundle;
-
+    
     private ViewHandler          _viewHandler;
     private NavigationHandler    _navigationHandler;
     private VariableResolver     _variableResolver;
@@ -78,609 +86,586 @@
     private ActionListener       _actionListener;
     private String               _defaultRenderKitId;
     private StateManager         _stateManager;
-
+    
+    private ServletContext       _servletContext;
+    
+    private ResolverForFaces     _resolverForFaces;
+    private ResolverForJSP       _resolverForJSP;
+    
+    private ExpressionFactory    _expressionFactory;
+    
+    private ArrayList<ELContextListener> _elContextListeners;
+    
     // components, converters, and validators can be added at runtime--must synchronize
     private final Map _converterIdToClassMap = Collections.synchronizedMap(new HashMap());
     private final Map _converterClassNameToClassMap = Collections.synchronizedMap(new HashMap());
     private final Map _converterClassNameToConfigurationMap = Collections.synchronizedMap(new HashMap());
     private final Map _componentClassMap = Collections.synchronizedMap(new HashMap());
     private final Map _validatorClassMap = Collections.synchronizedMap(new HashMap());
-
-
+    
+    
     //~ Constructors -------------------------------------------------------------------------------
-
-    public ApplicationImpl()
-    {
+    
+    public ApplicationImpl() {
         // set default implementation in constructor
         // pragmatic approach, no syncronizing will be needed in get methods
         _viewHandler = new JspViewHandlerImpl();
         _navigationHandler = new NavigationHandlerImpl();
-        _variableResolver = new VariableResolverImpl();
-        _propertyResolver = new PropertyResolverImpl();
+        _variableResolver = new NullVariableResolver();
+        _propertyResolver = new NullPropertyResolver();
         _actionListener = new ActionListenerImpl();
         _defaultRenderKitId = "HTML_BASIC";
         _stateManager = new JspStateManagerImpl();
+        _elContextListeners = new ArrayList();
+        _resolverForFaces =  new ResolverForFaces();
+        _resolverForJSP = null;
+        
         if (log.isTraceEnabled()) log.trace("New Application instance created");
     }
-
+    
     //~ Methods ------------------------------------------------------------------------------------
-
-    public void setActionListener(ActionListener actionListener)
-    {
-        if (actionListener == null)
-        {
-            log.error("setting actionListener to null is not allowed");
-            throw new NullPointerException("setting actionListener to null is not allowed");
-        }
+    
+    // note: this method is not part of the javax.faces.application.Application interface
+    // it must be called by FacesConfigurator or other init mechanism
+    public void setServletContext(ServletContext servletContext) {
+        
+        // this Class.forName will be removed when Tomcat fixes a bug
+        // also, we should then be able to remove jasper.jar from the deployment
+        try {
+            Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        
+        _servletContext = servletContext;
+        ResolverForJSP _resolverForJSP = new ResolverForJSP();
+        
+        System.out.println("factory = " + JspFactory.getDefaultFactory());
+        JspApplicationContext appCtx = JspFactory.getDefaultFactory().getJspApplicationContext(_servletContext);
+        
+        appCtx.addELResolver(_resolverForJSP);
+        
+        _expressionFactory = appCtx.getExpressionFactory();
+    }
+    
+    
+    public void addELResolver(ELResolver resolver) {
+        _resolverForFaces.addResolverFromApplicationAddResolver(resolver);
+        _resolverForJSP.addResolverFromApplicationAddResolver(resolver);
+    }
+    
+    public ELResolver getELResolver() {
+        return _resolverForFaces;
+    }
+    
+    public ResourceBundle getResourceBundle(FacesContext facesContext, String name)
+        throws FacesException, NullPointerException {
+        
+        checkNull(facesContext, "facesContext");
+        checkNull(name, "name");
+        
+        //TODO: implement the rest of this
+        return null;
+    }
+    
+    public UIComponent createComponent(ValueExpression componentExpression,
+            FacesContext facesContext,
+            String componentType)
+            throws FacesException, NullPointerException {
+        
+        checkNull(componentExpression, "componentExpression");
+        checkNull(facesContext, "facesContext");
+        checkNull(componentType, "componentType");
+        
+        Object retVal = componentExpression.getValue(facesContext.getELContext());
+        if (retVal instanceof UIComponent) return (UIComponent)retVal;
+        
+        
+        throw new UnsupportedOperationException("Not implemented yet.");
+    }
+    
+    public ExpressionFactory getExpressionFactory() {
+        return _expressionFactory;
+    }
+    
+    public Object evaluateExpressionGet(FacesContext context, String expression, Class expectedType) throws ELException {
+        ELContext elContext = context.getELContext();
+        return getExpressionFactory()
+               .createValueExpression(elContext, expression, expectedType)
+               .getValue(elContext);
+    }
+    
+    public void addELContextListener(ELContextListener listener) {
+        
+        synchronized (_elContextListeners) {
+            _elContextListeners.add(listener);
+        }
+    }
+    
+    public void removeELContextListener(ELContextListener listener) {
+        synchronized (_elContextListeners) {
+            _elContextListeners.remove(listener);
+        }
+    }
+    
+    public ELContextListener[] getELContextListeners() {
+        // this gets called on every request, so I can't afford to synchronize
+        // I just have to trust that toArray() with do the right thing if the
+        // list is changing (not likely)
+        return _elContextListeners.toArray(new ELContextListener[0]);
+    }
+    
+    public void setActionListener(ActionListener actionListener) {
+        checkNull(actionListener, "actionListener");
+        
         _actionListener = actionListener;
         if (log.isTraceEnabled()) log.trace("set actionListener = " + actionListener.getClass().getName());
     }
-
-    public ActionListener getActionListener()
-    {
+    
+    public ActionListener getActionListener() {
         return _actionListener;
     }
-
-    public Iterator getComponentTypes()
-    {
+    
+    public Iterator getComponentTypes() {
         return _componentClassMap.keySet().iterator();
     }
-
-    public Iterator getConverterIds()
-    {
+    
+    public Iterator getConverterIds() {
         return _converterIdToClassMap.keySet().iterator();
     }
-
-    public Iterator getConverterTypes()
-    {
+    
+    public Iterator getConverterTypes() {
         return _converterClassNameToClassMap.keySet().iterator();
     }
-
-    public void setDefaultLocale(Locale locale)
-    {
-        if (locale == null)
-        {
-            log.error("setting locale to null is not allowed");
-            throw new NullPointerException("setting locale to null is not allowed");
-        }
+    
+    public void setDefaultLocale(Locale locale) {
+        checkNull(locale, "locale");
+        
         _defaultLocale = locale;
         if (log.isTraceEnabled()) log.trace("set defaultLocale = " + locale.getCountry() + " " + locale.getLanguage());
     }
-
-    public Locale getDefaultLocale()
-    {
+    
+    public Locale getDefaultLocale() {
         return _defaultLocale;
     }
-
-    public void setMessageBundle(String messageBundle)
-    {
-        if (messageBundle == null)
-        {
-            log.error("setting messageBundle to null is not allowed");
-            throw new NullPointerException("setting messageBundle to null is not allowed");
-        }
+    
+    public void setMessageBundle(String messageBundle) {
+        checkNull(messageBundle, "messageBundle");
+        
         _messageBundle = messageBundle;
         if (log.isTraceEnabled()) log.trace("set MessageBundle = " + messageBundle);
     }
-
-    public String getMessageBundle()
-    {
+    
+    public String getMessageBundle() {
         return _messageBundle;
     }
-
-    public void setNavigationHandler(NavigationHandler navigationHandler)
-    {
-        if (navigationHandler == null)
-        {
-            log.error("setting navigationHandler to null is not allowed");
-            throw new NullPointerException("setting navigationHandler to null is not allowed");
-        }
+    
+    public void setNavigationHandler(NavigationHandler navigationHandler) {
+        checkNull(navigationHandler, "navigationHandler");
+        
         _navigationHandler = navigationHandler;
         if (log.isTraceEnabled()) log.trace("set NavigationHandler = " + navigationHandler.getClass().getName());
     }
-
-    public NavigationHandler getNavigationHandler()
-    {
+    
+    public NavigationHandler getNavigationHandler() {
         return _navigationHandler;
     }
-
-    public void setPropertyResolver(PropertyResolver propertyResolver)
-    {
-        if (propertyResolver == null)
-        {
-            log.error("setting propertyResolver to null is not allowed");
-            throw new NullPointerException("setting propertyResolver to null is not allowed");
-        }
-        _propertyResolver = propertyResolver;
+    
+    /**
+     * @deprecated
+     */
+    public void setPropertyResolver(PropertyResolver propertyResolver) {
+        checkNull(propertyResolver, "propertyResolver");
+        
+        _resolverForFaces.addResolverFromLegacyPropertyResolver(propertyResolver);
+        
+        // TODO: fix FacesConfigurator so this won't happen
+        if (_resolverForJSP != null) {
+            _resolverForJSP.addResolverFromLegacyPropertyResolver(propertyResolver);
+        }
+        
+        _propertyResolver = new ELResolverToPropertyResolver(getELResolver());
+        
         if (log.isTraceEnabled()) log.trace("set PropertyResolver = " + propertyResolver.getClass().getName());
-   }
-
-    public PropertyResolver getPropertyResolver()
-    {
+    }
+    
+    /**
+     * @deprecated
+     */
+    public PropertyResolver getPropertyResolver() {
         return _propertyResolver;
     }
-
-    public void setSupportedLocales(Collection locales)
-    {
-        if (locales == null)
-        {
-            log.error("setting supportedLocales to null is not allowed");
-            throw new NullPointerException("setting supportedLocales to null is not allowed");
-        }
+    
+    public void setSupportedLocales(Collection locales) {
+        checkNull(locales, "locales");
+        
         _supportedLocales = locales;
         if (log.isTraceEnabled()) log.trace("set SupportedLocales");
     }
-
-    public Iterator getSupportedLocales()
-    {
+    
+    public Iterator getSupportedLocales() {
         return _supportedLocales.iterator();
     }
-
-    public Iterator getValidatorIds()
-    {
+    
+    public Iterator getValidatorIds() {
         return _validatorClassMap.keySet().iterator();
     }
-
-    public void setVariableResolver(VariableResolver variableResolver)
-    {
-        if (variableResolver == null)
-        {
-            log.error("setting variableResolver to null is not allowed");
-            throw new NullPointerException("setting variableResolver to null is not allowed");
-        }
-        _variableResolver = variableResolver;
-        if (log.isTraceEnabled()) log.trace("set VariableResolver = " + variableResolver.getClass().getName());
-    }
-
-    public VariableResolver getVariableResolver()
-    {
+    
+    /**
+     * @deprecated
+     */
+    public void setVariableResolver(VariableResolver variableResolver) {
+        _resolverForFaces.addResolverFromLegacyVariableResolver(variableResolver);
+        
+        // TODO: fix FacesConfigurator so this won't happen
+        if (_resolverForJSP != null) {
+            _resolverForJSP.addResolverFromLegacyVariableResolver(variableResolver);
+        }
+        
+        _variableResolver = new ELResolverToVariableResolver(getELResolver());
+    }
+    
+    /**
+     * @deprecated
+     */
+    public VariableResolver getVariableResolver() {
         return _variableResolver;
     }
-
-    public void setViewHandler(ViewHandler viewHandler)
-    {
-        if (viewHandler == null)
-        {
-            log.error("setting viewHandler to null is not allowed");
-            throw new NullPointerException("setting viewHandler to null is not allowed");
-        }
+    
+    public void setViewHandler(ViewHandler viewHandler) {
+        checkNull(viewHandler, "viewHandler");
+        
         _viewHandler = viewHandler;
         if (log.isTraceEnabled()) log.trace("set ViewHandler = " + viewHandler.getClass().getName());
     }
-
-    public ViewHandler getViewHandler()
-    {
+    
+    public ViewHandler getViewHandler() {
         return _viewHandler;
     }
-
-    public void addComponent(String componentType, String componentClassName)
-    {
-        if ((componentType == null) || (componentType.length() == 0))
-        {
-            log.error("addComponent: componentType = null is not allowed");
-            throw new NullPointerException("addComponent: componentType = null is not allowed");
-        }
-        if ((componentClassName == null) || (componentClassName.length() == 0))
-        {
-            log.error("addComponent: component = null is not allowed");
-            throw new NullPointerException("addComponent: component = null is not allowed");
-        }
-
-        try
-        {
+    
+    public void addComponent(String componentType, String componentClassName) {
+        checkNull(componentType, "componentType");
+        checkEmpty(componentType, "componentType");
+        checkNull(componentClassName, "componentClassName");
+        checkEmpty(componentClassName, "componentClassName");
+        
+        try {
             _componentClassMap.put(componentType, ClassUtils.simpleClassForName(componentClassName));
             if (log.isTraceEnabled()) log.trace("add Component class = " + componentClassName +
-                                                " for type = " + componentType);
-        }
-        catch (Exception e)
-        {
+                    " for type = " + componentType);
+        } catch (Exception e) {
             log.error("Component class " + componentClassName + " not found", e);
         }
     }
-
-    public void addConverter(String converterId, String converterClass)
-    {
-        if ((converterId == null) || (converterId.length() == 0))
-        {
-            log.error("addConverter: converterId = null is not allowed");
-            throw new NullPointerException("addConverter: converterId = null is not allowed");
-        }
-        if ((converterClass == null) || (converterClass.length() == 0))
-        {
-            log.error("addConverter: converterClass = null is not allowed");
-            throw new NullPointerException("addConverter: converterClass = null is not allowed");
-        }
-
-
-        try
-        {
+    
+    public void addConverter(String converterId, String converterClass) {
+        checkNull(converterId, "converterId");
+        checkEmpty(converterId, "converterId");
+        checkNull(converterClass, "converterClass");
+        checkEmpty(converterClass, "converterClass");
+        
+        try {
             _converterIdToClassMap.put(converterId, ClassUtils.simpleClassForName(converterClass));
             if (log.isTraceEnabled()) log.trace("add Converter id = " + converterId +
                     " converterClass = " + converterClass);
-           }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("Converter class " + converterClass + " not found", e);
         }
     }
-
-    public void addConverter(Class targetClass, String converterClass)
-    {
-        if ((targetClass == null))
-        {
-            log.error("addConverter: targetClass = null is not allowed");
-            throw new NullPointerException("addConverter: targetClass = null is not allowed");
-        }
-        if ((converterClass == null) || (converterClass.length() == 0))
-        {
-            log.error("addConverter: converterClass = null is not allowed");
-            throw new NullPointerException("addConverter: converterClass = null is not allowed");
-        }
-
-        try
-        {
+    
+    public void addConverter(Class targetClass, String converterClass) {
+        checkNull(targetClass, "targetClass");
+        checkNull(converterClass, "converterClass");
+        checkEmpty(converterClass, "converterClass");
+        
+        try {
             _converterClassNameToClassMap.put(targetClass, converterClass);
             if (log.isTraceEnabled()) log.trace("add Converter for class = " + targetClass +
                     " converterClass = " + converterClass);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("Converter class " + converterClass + " not found", e);
         }
     }
-
+    
     public void addConverterConfiguration(String converterClassName,
-                                          org.apache.myfaces.config.impl.digester.elements.Converter configuration)
-    {
-        if ((converterClassName == null) || (converterClassName.length() == 0))
-        {
-            log.error("addConverterConfiguration: converterClassName = null is not allowed");
-            throw new NullPointerException("addConverterConfiguration: converterClassName = null is not allowed");
-        }
-        if ((configuration == null))
-        {
-            log.error("addConverterConfiguration: configuration = null is not allowed");
-            throw new NullPointerException("addConverterConfiguration: configuration = null is not allowed");
-        }
-
+            org.apache.myfaces.config.impl.digester.elements.Converter configuration) {
+        checkNull(converterClassName, "converterClassName");
+        checkEmpty(converterClassName, "converterClassName");
+        checkNull(configuration, "configuration");
+        
         _converterClassNameToConfigurationMap.put(converterClassName, configuration);
     }
-
-    public void addValidator(String validatorId, String validatorClass)
-    {
-        if ((validatorId == null) || (validatorId.length() == 0))
-        {
-            log.error("addValidator: validatorId = null is not allowed");
-            throw new NullPointerException("addValidator: validatorId = null is not allowed");
-        }
-        if ((validatorClass == null) || (validatorClass.length() == 0))
-        {
-            log.error("addValidator:  validatorClass = null is not allowed");
-            throw new NullPointerException("addValidator:  validatorClass = null is not allowed");
-        }
-
-        try
-        {
+    
+    public void addValidator(String validatorId, String validatorClass) {
+        checkNull(validatorId, "validatorId");
+        checkEmpty(validatorId, "validatorId");
+        checkNull(validatorClass, "validatorClass");
+        checkEmpty(validatorClass, "validatorClass");
+        
+        try {
             _validatorClassMap.put(validatorId, ClassUtils.simpleClassForName(validatorClass));
             if (log.isTraceEnabled()) log.trace("add Validator id = " + validatorId +
-                                            " class = " + validatorClass);
-        }
-        catch (Exception e)
-        {
+                    " class = " + validatorClass);
+        } catch (Exception e) {
             log.error("Validator class " + validatorClass + " not found", e);
         }
     }
-
+    
     public UIComponent createComponent(String componentType)
-        throws FacesException
-    {
-        if ((componentType == null) || (componentType.length() == 0))
-        {
-            log.error("createComponent: componentType = null is not allowed");
-            throw new NullPointerException("createComponent: componentType = null is not allowed");
-        }
-
+    throws FacesException {
+        checkNull(componentType, "componentType");
+        checkEmpty(componentType, "componentType");
+        
         Class componentClass;
-        synchronized (_componentClassMap)
-        {
+        synchronized (_componentClassMap) {
             componentClass = (Class) _componentClassMap.get(componentType);
         }
-        if (componentClass == null)
-        {
+        if (componentClass == null) {
             log.error("Undefined component type " + componentType);
             throw new FacesException("Undefined component type " + componentType);
         }
-
-        try
-        {
+        
+        try {
             return (UIComponent) componentClass.newInstance();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("Could not instantiate component componentType = " + componentType, e);
             throw new FacesException("Could not instantiate component componentType = " + componentType, e);
         }
     }
-
+    
+    /**
+     * @deprecated Use createComponent(ValueExpression, FacesContext, String) instead.
+     */
     public UIComponent createComponent(ValueBinding valueBinding,
                                        FacesContext facesContext,
                                        String componentType)
-        throws FacesException
-    {        
-        if ((valueBinding == null))
-        {
-            log.error("createComponent: valueBinding = null is not allowed");
-            throw new NullPointerException("createComponent: valueBinding = null is not allowed");
-        }
-        if ((facesContext == null))
-        {
-            log.error("createComponent: facesContext = null is not allowed");
-            throw new NullPointerException("createComponent: facesContext = null is not allowed");
-        }
-        if ((componentType == null) || (componentType.length() == 0))
-        {
-            log.error("createComponent: componentType = null is not allowed");
-            throw new NullPointerException("createComponent: componentType = null is not allowed");
-        }
-
-        Object obj = valueBinding.getValue(facesContext);
-
-        if (obj instanceof UIComponent)
-        {
-         	// check for stale component
-         	UIComponent parent = (UIComponent) obj;
-             while (parent.getParent() != null) {
-         		parent = parent.getParent();
-         	}
-         	if (!(parent instanceof UIViewRoot) || parent == facesContext.getViewRoot()) {
-         		return (UIComponent) obj;
-         	}
-         	else {
-         		log.debug("Stale component found while creating component of type [" + componentType + "]"
-	                    + " for binding [" + valueBinding.getExpressionString() + "]");
-         	}
-
-            return (UIComponent) obj;
-        }
-        else
-        {
-            try {
-            UIComponent component = createComponent(componentType);
-            valueBinding.setValue(facesContext, component);
-            return component;
-            } catch(FacesException ex) {
-                log.error("Exception while creating component of type [" + componentType + "]"
-                        + " for binding [" + valueBinding.getExpressionString() + "]");
-                throw ex;
-            }
-        }
-    }
-
-    public Converter createConverter(String converterId)
-    {
-        if ((converterId == null) || (converterId.length() == 0))
-        {
-            log.error("createConverter: converterId = null is not allowed");
-            throw new NullPointerException("createConverter: converterId = null is not allowed");
-        }
-
+            throws FacesException {
+        
+        checkNull(valueBinding, "valueBinding");
+        checkNull(facesContext, "facesContext");
+        checkNull(componentType, "componentType");
+        checkEmpty(componentType, "componentType");
+        
+        ValueExpression valExpression = new ValueBindingToValueExpression(valueBinding);
+        
+        return createComponent(valExpression, facesContext, componentType);
+    }
+    
+    public Converter createConverter(String converterId) {
+        checkNull(converterId, "converterId");
+        checkEmpty(converterId, "converterId");
+        
         Class converterClass = (Class) _converterIdToClassMap.get(converterId);
-
-        try
-        {
+        
+        try {
             Converter converter= (Converter) converterClass.newInstance();
-
+            
             setConverterProperties(converterClass, converter);
-
+            
             return converter;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("Could not instantiate converter " + converterClass, e);
             throw new FacesException("Could not instantiate converter: " + converterClass, e);
         }
     }
-
-
-    public Converter createConverter(Class targetClass)
-    {
-        if (targetClass == null)
-        {
-            log.error("createConverter: targetClass = null is not allowed");
-            throw new NullPointerException("createConverter: targetClass = null is not allowed");
-        }
-
-        Converter converter;
-        converter = internalCreateConverter(targetClass);
-        return converter;
-    }
-
-
-    private Converter internalCreateConverter(Class targetClass)
-    {
+    
+    
+    public Converter createConverter(Class targetClass) {
+        checkNull(targetClass, "targetClass");
+        
+        return internalCreateConverter(targetClass);
+    }
+    
+    
+    private Converter internalCreateConverter(Class targetClass) {
         // Locate a Converter registered for the target class itself.
         String converterClassName = (String)_converterClassNameToClassMap.get(targetClass);
-
+        
         //Locate a Converter registered for interfaces that are
         // implemented by the target class (directly or indirectly).
-        if (converterClassName == null)
-        {
+        if (converterClassName == null) {
             Class interfaces[] = targetClass.getInterfaces();
-            if (interfaces != null)
-            {
-                for (int i = 0, len = interfaces.length; i < len; i++)
-                {
-                	// search all superinterfaces for a matching converter, create it
+            if (interfaces != null) {
+                for (int i = 0, len = interfaces.length; i < len; i++) {
+                    // search all superinterfaces for a matching converter, create it
                     Converter converter = internalCreateConverter(interfaces[i]);
-                    if (converter != null)
-                    {
+                    if (converter != null) {
                         return converter;
                     }
                 }
             }
         }
-
-        if (converterClassName != null)
-        {
-            try
-            {
+        
+        if (converterClassName != null) {
+            try {
                 Class converterClass = ClassUtils.simpleClassForName(converterClassName);
                 
-                Converter converter = (Converter) converterClass.newInstance();
-
+                Converter converter = null;
+                try {
+                    // look for a constructor that takes a single Class object
+                    // See JSF 1.2 javadoc for Converter
+                    Constructor constructor = converterClass.getConstructor(new Class[]{Class.class});
+                    converter = (Converter)constructor.newInstance(new Object[]{targetClass});
+                } catch (Exception e) {
+                    // if there is no matching constructor use no-arg constructor
+                    converter = (Converter) converterClass.newInstance();
+                }
+                
                 setConverterProperties(converterClass, converter);
-
+                
                 return converter;
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 log.error("Could not instantiate converter " + converterClassName, e);
                 throw new FacesException("Could not instantiate converter: " + converterClassName, e);
             }
         }
-
+        
         //   locate converter for primitive types
-        if (targetClass == Long.TYPE)
-        {
+        if (targetClass == Long.TYPE) {
             return internalCreateConverter(Long.class);
-        } else if (targetClass == Boolean.TYPE)
-        {
+        } else if (targetClass == Boolean.TYPE) {
             return internalCreateConverter(Boolean.class);
-        } else if (targetClass == Double.TYPE)
-        {
+        } else if (targetClass == Double.TYPE) {
             return internalCreateConverter(Double.class);
-        } else if (targetClass == Byte.TYPE)
-        {
+        } else if (targetClass == Byte.TYPE) {
             return internalCreateConverter(Byte.class);
-        } else if (targetClass == Short.TYPE)
-        {
+        } else if (targetClass == Short.TYPE) {
             return internalCreateConverter(Short.class);
-        } else if (targetClass == Integer.TYPE)
-        {
+        } else if (targetClass == Integer.TYPE) {
             return internalCreateConverter(Integer.class);
-        } else if (targetClass == Float.TYPE)
-        {
+        } else if (targetClass == Float.TYPE) {
             return internalCreateConverter(Float.class);
-        } else if (targetClass == Character.TYPE)
-        {
+        } else if (targetClass == Character.TYPE) {
             return internalCreateConverter(Character.class);
         }
-
-
+        
+        
         //Locate a Converter registered for the superclass (if any) of the target class,
         // recursively working up the inheritance hierarchy.
         Class superClazz = targetClass.getSuperclass();
-        if (superClazz != null)
-        {
+        if (superClazz != null) {
             return internalCreateConverter(superClazz);
-        }
-        else
-        {
+        } else {
             return null;
         }
-
+        
     }
-
-    private void setConverterProperties(Class converterClass, Converter converter)
-    {
+    
+    private void setConverterProperties(Class converterClass, Converter converter) {
         org.apache.myfaces.config.impl.digester.elements.Converter converterConfig =
                 (org.apache.myfaces.config.impl.digester.elements.Converter)
-                    _converterClassNameToConfigurationMap.get(converterClass.getName());
-
-        if(converterConfig != null)
-        {
-
+                _converterClassNameToConfigurationMap.get(converterClass.getName());
+        
+        if(converterConfig != null) {
+            
             Iterator it = converterConfig.getProperties();
-
-            while (it.hasNext())
-            {
+            
+            while (it.hasNext()) {
                 Property property = (Property) it.next();
-
-                try
-                {
+                
+                try {
                     BeanUtils.setProperty(converter,property.getPropertyName(),property.getDefaultValue());
-                }
-                catch(Throwable th)
-                {
+                } catch(Throwable th) {
                     log.error("Initializing converter : "+converterClass.getName()+" with property : "+
                             property.getPropertyName()+" and value : "+property.getDefaultValue()+" failed.");
                 }
             }
         }
     }
-
-
-    public synchronized MethodBinding createMethodBinding(String reference, Class[] params)
-        throws ReferenceSyntaxException
-    {
-        if ((reference == null) || (reference.length() == 0))
-        {
-            log.error("createMethodBinding: reference = null is not allowed");
-            throw new NullPointerException("createMethodBinding: reference = null is not allowed");
-        }
-
-        // We choose to instantiate a new MethodBinding every time as this is much easier
-        // and about as efficient as implementing a cache specifically for MethodBinding,
-        // which is complicated by the need to use a conposite key=(reference, params)
-        // (significant part of MethodBinding is already cached by ValueBinding implicitly)
-        return new MethodBindingImpl(this, reference, params);
-    }
-
-    public Validator createValidator(String validatorId) throws FacesException
-    {
-        if ((validatorId == null) || (validatorId.length() == 0))
-        {
-            log.error("createValidator: validatorId = null is not allowed");
-            throw new NullPointerException("createValidator: validatorId = null is not allowed");
-        }
-
+    
+    
+    // Note: this method used to be synchronized in the JSF 1.1 version.  Why?
+    /**
+     * @deprecated
+     */
+    public MethodBinding createMethodBinding(String reference, Class[] params)
+    throws ReferenceSyntaxException {
+        checkNull(reference, "reference");
+        checkEmpty(reference, "reference");
+        
+        if (params == null) params = new Class[0];
+        
+        MethodExpression methodExpression;
+        
+        try {
+            methodExpression = getExpressionFactory()
+            .createMethodExpression(threadELContext(), reference, Object.class, params);
+        } catch (ELException e) {
+            throw new ReferenceSyntaxException(e);
+        }
+        
+        return new MethodExpressionToMethodBinding(methodExpression);
+    }
+    
+    public Validator createValidator(String validatorId) throws FacesException {
+        checkNull(validatorId, "validatorId");
+        checkEmpty(validatorId, "validatorId");
+        
         Class validatorClass = (Class) _validatorClassMap.get(validatorId);
-        if (validatorClass == null)
-        {
+        if (validatorClass == null) {
             String message = "Unknown validator id '" + validatorId + "'.";
             log.error(message);
             throw new FacesException(message);
         }
-
-        try
-        {
+        
+        try {
             return (Validator) validatorClass.newInstance();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("Could not instantiate validator " + validatorClass, e);
             throw new FacesException("Could not instantiate validator: " + validatorClass, e);
         }
     }
-
-    public ValueBinding createValueBinding(String reference) throws ReferenceSyntaxException
-    {
-        if ((reference == null) || (reference.length() == 0))
-        {
-            log.error("createValueBinding: reference = null is not allowed");
-            throw new NullPointerException("createValueBinding: reference = null is not allowed");
-        }
-        return (ValueBinding) _valueBindingCache.get(reference);
-    }
-
-
-    public String getDefaultRenderKitId()
-    {
+    
+    /**
+     * @deprecated
+     */
+    public ValueBinding createValueBinding(String reference) throws ReferenceSyntaxException {
+        checkNull(reference, "reference");
+        checkEmpty(reference, "reference");
+        
+        ValueExpression valueExpression;
+        
+        try {
+            valueExpression = getExpressionFactory()
+            .createValueExpression(threadELContext(), reference, Object.class);
+        } catch (ELException e) {
+            throw new ReferenceSyntaxException(e);
+        }
+        
+        return new ValueExpressionToValueBinding(valueExpression);
+    }
+    
+    // gets the elContext from the current FacesContext()
+    private ELContext threadELContext() {
+        return FacesContext.getCurrentInstance().getELContext();
+    }
+    
+    
+    public String getDefaultRenderKitId() {
         return _defaultRenderKitId;
     }
-
-    public void setDefaultRenderKitId(String defaultRenderKitId)
-    {
+    
+    public void setDefaultRenderKitId(String defaultRenderKitId) {
         _defaultRenderKitId = defaultRenderKitId;
     }
-
-    public StateManager getStateManager()
-    {
+    
+    public StateManager getStateManager() {
         return _stateManager;
     }
-
-    public void setStateManager(StateManager stateManager)
-    {
+    
+    public void setStateManager(StateManager stateManager) {
         _stateManager = stateManager;
+    }
+    
+    private void checkNull(Object param, String paramName) {
+        if (param == null) {
+            throw new NullPointerException(paramName + " can not be null.");
+        }
+    }
+    
+    private void checkEmpty(String param, String paramName) {
+        if (param.length() == 0) {
+            throw new NullPointerException("String " + paramName + " can not be empty.");
+        }
     }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Sun May 28 20:59:46 2006
@@ -15,39 +15,7 @@
  */
 package org.apache.myfaces.config;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.application.NavigationHandler;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.el.PropertyResolver;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.ActionListener;
-import javax.faces.event.PhaseListener;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.webapp.FacesServlet;
-
+import javax.servlet.ServletContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.application.ApplicationFactoryImpl;
@@ -65,6 +33,28 @@
 import org.apache.myfaces.shared_impl.util.LocaleUtils;
 import org.xml.sax.SAXException;
 
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.*;
+import javax.faces.context.ExternalContext;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.webapp.FacesServlet;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.*;
+
 
 /**
  * Configures everything for a given context.
@@ -112,7 +102,7 @@
     }
 
 
-    public void configure()
+    public void configure(ServletContext servletContext)
         throws FacesException
     {
         //These two classes can be easily replaced by alternative implementations.
@@ -138,7 +128,7 @@
         }
 
         configureFactories();
-        configureApplication();
+        configureApplication(servletContext);
         configureRenderKits();
         configureRuntimeConfig();
         configureLifecycle();
@@ -169,7 +159,7 @@
                 while (it.hasNext())
                 {
                     URL url = (URL)it.next();
-                    InputStream stream = openStreamWithoutCache(url);
+                    InputStream stream = url.openStream();
                     InputStreamReader isr = new InputStreamReader(stream);
                     BufferedReader br = new BufferedReader(isr);
                     String className;
@@ -213,25 +203,18 @@
         }
     }
 
-    private InputStream openStreamWithoutCache(URL url)
-            throws IOException
-    {
-        URLConnection connection = url.openConnection();
-        connection.setUseCaches(false);
-        return connection.getInputStream();
-    }
 
     /*private Map expandFactoryNames(Set factoryNames)
-   {
-       Map names = new HashMap();
-       Iterator itr = factoryNames.iterator();
-       while (itr.hasNext())
-       {
-           String name = (String) itr.next();
-           names.put(META_INF_SERVICES_LOCATION + name, name);
-       }
-       return names;
-   } */
+    {
+        Map names = new HashMap();
+        Iterator itr = factoryNames.iterator();
+        while (itr.hasNext())
+        {
+            String name = (String) itr.next();
+            names.put(META_INF_SERVICES_LOCATION + name, name);
+        }
+        return names;
+    } */
 
 
     /**
@@ -245,7 +228,7 @@
             while (it.hasNext())
             {
                 URL url = (URL)it.next();
-                InputStream stream = openStreamWithoutCache(url);
+                InputStream stream = url.openStream();
                 String systemId = url.toExternalForm();
                 if (log.isInfoEnabled()) log.info("Reading config " + systemId);
                 _dispenser.feed(_unmarshaller.getFacesConfig(stream, systemId));
@@ -259,7 +242,7 @@
     }
 
 
-    /*
+    /**
      * To make this easier AND to fix MYFACES-208 at the same time, this method is replaced by
      * {@link FacesConfigurator#feedClassloaderConfigurations}
      *
@@ -434,9 +417,16 @@
     }
 
 
-    private void configureApplication()
+    private void configureApplication(ServletContext servletContext)
     {
         Application application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+
+        if (application instanceof ApplicationImpl) {
+            ApplicationImpl appImpl = (ApplicationImpl)application;
+            appImpl.setServletContext(servletContext);
+        }
+         
+        
         application.setActionListener((ActionListener) getApplicationObject(ActionListener.class, _dispenser.getActionListenerIterator(), null));
 
         if (_dispenser.getDefaultLocale() != null)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java Sun May 28 20:59:46 2006
@@ -15,8 +15,11 @@
  */
 package org.apache.myfaces.config;
 
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
 import org.apache.myfaces.config.element.*;
-import org.apache.myfaces.shared_impl.util.ClassUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -25,12 +28,11 @@
 import javax.faces.application.Application;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ExternalContext;
-import javax.faces.el.PropertyResolver;
-import javax.faces.el.ValueBinding;
-import javax.faces.el.EvaluationException;
 import javax.faces.webapp.UIComponentTag;
 import java.util.*;
 import java.lang.reflect.Array;
+import javax.el.ELException;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
 
 
 /**
@@ -60,7 +62,7 @@
                           e.getMessage()
                               + " for bean '"
                               + beanConfiguration.getManagedBeanName()
-                              + "' check the configuration to make sure all properties correspond with get/set methods");
+                              + "' check the configuration to make sure all properties correspond with get/set methods", e);
                 }
                 break;
 
@@ -101,9 +103,9 @@
 
     private void initializeProperties(FacesContext facesContext, Iterator managedProperties, String targetScope, Object bean)
     {
-        PropertyResolver propertyResolver =
-            facesContext.getApplication().getPropertyResolver();
-
+        ELResolver elResolver = facesContext.getApplication().getELResolver();
+        ELContext elContext = facesContext.getELContext();
+        
         while (managedProperties.hasNext())
         {
             ManagedProperty property = (ManagedProperty) managedProperties.next();
@@ -118,7 +120,7 @@
                 	// If the getter returns null or doesn't exist, create a java.util.ArrayList,
                 	// otherwise use the returned Object ...
                 	if(PropertyUtils.isReadable(bean, property.getPropertyName()))
-                		value = propertyResolver.getValue(bean, property.getPropertyName());
+                		value = elResolver.getValue(elContext, bean, property.getPropertyName());
                 	value = value == null ? new ArrayList() : value;
                 	
                     if (value instanceof List) {
@@ -150,7 +152,7 @@
                 	// If the getter returns null or doesn't exist, create a java.util.HashMap,
                 	// otherwise use the returned java.util.Map .
                 	if(PropertyUtils.isReadable(bean, property.getPropertyName()))
-                		value = propertyResolver.getValue(bean, property.getPropertyName());
+                		value = elResolver.getValue(elContext, bean, property.getPropertyName());
                 	value = value == null ? new HashMap() : value;
                 	
                     if (! (value instanceof Map)) {
@@ -175,8 +177,8 @@
 
             if (property.getPropertyClass() == null)
             {
-                propertyClass = propertyResolver
-                    .getType(bean, property.getPropertyName());
+                propertyClass = elResolver
+                    .getType(elContext, bean, property.getPropertyName());
             }
             else
             {
@@ -186,9 +188,31 @@
             if(null == propertyClass) {
               throw new IllegalArgumentException("unable to find the type of property " + property.getPropertyName());
             }
-            Object coercedValue = ClassUtils.convertToType(value, propertyClass);
-            propertyResolver.setValue(
-                bean, property.getPropertyName(), coercedValue);
+            Object coercedValue = coerceToType(facesContext, value, propertyClass);
+            elResolver.setValue(
+                elContext, bean, property.getPropertyName(), coercedValue);
+        }
+    }
+    
+    // We no longer use the convertToType from shared impl because we switched
+    // to unified EL in JSF 1.2
+    public static Object coerceToType(FacesContext facesContext, Object value, Class desiredClass)
+    {
+        if (value == null) return null;
+
+        try
+        {
+            ExpressionFactory expFactory = facesContext.getApplication().getExpressionFactory();
+            // Use coersion implemented by JSP EL for consistency with EL
+            // expressions. Additionally, it caches some of the coersions.
+            return expFactory.coerceToType(value, desiredClass);
+        }
+        catch (ELException e)
+        {
+            String message = "Cannot coerce " + value.getClass().getName()
+                             + " to " + desiredClass.getName();
+            log.error(message, e);
+            throw new FacesException(message, e);
         }
     }
 
@@ -367,7 +391,7 @@
             index = tmp.indexOf('"', 1);
 
             if (index < 0) {
-                throw new EvaluationException(tmp);
+                throw new ELException(tmp);
             }
             return tmp.substring(1, index);
         }
@@ -375,7 +399,7 @@
             index = tmp.indexOf('\'', 1);
 
             if (index < 0) {
-                throw new EvaluationException(tmp);
+                throw new ELException(tmp);
             }
             return tmp.substring(1, index);
         }
@@ -383,7 +407,7 @@
         index = tmp.indexOf(']');
 
         if (index < 0) {
-            throw new EvaluationException(tmp);
+            throw new ELException(tmp);
         }
 
         return tmp.substring(1, index);
@@ -413,8 +437,10 @@
             ? String.class : ClassUtils.simpleJavaTypeToClass(mapEntries.getKeyClass());
         Class valueClass = (mapEntries.getValueClass() == null)
             ? String.class : ClassUtils.simpleJavaTypeToClass(mapEntries.getValueClass());
-        ValueBinding valueBinding;
-
+        ValueExpression valueExpression;
+        ExpressionFactory expFactory = application.getExpressionFactory();
+        ELContext elContext = facesContext.getELContext();
+        
         for (Iterator iterator = mapEntries.getMapEntries(); iterator.hasNext();)
         {
             MapEntry entry = (MapEntry) iterator.next();
@@ -422,23 +448,23 @@
 
             if (UIComponentTag.isValueReference((String) key))
             {
-                valueBinding = application.createValueBinding((String) key);
-                key = valueBinding.getValue(facesContext);
+                valueExpression = expFactory.createValueExpression(elContext, (String) key, Object.class);
+                key = valueExpression.getValue(elContext);
             }
 
             if (entry.isNullValue())
             {
-                map.put(ClassUtils.convertToType(key, keyClass), null);
+                map.put(coerceToType(facesContext, key, keyClass), null);
             }
             else
             {
                 Object value = entry.getValue();
                 if (UIComponentTag.isValueReference((String) value))
                 {
-                    valueBinding = application.createValueBinding((String) value);
-                    value = valueBinding.getValue(facesContext);
+                    valueExpression = expFactory.createValueExpression(elContext, (String) value, Object.class);
+                    value = valueExpression.getValue(elContext);
                 }
-                map.put(ClassUtils.convertToType(key, keyClass), ClassUtils.convertToType(value, valueClass));
+                map.put(coerceToType(facesContext, key, keyClass), coerceToType(facesContext, value, valueClass));
             }
         }
     }
@@ -448,7 +474,8 @@
     {
         Application application = facesContext.getApplication();
         Class valueClass = listEntries.getValueClass() == null ? String.class : ClassUtils.simpleJavaTypeToClass(listEntries.getValueClass());
-        ValueBinding valueBinding;
+        ExpressionFactory expFactory = application.getExpressionFactory();
+        ELContext elContext = facesContext.getELContext();
 
         for (Iterator iterator = listEntries.getListEntries(); iterator.hasNext();)
         {
@@ -462,10 +489,10 @@
                 Object value = entry.getValue();
                 if (UIComponentTag.isValueReference((String) value))
                 {
-                    valueBinding = application.createValueBinding((String) value);
-                    value = valueBinding.getValue(facesContext);
+                    ValueExpression valueExpression = expFactory.createValueExpression(elContext, (String) value, Object.class);
+                    value = valueExpression.getValue(elContext);
                 }
-                list.add(ClassUtils.convertToType(value, valueClass));
+                list.add(coerceToType(facesContext, value, valueClass));
             }
         }
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java Sun May 28 20:59:46 2006
@@ -58,16 +58,9 @@
      */
     public Collection getNavigationRules()
     {
-        return _navigationRules == null ?
-                null : Collections.unmodifiableCollection(_navigationRules);
+        return Collections.unmodifiableCollection(_navigationRules);
     }
 
-    public Map getManagedBeans()
-    {
-        return _managedBeans == null ?
-                null : Collections.unmodifiableMap(_managedBeans);
-    }
-    
     public void addNavigationRule(NavigationRule navigationRule)
     {
         _navigationRules.add(navigationRule);
@@ -92,6 +85,10 @@
     public ManagedBean getManagedBean(String name)
     {
         return (ManagedBean)_managedBeans.get(name);
+    }
+    
+    public Map<String, ManagedBean> getManagedBeans() {
+        return Collections.unmodifiableMap(_managedBeans);
     }
 
     public void addManagedBean(String name, ManagedBean managedBean)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ManagedBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ManagedBean.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ManagedBean.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ManagedBean.java Sun May 28 20:59:46 2006
@@ -32,6 +32,7 @@
     public static final int INIT_MODE_MAP = 2;
     public static final int INIT_MODE_LIST = 3;
 
+    public String getDescription();
     public String getManagedBeanName();
     public String getManagedBeanClassName();
     public Class getManagedBeanClass();

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java Sun May 28 20:59:46 2006
@@ -100,6 +100,7 @@
 
         digester.addObjectCreate("faces-config/managed-bean", ManagedBean.class);
         digester.addSetNext("faces-config/managed-bean", "addManagedBean");
+        digester.addCallMethod("faces-config/managed-bean/description", "setDescription", 0);
         digester.addCallMethod("faces-config/managed-bean/managed-bean-name", "setName", 0);
         digester.addCallMethod("faces-config/managed-bean/managed-bean-class", "setBeanClass", 0);
         digester.addCallMethod("faces-config/managed-bean/managed-bean-scope", "setScope", 0);

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ManagedBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ManagedBean.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ManagedBean.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ManagedBean.java Sun May 28 20:59:46 2006
@@ -28,6 +28,7 @@
 public class ManagedBean implements org.apache.myfaces.config.element.ManagedBean
 {
 
+    private String description;
     private String name;
     private String beanClassName;
     private Class beanClass;
@@ -77,6 +78,14 @@
     }
 
 
+    public String getDescription() {
+        return description;
+    }
+    
+    public void setDescription(String description) {
+        this.description = description;
+    }
+    
     public String getManagedBeanName()
     {
         return name;

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/FacesContextWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/FacesContextWrapper.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/FacesContextWrapper.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/FacesContextWrapper.java Sun May 28 20:59:46 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.myfaces.context;
 
+import javax.el.ELContext;
 import javax.faces.application.Application;
 import javax.faces.application.FacesMessage;
 import javax.faces.application.FacesMessage.Severity;
@@ -142,5 +143,10 @@
     public void responseComplete()
     {
         _facesContext.responseComplete();
+    }
+    
+    public ELContext getELContext()
+    {
+        return _facesContext.getELContext();
     }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/PortletExternalContextImpl.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/PortletExternalContextImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/PortletExternalContextImpl.java Sun May 28 20:59:46 2006
@@ -241,6 +241,10 @@
         return _portletRequest;
     }
 
+    public String getRequestContentType() {
+        return null;
+    }
+    
     public String getRequestContextPath() {
         return _portletRequest.getContextPath();
     }
@@ -331,6 +335,10 @@
         return _portletResponse;
     }
 
+    public String getResponseContentType() {
+        return null;
+    }
+    
     public Object getSession(boolean create) {
         return _portletRequest.getPortletSession(create);
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/SessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/SessionMap.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/SessionMap.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/portlet/SessionMap.java Sun May 28 20:59:46 2006
@@ -78,8 +78,18 @@
     }
 
 
+    /**
+     * This will clear the session without invalidation.  If no session has
+     * been created, it will simply return.
+     */
     public void clear()
     {
-        throw new UnsupportedOperationException();
+        PortletSession session = getSession();
+        if (session == null) return;
+        for (Enumeration attributeNames = session.getAttributeNames(PortletSession.PORTLET_SCOPE); 
+             attributeNames.hasMoreElements(); ) {
+            String attributeName = (String)attributeNames.nextElement();
+            session.removeAttribute(attributeName);
+        }
     }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java Sun May 28 20:59:46 2006
@@ -212,6 +212,11 @@
         return _servletResponse;
     }
 
+    public String getResponseContentType()
+    {
+        return _servletResponse.getContentType();
+    }
+    
     public Map getApplicationMap()
     {
         if (_applicationMap == null)
@@ -336,6 +341,10 @@
         return _requestPathInfo;
     }
 
+    public String getRequestContentType() {
+        return _servletRequest.getContentType();
+    }
+    
     public String getRequestContextPath()
     {
         if (!_isHttpServletRequest)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java Sun May 28 20:59:46 2006
@@ -15,6 +15,10 @@
  */
 package org.apache.myfaces.context.servlet;
 
+import javax.el.ELContext;
+import javax.el.ELContextEvent;
+import javax.el.ELContextListener;
+import org.apache.myfaces.el.unified.FacesELContext;
 import org.apache.myfaces.shared_impl.util.NullIterator;
 
 import javax.faces.FactoryFinder;
@@ -61,6 +65,7 @@
     private boolean                     _responseComplete = false;
     private RenderKitFactory            _renderKitFactory;
     private boolean                     _released = false;
+    private ELContext                   _elContext;
 
     //~ Constructors -------------------------------------------------------------------------------
 
@@ -307,7 +312,6 @@
         _responseStream       = null;
         _responseWriter       = null;
         _viewRoot             = null;
-        _maximumSeverity      = null;
 
         _released             = true;
         FacesContext.setCurrentInstance(null);
@@ -336,4 +340,19 @@
         _externalContext = extContext;
         FacesContext.setCurrentInstance(this); //TODO: figure out if I really need to do this
     }
+
+    public ELContext getELContext() {
+        if (_elContext != null) return _elContext;
+        
+        
+        _elContext = new FacesELContext(getApplication().getELResolver(), this);
+        
+        ELContextEvent event = new ELContextEvent(_elContext);
+        for (ELContextListener listener : getApplication().getELContextListeners()) {
+            listener.contextCreated(event);
+        }
+        
+        return _elContext;
+    }
+    
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/SessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/SessionMap.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/SessionMap.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/SessionMap.java Sun May 28 20:59:46 2006
@@ -21,6 +21,7 @@
 import javax.servlet.http.HttpSession;
 import java.util.Enumeration;
 import java.util.Map;
+import javax.portlet.PortletSession;
 
 
 /**
@@ -78,9 +79,18 @@
         throw new UnsupportedOperationException();
     }
 
-
+    /**
+     * This will clear the session without invalidation.  If no session has
+     * been created, it will simply return.
+     */
     public void clear()
     {
-        throw new UnsupportedOperationException();
+        HttpSession session = getSession();
+        if (session == null) return;
+        for (Enumeration attributeNames = session.getAttributeNames(); 
+             attributeNames.hasMoreElements(); ) {
+            String attributeName = (String)attributeNames.nextElement();
+            session.removeAttribute(attributeName);
+        }
     }
 }

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullPropertyResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullPropertyResolver.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullPropertyResolver.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullPropertyResolver.java Sun May 28 20:59:46 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el;
+
+import javax.el.ELContext;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.PropertyResolver;
+
+/**
+ * Default PropertyResolver.  See JSF 1.2 spec section 5.8.2
+ *
+ * @author Stan Silvert
+ */
+public class NullPropertyResolver extends PropertyResolver {
+    
+    /** Creates a new instance of NullPropertyResolver */
+    public NullPropertyResolver() {
+    }
+
+    public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+        return false;
+    }
+    
+    public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+        return false;
+    }
+
+    public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+        return null;
+    }
+    
+    public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+        return null;
+    }
+
+    public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+        return null;
+    }
+    
+     public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+        return null;
+    }
+
+    public void setValue(Object base, Object property, Object value) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+    }
+
+    public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException {
+        elContext().setPropertyResolved(false);
+    }
+
+    private ELContext elContext() {
+        return FacesContext.getCurrentInstance().getELContext();
+    }
+    
+}

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullVariableResolver.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullVariableResolver.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/NullVariableResolver.java Sun May 28 20:59:46 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.VariableResolver;
+
+/**
+ * This is the default VariableResolver.  See JSF 1.2 spec section 5.8.1
+ *
+ * @author Stan Silvert
+ */
+public class NullVariableResolver extends VariableResolver {
+    
+    /** Creates a new instance of NullVariableResolver */
+    public NullVariableResolver() {
+    }
+
+    public Object resolveVariable(FacesContext facesContext, String name) 
+        throws EvaluationException {
+        
+        facesContext.getELContext().setPropertyResolved(false);
+        
+        return null;
+    }
+    
+}