You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2007/02/25 14:47:50 UTC
svn commit: r511514 [1/2] - in /myfaces/core/branches/jsf12/impl/src:
main/java/org/apache/myfaces/application/ main/java/org/apache/myfaces/el/
main/java/org/apache/myfaces/el/convert/
main/java/org/apache/myfaces/el/unified/ main/java/org/apache/myfa...
Author: mbr
Date: Sun Feb 25 05:47:48 2007
New Revision: 511514
URL: http://svn.apache.org/viewvc?view=rev&rev=511514
Log:
various fixes for MYFACES-1274:
faces config el-resolver support
fix resolver for faces/jsp setup
VariableResolverImpl do not handle manged beans
Application#getVariableResolver() and Application#getPropertyResolver
removed MethodBindingImpl (replaced by unified EL)
removed ValueBindingImpl (replaced by unified EL)
improve initialization of myfaces through ServletContextListener
+formatting
+generics used
TODO: tests
Added:
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverFactoryForFaces.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/FacesCompositeELResolver.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/DefaultFacesInitializer.java (with props)
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializer.java (with props)
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/el/unified/
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/el/unified/NoOpElResolver.java (with props)
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/el/unified/NoOpPropertyResolver.java (with props)
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/el/unified/ResolverBuilderBaseTest.java (with props)
Removed:
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/MethodBindingImpl.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ValueBindingImpl.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CustomResolverBase.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ResolverForFaces.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ResolverForJSP.java
Modified:
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverImpl.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServlet.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?view=diff&rev=511514&r1=511513&r2=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Sun Feb 25 05:47:48 2007
@@ -23,17 +23,18 @@
import org.apache.myfaces.config.RuntimeConfig;
import org.apache.myfaces.config.impl.digester.elements.Property;
import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
-import org.apache.myfaces.el.NullPropertyResolver;
-import org.apache.myfaces.el.NullVariableResolver;
-import org.apache.myfaces.el.convert.ELResolverToPropertyResolver;
-import org.apache.myfaces.el.convert.ELResolverToVariableResolver;
+import org.apache.myfaces.el.PropertyResolverImpl;
+import org.apache.myfaces.el.VariableResolverImpl;
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.unified.ELResolverBuilder;
+import org.apache.myfaces.el.unified.ResolverFactoryForFaces;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
import org.apache.myfaces.shared_impl.util.ClassUtils;
+import javax.el.CompositeELResolver;
import javax.el.ELContext;
import javax.el.ELContextListener;
import javax.el.ELException;
@@ -48,7 +49,6 @@
import javax.faces.application.ViewHandler;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.el.MethodBinding;
@@ -58,9 +58,6 @@
import javax.faces.el.VariableResolver;
import javax.faces.event.ActionListener;
import javax.faces.validator.Validator;
-import javax.servlet.ServletContext;
-import javax.servlet.jsp.JspApplicationContext;
-import javax.servlet.jsp.JspFactory;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@@ -81,10 +78,18 @@
* @author Stan Silvert
* @version $Revision$ $Date$
*/
+@SuppressWarnings("deprecation")
public class ApplicationImpl extends Application
{
private static final Log log = LogFactory.getLog(ApplicationImpl.class);
+ private final static VariableResolver VARIABLERESOLVER = new VariableResolverImpl();
+
+ private final static PropertyResolver PROPERTYRESOLVER = new PropertyResolverImpl();
+
+ // recives the runtime config instance during initializing
+ private final static ThreadLocal<RuntimeConfig> initializingRuntimeConfig = new ThreadLocal<RuntimeConfig>();
+
// ~ Instance fields
// ----------------------------------------------------------------------------
@@ -94,19 +99,10 @@
private ViewHandler _viewHandler;
private NavigationHandler _navigationHandler;
- private VariableResolver _variableResolver;
- private PropertyResolver _propertyResolver;
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
@@ -119,70 +115,101 @@
private final Map<String, Class> _componentClassMap = Collections.synchronizedMap(new HashMap<String, Class>());
private final Map<String, Class> _validatorClassMap = Collections.synchronizedMap(new HashMap<String, Class>());
+ private final RuntimeConfig _runtimeConfig;
+
+ private ELResolver elResolver;
+
+ private ELResolverBuilder resolverFactoryForFaces;
+
// ~ Constructors
// -------------------------------------------------------------------------------
public ApplicationImpl()
{
+ this(internalGetRuntimeConfig());
+ }
+
+ private static RuntimeConfig internalGetRuntimeConfig()
+ {
+ if (initializingRuntimeConfig.get() == null)
+ {
+ throw new IllegalStateException("The runtime config instance which is created while initialize myfaces "
+ + "must be set through ApplicationImpl.setInitializingRuntimeConfig");
+ }
+ return initializingRuntimeConfig.get();
+ }
+
+ ApplicationImpl(RuntimeConfig runtimeConfig)
+ {
+ if (runtimeConfig == null)
+ {
+ throw new IllegalArgumentException("runtimeConfig must mot be null");
+ }
// set default implementation in constructor
// pragmatic approach, no syncronizing will be needed in get methods
_viewHandler = new JspViewHandlerImpl();
_navigationHandler = new NavigationHandlerImpl();
- _variableResolver = new NullVariableResolver();
- _propertyResolver = new NullPropertyResolver();
_actionListener = new ActionListenerImpl();
_defaultRenderKitId = "HTML_BASIC";
_stateManager = new JspStateManagerImpl();
_elContextListeners = new ArrayList<ELContextListener>();
- _resolverForFaces = new ResolverForFaces();
- _resolverForJSP = null;
+ _runtimeConfig = runtimeConfig;
if (log.isTraceEnabled())
log.trace("New Application instance created");
}
+ public static void setInitializingRuntimeConfig(RuntimeConfig config)
+ {
+ initializingRuntimeConfig.set(config);
+ }
+
// ~ Methods
// ------------------------------------------------------------------------------------
- // 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)
+ @Override
+ public void addELResolver(ELResolver resolver)
{
-
- // 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
+ if (FacesContext.getCurrentInstance() != null)
{
- Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
+ throw new IllegalStateException("It is illegal to add a resolver after the first request is processed");
}
- catch (Exception e)
+ if (resolver != null)
{
- e.printStackTrace();
+ _runtimeConfig.addApplicationElResolver(resolver);
}
+ }
- _servletContext = servletContext;
- ResolverForJSP _resolverForJSP = new ResolverForJSP();
-
- log.debug("factory = " + JspFactory.getDefaultFactory());
- JspApplicationContext appCtx = JspFactory.getDefaultFactory().getJspApplicationContext(_servletContext);
-
- appCtx.addELResolver(_resolverForJSP);
+ @Override
+ public ELResolver getELResolver()
+ {
+ // we don't need synchronization here since it is ok to have multiple instances of the elresolver
+ if (elResolver == null)
+ {
+ elResolver = createFacesResolver();
+ }
+ return elResolver;
+ }
- _expressionFactory = appCtx.getExpressionFactory();
+ private ELResolver createFacesResolver()
+ {
+ CompositeELResolver resolver = new FacesCompositeELResolver(Scope.Faces);
+ getResolverFactoryForFaces().build(resolver);
+ return resolver;
}
- @Override
- public void addELResolver(ELResolver resolver)
+ protected ELResolverBuilder getResolverFactoryForFaces()
{
- _resolverForFaces.addResolverFromApplicationAddResolver(resolver);
- _resolverForJSP.addResolverFromApplicationAddResolver(resolver);
+ if (resolverFactoryForFaces == null)
+ {
+ resolverFactoryForFaces = new ResolverFactoryForFaces(_runtimeConfig);
+ }
+ return resolverFactoryForFaces;
}
- @Override
- public ELResolver getELResolver()
+ public void setResolverFactoryForFaces(ELResolverBuilder factory)
{
- return _resolverForFaces;
+ resolverFactoryForFaces = factory;
}
@Override
@@ -193,7 +220,7 @@
checkNull(facesContext, "facesContext");
checkNull(name, "name");
- String bundleName = getBundleName(name);
+ String bundleName = getBundleName(facesContext, name);
if (bundleName == null)
{
@@ -223,9 +250,9 @@
return Thread.currentThread().getContextClassLoader();
}
- String getBundleName(String name)
+ String getBundleName(FacesContext facesContext, String name)
{
- ResourceBundle bundle = getRuntimeConfig().getResourceBundle(name);
+ ResourceBundle bundle = getRuntimeConfig(facesContext).getResourceBundle(name);
return bundle != null ? bundle.getBaseName() : null;
}
@@ -235,14 +262,9 @@
return java.util.ResourceBundle.getBundle(name, locale, loader);
}
- RuntimeConfig getRuntimeConfig()
+ RuntimeConfig getRuntimeConfig(FacesContext facesContext)
{
- return RuntimeConfig.getCurrentInstance(getExternalContext());
- }
-
- ExternalContext getExternalContext()
- {
- return getFaceContext().getExternalContext();
+ return RuntimeConfig.getCurrentInstance(facesContext.getExternalContext());
}
FacesContext getFaceContext()
@@ -288,7 +310,7 @@
@Override
public ExpressionFactory getExpressionFactory()
{
- return _expressionFactory;
+ return _runtimeConfig.getExpressionFactory();
}
@Override
@@ -422,15 +444,7 @@
throw new IllegalStateException("propertyResolver must be defined before request processing");
}
- _resolverForFaces.addResolverFromLegacyPropertyResolver(propertyResolver);
-
- // TODO: fix FacesConfigurator so this won't happen
- if (_resolverForJSP != null)
- {
- _resolverForJSP.addResolverFromLegacyPropertyResolver(propertyResolver);
- }
-
- _propertyResolver = new ELResolverToPropertyResolver(getELResolver());
+ _runtimeConfig.setPropertyResolver(propertyResolver);
if (log.isTraceEnabled())
log.trace("set PropertyResolver = " + propertyResolver.getClass().getName());
@@ -443,7 +457,7 @@
@Override
public PropertyResolver getPropertyResolver()
{
- return _propertyResolver;
+ return PROPERTYRESOLVER;
}
@Override
@@ -482,15 +496,10 @@
throw new IllegalStateException("variableResolver must be defined before request processing");
}
- _resolverForFaces.addResolverFromLegacyVariableResolver(variableResolver);
-
- // TODO: fix FacesConfigurator so this won't happen
- if (_resolverForJSP != null)
- {
- _resolverForJSP.addResolverFromLegacyVariableResolver(variableResolver);
- }
+ _runtimeConfig.setVariableResolver(variableResolver);
- _variableResolver = new ELResolverToVariableResolver(getELResolver());
+ if (log.isTraceEnabled())
+ log.trace("set VariableResolver = " + variableResolver.getClass().getName());
}
/**
@@ -500,7 +509,7 @@
@Override
public VariableResolver getVariableResolver()
{
- return _variableResolver;
+ return VARIABLERESOLVER;
}
@Override
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java?view=auto&rev=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java Sun Feb 25 05:47:48 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.el;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.PropertyResolver;
+
+/**
+ * Implements the default property resolver see spec section 5.8.2.
+ *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class DefaultPropertyResolver extends PropertyResolver
+{
+ private void updatePropertyResolved()
+ {
+ FacesContext.getCurrentInstance().getELContext().setPropertyResolved(false);
+ }
+
+ @Override
+ public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ return null;
+ }
+
+ @Override
+ public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ return null;
+ }
+
+ @Override
+ public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ return null;
+ }
+
+ @Override
+ public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ return false;
+ }
+
+ @Override
+ public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ return false;
+ }
+
+ @Override
+ public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ }
+
+ @Override
+ public void setValue(Object base, Object property, Object value) throws EvaluationException,
+ PropertyNotFoundException
+ {
+ updatePropertyResolved();
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/DefaultPropertyResolver.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java?view=diff&rev=511514&r1=511513&r2=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java Sun Feb 25 05:47:48 2007
@@ -15,488 +15,162 @@
*/
package org.apache.myfaces.el;
-import org.apache.commons.beanutils.MethodUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.PropertyResolver;
-import javax.faces.el.ReferenceSyntaxException;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
/**
* @author Manfred Geiler (latest modification by $Author$)
* @author Anton Koinov
* @version $Revision$ $Date$
*/
+@SuppressWarnings("deprecation")
public class PropertyResolverImpl extends PropertyResolver
{
- private static final Log log =
- LogFactory.getLog(PropertyResolverImpl.class);
-
- //~ Static fields/initializers ---------------------------------------------
-
- private static final Object[] NO_ARGS = {};
-
- //~ Public PropertyResolver Methods ----------------------------------------
-
- public Object getValue(Object base, Object property)
- throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- if(base == null)
- {
- if(log.isDebugEnabled())
- log.debug("property : "+property +" could not be retrieved as base was null.");
-
- return null;
- }
-
- //fix for myfaces-315 - empty string as key to a map-value is allowed
- //thanks to duffy gillman
- if (property == null ||
- (property instanceof String && ((String)property).length() == 0 &&
- !(base instanceof Map)))
- {
- if(log.isDebugEnabled())
- log.debug("property for base with class: "+ base.getClass().getName() +" could not be retrieved as property was null.");
-
- return null;
- }
- if (base instanceof Map)
- {
- return ((Map) base).get(property);
- }
-
- // If none of the special bean types, then process as normal Bean
- return getProperty(base, property.toString());
- }
- catch (PropertyNotFoundException e) {
-
- if(log.isDebugEnabled())
- log.debug("Exception while retrieving property; base with class : "+base.getClass().getName()+", property : "+property,e);
-
- throw e;
- }
- catch (RuntimeException e)
- {
- if(log.isDebugEnabled())
- log.debug("Exception while retrieving property; base : "+base.getClass().getName()+", property : "+property,e);
-
- throw new EvaluationException("Exception getting value of property " + property
- + " of base of type : "
- + base.getClass().getName(), e);
- }
- }
+ // ~ Public PropertyResolver Methods
+ // ----------------------------------------
- public Object getValue(Object base, int index)
- throws EvaluationException, PropertyNotFoundException
+ @Override
+ public Object getValue(final Object base, final Object property) throws EvaluationException,
+ PropertyNotFoundException
{
- try
+ return invokeResolver(new ResolverInvoker<Object>(base, property)
{
- if (base == null)
+ public Object invoke(ELResolver resolver, ELContext context)
{
- log.debug("index : "+index+" not retrievable cause base is null.");
- return null;
- }
-
- try
- {
- if (base.getClass().isArray())
- {
- return Array.get(base, index);
- }
- if (base instanceof List)
- {
- return ((List) base).get(index);
- }
- }
- catch (IndexOutOfBoundsException e)
- {
- if(log.isDebugEnabled())
- log.debug("IndexOutOfBoundException while getting property; base with class: "+base.getClass().getName()+", index : "+index,e);
-
- // Note: ArrayIndexOutOfBoundsException also here
- return null;
+ return getELResolver().getValue(getELContext(), base, property);
}
-
- throw new ReferenceSyntaxException("Must be array or List. Bean with class: "
- + base.getClass().getName() + ", index " + index);
- }
- catch (RuntimeException e)
- {
- if(log.isDebugEnabled())
- log.debug("Exception while getting property; base with class: "+base.getClass().getName()+", index : "+index,e);
-
- throw new EvaluationException("Exception getting value for index " + index
- + " of bean "
- + base != null ? base.getClass().getName() : "NULL", e);
- }
+ });
}
- public void setValue(Object base, Object property, Object newValue)
- throws EvaluationException, PropertyNotFoundException
+ @Override
+ public Object getValue(final Object base, final int index) throws EvaluationException, PropertyNotFoundException
{
- try
- {
- if (base == null)
- {
- throw new PropertyNotFoundException(
- "Null bean, property: " + property);
- }
- if (property == null ||
- property instanceof String && ((String)property).length() == 0)
- {
- throw new PropertyNotFoundException("Bean with class : "
- + base.getClass().getName()
- + ", null or empty property name");
- }
-
- if (base instanceof Map)
- {
- ((Map) base).put(property, newValue);
-
- return;
- }
-
- // If none of the special bean types, then process as normal Bean
- setProperty(base, property.toString(), newValue);
- }
- catch (PropertyNotFoundException e) {
- if(log.isDebugEnabled())
- log.debug("Exception while setting property; base with class : "+base.getClass().getName()+", property : "+property,e);
- throw e;
- }
- catch (RuntimeException e)
- {
- if(log.isDebugEnabled())
- log.debug("Exception while setting property; base : "+base.getClass().getName()+", property : "+property,e);
-
- throw new EvaluationException("Exception setting property " + property
- + " of base with class "
- + base.getClass().getName(), e);
- }
+ return getValue(base, new Integer(index));
}
- public void setValue(Object base, int index, Object newValue)
- throws EvaluationException, PropertyNotFoundException
+ @Override
+ public void setValue(final Object base, final Object property, final Object newValue) throws EvaluationException,
+ PropertyNotFoundException
{
- try
+ invokeResolver(new ResolverInvoker<Object>(base, property)
{
- if (base == null)
+ @Override
+ public Object invoke(ELResolver resolver, ELContext context)
{
- throw new PropertyNotFoundException(
- "Null bean, index: " + index);
+ resolver.setValue(context, base, property, newValue);
+ return null;
}
- try
- {
- if (base.getClass().isArray())
- {
- Array.set(base, index, newValue);
-
- return;
- }
- if (base instanceof List)
- {
- // REVISIT: should we try to grow the list, if growable type
- // (e.g., ArrayList, etc.), and if not large
- // enough?
- ((List) base).set(index, newValue);
-
- return;
- }
- }
- catch (IndexOutOfBoundsException e)
+ @Override
+ String getMessage()
{
- throw new PropertyNotFoundException("Base with class : "
- + base.getClass().getName() + ", index " + index, e);
+ return super.getMessage() + " newValue: '" + newValue + "'";
}
+ });
+ }
- throw new EvaluationException(
- "Bean must be array or List. Base with class: "
- + base.getClass().getName() + ", index " + index);
- }
- catch (PropertyNotFoundException e) {
- throw e;
- }
- catch (RuntimeException e)
- {
- throw new EvaluationException("Exception setting value of index " + index + " of bean "
- + base.getClass().getName(), e);
- }
+ @Override
+ public void setValue(Object base, int index, Object newValue) throws EvaluationException, PropertyNotFoundException
+ {
+ setValue(base, new Integer(index), newValue);
}
- public boolean isReadOnly(Object base, Object property)
+ @Override
+ public boolean isReadOnly(final Object base, final Object property)
{
- try
+ return invokeResolver(new ResolverInvoker<Boolean>(base, property)
{
- if (base == null || property == null ||
- property instanceof String && ((String)property).length() == 0)
+ public Boolean invoke(ELResolver resolver, ELContext context)
{
- // Cannot determine read-only, return false (is this what the spec requires?)
- return false;
+ return Boolean.valueOf(getELResolver().isReadOnly(getELContext(), base, property));
}
-
- // Is there any way to determine whether Map.put() will fail?
- if (base instanceof Map)
- {
- return false;
- }
-
- // If none of the special bean types, then process as normal Bean
- PropertyDescriptor propertyDescriptor =
- getPropertyDescriptor(base, property.toString());
-
- return propertyDescriptor.getWriteMethod() == null;
- }
- catch (Exception e)
- {
- // Cannot determine read-only, return false (is this what the spec requires?)
- return false;
- }
+ });
}
+ @Override
public boolean isReadOnly(Object base, int index)
{
- try
- {
- /*todo: actually implement something here*/
- if (base == null)
- {
- // Cannot determine read-only, return false (is this what the spec requires?)
- return false;
- }
- if (base instanceof List || base.getClass().isArray())
- {
- // Is there any way to determine whether List.set() will fail?
- return false;
- }
-
- // Cannot determine read-only, return false (is this what the spec requires?)
- return false;
- }
- catch (Exception e)
- {
- // Cannot determine read-only, return false (is this what the spec requires?)
- return false;
- }
+ return isReadOnly(base, new Integer(index));
}
- public Class getType(Object base, Object property)
+ @Override
+ public Class getType(final Object base, final Object property)
{
- try
+ return invokeResolver(new ResolverInvoker<Class>(base, property)
{
- if (base == null)
- {
- throw new PropertyNotFoundException("Base bean is null.");
- }
- else if (property == null)
- {
- throw new PropertyNotFoundException("Property name is null.");
- }
- else if (property instanceof String && ((String)property).length() == 0)
- {
- throw new PropertyNotFoundException("Property name is an empty String.");
- }
-
- if (base instanceof Map)
+ public Class invoke(ELResolver resolver, ELContext context)
{
- Object value = ((Map) base).get(property);
-
- // REVISIT: when generics are imlemented in JVM 1.5
- return (value == null) ? Object.class : value.getClass();
+ return resolver.getType(context, base, property);
}
-
- // If none of the special bean types, then process as normal Bean
- PropertyDescriptor propertyDescriptor =
- getPropertyDescriptor(base, property.toString());
-
- return propertyDescriptor.getPropertyType();
- }
- catch (PropertyNotFoundException e) {
- throw e;
- }
- catch (Exception e)
- {
- return null;
- }
+ });
}
+ @Override
public Class getType(Object base, int index)
{
- if (base == null)
- {
- throw new PropertyNotFoundException("Bean is null");
- }
-
- try
- {
- if (base.getClass().isArray())
- {
- if (base instanceof Object[] && ((Object[])base)[index] != null) {
- Object[] array = (Object[]) base;
- return array[index].getClass().getComponentType();
- } else {
- return base.getClass().getComponentType();
- }
- }
-
- if (base instanceof List)
- {
- // REVISIT: does it make sense to do this or simply return
- // Object.class? What if the new value is not of
- // the old value's class?
- Object value = ((List) base).get(index);
-
- // REVISIT: when generics are implemented in JVM 1.5
- return (value != null) ? value.getClass() : Object.class;
- }
-
- // Cannot determine type, return null per JSF spec
- return null;
- }
- catch (IndexOutOfBoundsException e) {
- throw new PropertyNotFoundException("Bean: "
- + base.getClass().getName() + ", index " + index, e);
- }
- catch (Exception e)
- {
- throw new EvaluationException("Exception getting type of index " + index + " of bean with class : "
- + base.getClass().getName(), e);
- }
+ return getType(base, new Integer(index));
}
+ // ~ Internal Helper Methods
+ // ------------------------------------------------
- //~ Internal Helper Methods ------------------------------------------------
-
- public static void setProperty(Object base, String name, Object newValue)
+ ELContext getELContext()
{
- PropertyDescriptor propertyDescriptor =
- getPropertyDescriptor(base, name);
-
- Method m = propertyDescriptor.getWriteMethod();
- if (m == null)
- {
- throw new PropertyNotFoundException(
- getMessage(base, name)+ " (no write method for property!)");
- }
-
- // Check if the concrete class of this method is accessible and if not
- // search for a public interface that declares this method
- m = MethodUtils.getAccessibleMethod(m);
- if (m == null)
- {
- throw new PropertyNotFoundException(
- getMessage(base, name) + " (not accessible!)");
- }
-
- try
- {
- m.invoke(base, new Object[] {newValue});
- }
- catch (Throwable t)
- {
- log.debug("Exception while invoking setter method.",t);
- throw new EvaluationException(getMessage(base, name, newValue, m), t);
- }
+ return getFacesContext().getELContext();
}
- private static String getMessage(Object base, String name, Object newValue, Method m)
+ ELResolver getELResolver()
{
- return "Bean: "
- + base.getClass().getName() + ", property: " + name +", newValue: "+(newValue==null?" null ":newValue)+
- ",newValue class: "+(newValue==null?" null ":newValue.getClass().getName())+" method parameter class: "
- +((m.getParameterTypes()!=null&&m.getParameterTypes().length>0)
- ?m.getParameterTypes()[0].getName():"null");
-
+ return getFacesContext().getApplication().getELResolver();
}
- private static String getMessage(Object base, String name)
+ FacesContext getFacesContext()
{
- return "Bean: "
- + base.getClass().getName() + ", property: " + name;
+ return FacesContext.getCurrentInstance();
}
- public static Object getProperty(Object base, String name)
+ <T> T invokeResolver(ResolverInvoker<T> invoker) throws EvaluationException, PropertyNotFoundException
{
- PropertyDescriptor propertyDescriptor =
- getPropertyDescriptor(base, name);
-
- Method m = propertyDescriptor.getReadMethod();
- if (m == null)
+ try
{
- throw new PropertyNotFoundException(
- getMessage(base, name));
+ return invoker.invoke(getELResolver(), getELContext());
}
-
- // Check if the concrete class of this method is accessible and if not
- // search for a public interface that declares this method
- m = MethodUtils.getAccessibleMethod(m);
- if (m == null)
+ catch (javax.el.PropertyNotFoundException e)
{
- throw new PropertyNotFoundException(
- getMessage(base, name) + " (not accessible!)");
+ throw new PropertyNotFoundException("property not found: " + invoker.getMessage() + ": " + e.getMessage(),
+ e);
}
-
- try
+ catch (ELException e)
{
- return m.invoke(base, NO_ARGS);
+ throw new EvaluationException("exception: " + invoker.getMessage() + ": " + e.getMessage(), e);
}
- catch (Throwable t)
+ catch (RuntimeException e)
{
- throw new EvaluationException(getMessage(base, name), t);
+ throw new RuntimeException("runtime exception: " + invoker.getMessage() + ": " + e.getMessage(), e);
}
}
- public static PropertyDescriptor getPropertyDescriptor(
- Object base, String name)
+ abstract static class ResolverInvoker<T>
{
- PropertyDescriptor propertyDescriptor;
+ private final Object _base;
+ private final Object _property;
- try
+ ResolverInvoker(Object base, Object property)
{
- propertyDescriptor =
- getPropertyDescriptor(
- Introspector.getBeanInfo(base.getClass()), name);
+ _base = base;
+ _property = property;
}
- catch (IntrospectionException e)
- {
- throw new PropertyNotFoundException(getMessage(base, name), e);
- }
-
- return propertyDescriptor;
- }
- public static PropertyDescriptor getPropertyDescriptor(
- BeanInfo beanInfo, String propertyName)
- {
- PropertyDescriptor[] propDescriptors =
- beanInfo.getPropertyDescriptors();
+ abstract T invoke(ELResolver resolver, ELContext context);
- if (propDescriptors != null)
+ String getMessage()
{
- // TODO: cache this in classLoader safe way
- for (int i = 0, len = propDescriptors.length; i < len; i++)
- {
- if (propDescriptors[i].getName().equals(propertyName))
- return propDescriptors[i];
- }
+ return "base: '" + _base + "' property/index: '" + _property + "'";
}
-
- throw new PropertyNotFoundException("Bean: "
- + beanInfo.getBeanDescriptor().getBeanClass().getName()
- + ", property: " + propertyName);
}
-
}
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java?view=auto&rev=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java Sun Feb 25 05:47:48 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.el;
+
+import org.apache.myfaces.el.unified.ELResolverBuilder;
+
+import javax.el.CompositeELResolver;
+import javax.faces.FactoryFinder;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.LifecycleFactory;
+
+import java.util.Iterator;
+
+/**
+ * The class will initialize the resolver for JSP
+ *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ResolverForJSPInitializer implements PhaseListener
+{
+ private final ELResolverBuilder _resolverBuilder;
+ private boolean initialized;
+ private final CompositeELResolver _resolverForJSP;
+
+ public ResolverForJSPInitializer(ELResolverBuilder resolverBuilder, CompositeELResolver resolverForJSP)
+ {
+ _resolverBuilder = resolverBuilder;
+ _resolverForJSP = resolverForJSP;
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ if (!initialized)
+ {
+ initialized = true;
+ _resolverBuilder.build(_resolverForJSP);
+
+ LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ for (Iterator<String> iter = factory.getLifecycleIds(); iter.hasNext();)
+ {
+ factory.getLifecycle(iter.next()).removePhaseListener(this);
+ }
+ }
+ }
+
+ public void afterPhase(PhaseEvent event)
+ {
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/ResolverForJSPInitializer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverImpl.java?view=diff&rev=511514&r1=511513&r2=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverImpl.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverImpl.java Sun Feb 25 05:47:48 2007
@@ -15,361 +15,70 @@
*/
package org.apache.myfaces.el;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
-import javax.faces.context.ExternalContext;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
import javax.faces.context.FacesContext;
-import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.EvaluationException;
import javax.faces.el.VariableResolver;
-import javax.faces.FacesException;
-
-import org.apache.myfaces.config.ManagedBeanBuilder;
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.element.ManagedBean;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
/**
+ * This variable resolver will be used for legacy variable resolvers which are registered through the faces config. If
+ * it is invoked through the faces chain it will use the el resolver of {@link Application#getELResolver()}. If it is
+ * invoked through the jsp chain it will create an value expression through {@link Application#getExpressionFactory()}
+ * to resolve the variable.
+ *
* @author Manfred Geiler (latest modification by $Author$)
* @author Anton Koinov
+ * @author Mathias Broekelmann
* @version $Revision$ $Date$
*/
-public class VariableResolverImpl
- extends VariableResolver
+@SuppressWarnings("deprecation")
+public class VariableResolverImpl extends VariableResolver
{
- //~ Static fields/initializers -----------------------------------------------------------------
-
- private static final Log log = LogFactory.getLog(VariableResolverImpl.class);
- private static final String BEANS_UNDER_CONSTRUCTION = "org.apache.myfaces.config.beansUnderConstruction";
-
- //~ Instance fields ----------------------------------------------------------------------------
-
- public static final Map s_standardImplicitObjects = new HashMap(32);
- static {
- s_standardImplicitObjects.put(
- "applicationScope",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getApplicationMap();
- }
- });
- s_standardImplicitObjects.put(
- "cookie",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getRequestCookieMap();
- }
- });
- s_standardImplicitObjects.put(
- "facesContext",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext;
- }
- });
- s_standardImplicitObjects.put(
- "header",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getRequestHeaderMap();
- }
- });
- s_standardImplicitObjects.put(
- "headerValues",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getRequestHeaderValuesMap();
- }
- });
- s_standardImplicitObjects.put(
- "initParam",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getInitParameterMap();
- }
- });
- s_standardImplicitObjects.put(
- "param",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getRequestParameterMap();
- }
- });
- s_standardImplicitObjects.put(
- "paramValues",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getRequestParameterValuesMap();
- }
- });
- s_standardImplicitObjects.put(
- "requestScope",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getRequestMap();
- }
- });
- s_standardImplicitObjects.put(
- "sessionScope",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getExternalContext().getSessionMap();
- }
- });
- s_standardImplicitObjects.put(
- "view",
- new ImplicitObject()
- {
- public Object get(FacesContext facesContext)
- {
- return facesContext.getViewRoot();
- }
- });
- }
-
- /**
- * Stores all implicit objects defined for this instance of <code>VariableResolver</code>
- * <p>
- * Can store instances of <code>ImplicitObject</code> which have the ability to
- * dynamically resolve against FacesContext. Can also store any other object
- * which itself is the value for the implicit object (this in effect will be
- * a static object).
- * </p>
- * <p>
- * WARNING: this implementation is not serialized as it is thread safe because
- * it does not update/add to _implicitObjects after object initialization.
- * If you need to add your own implicit objects, either extend and add more
- * in an initialization block, or add proper sychronization
- * </p>
- */
- protected final Map _implicitObjects = new HashMap(32);
+ @Override
+ public Object resolveVariable(FacesContext context, String name) throws EvaluationException
{
- _implicitObjects.putAll(s_standardImplicitObjects);
- }
-
- protected static final Map s_standardScopes = new HashMap(16);
- static {
- s_standardScopes.put(
- "request",
- new Scope()
- {
- public void put(ExternalContext extContext, String name, Object obj)
- {
- extContext.getRequestMap().put(name, obj);
- }
- });
- s_standardScopes.put(
- "session",
- new Scope()
- {
- public void put(ExternalContext extContext, String name, Object obj)
- {
- extContext.getSessionMap().put(name, obj);
- }
- });
- s_standardScopes.put(
- "application",
- new Scope()
- {
- public void put(ExternalContext extContext, String name, Object obj)
- {
- extContext.getApplicationMap().put(name, obj);
- }
- });
- s_standardScopes.put(
- "none",
- new Scope()
- {
- public void put(ExternalContext extContext, String name, Object obj)
- {
- // do nothing
- }
- });
- }
-
- /**
- * Stores all scopes defined for this instance of <code>VariableResolver</code>
- * <p>
- * Can store instances of <code>Scope</code> which have the ability to
- * dynamically resolve against ExternalContext for put operations.
- * </p>
- * <p>
- * WARNING: this implementation is not serialized as it is thread safe because
- * it does not update/add to _scopes after object initialization.
- * If you need to add your own scopes, either extend and add more
- * in an initialization block, or add proper sychronization
- * </p>
- */
- protected final Map _scopes = new HashMap(16);
- {
- _scopes.putAll(s_standardScopes);
- }
-
- /**
- * RuntimeConfig is instantiated once per servlet and never changes--we can
- * safely cache it
- */
- private RuntimeConfig _runtimeConfig;
-
- private ManagedBeanBuilder beanBuilder = new ManagedBeanBuilder();
-
-
- //~ Methods ---------------------------------------------------------------
-
- public Object resolveVariable(FacesContext facesContext, String name)
- {
- if ((name == null) || (name.length() == 0))
- {
- throw new ReferenceSyntaxException("Varible name is null or empty");
- }
-
- // Implicit objects
- Object implicitObject = _implicitObjects.get(name);
- if (implicitObject != null)
+ if (context == null)
{
- if (implicitObject instanceof ImplicitObject)
- {
- // a complex runtime object
- return ((ImplicitObject) implicitObject).get(facesContext);
- }
- else
- {
- // a simple object
- return implicitObject;
- }
+ throw new NullPointerException("context must not be null");
}
-
- ExternalContext externalContext = facesContext.getExternalContext();
-
- // Request context
- Map requestMap = externalContext.getRequestMap();
- Object obj = requestMap.get(name);
- if (obj != null)
- {
- return obj;
- }
-
- // Session context
- obj = externalContext.getSessionMap().get(name);
- if (obj != null)
+ if (name == null)
{
- return obj;
+ throw new NullPointerException("name must not be null");
}
- // Application context
- obj = externalContext.getApplicationMap().get(name);
- if (obj != null)
+ try
{
- return obj;
- }
-
- // ManagedBean
- ManagedBean mbc = getRuntimeConfig(facesContext).getManagedBean(name);
-
- if (mbc != null)
- {
-
- // check for cyclic references
- List beansUnderConstruction = (List)requestMap.get(BEANS_UNDER_CONSTRUCTION);
- if (beansUnderConstruction == null) {
- beansUnderConstruction = new ArrayList();
- requestMap.put(BEANS_UNDER_CONSTRUCTION, beansUnderConstruction);
+ Scope scope = getScope(context);
+ ELContext elcontext = context.getELContext();
+ Application application = context.getApplication();
+ if (Scope.Faces.equals(scope))
+ {
+ return application.getELResolver().getValue(elcontext, null, name);
}
-
- String managedBeanName = mbc.getManagedBeanName();
- if (beansUnderConstruction.contains(managedBeanName)) {
- throw new FacesException( "Detected cyclic reference to managedBean " + mbc.getManagedBeanName());
+ else if (Scope.JSP.equals(scope))
+ {
+ ValueExpression expression = application.getExpressionFactory().createValueExpression(elcontext,
+ "#{" + name + "}", Object.class);
+ return expression.getValue(elcontext);
}
-
- beansUnderConstruction.add(managedBeanName);
- try {
- obj = beanBuilder.buildManagedBean(facesContext, mbc);
- } finally {
- beansUnderConstruction.remove(managedBeanName);
+ else
+ {
+ throw new IllegalStateException("unknown scope defined: " + scope);
}
-
- putInScope(mbc, externalContext, obj);
-
- return obj;
}
-
- if(log.isDebugEnabled())
+ catch (ELException e)
{
- log.debug("Variable '" + name + "' could not be resolved.");
+ throw new EvaluationException(e.getMessage(), e);
}
-
- return null;
}
- private void putInScope(ManagedBean managedBean, ExternalContext extContext, Object obj) {
-
- final String managedBeanName = managedBean.getManagedBeanName();
-
- if (obj == null) {
- if (log.isDebugEnabled())
- log.debug("Variable '" + managedBeanName + "' could not be resolved.");
- } else {
-
- String scopeKey = managedBean.getManagedBeanScope();
-
- // find the scope handler object
- Scope scope = (Scope) _scopes.get(scopeKey);
- if (scope == null) {
- log.error("Managed bean '" + managedBeanName + "' has illegal scope: " + scopeKey);
- } else {
- scope.put(extContext, managedBeanName, obj);
- }
- }
-
- }
-
- protected RuntimeConfig getRuntimeConfig(FacesContext facesContext)
+ protected Scope getScope(FacesContext context)
{
- if (_runtimeConfig == null)
- {
- _runtimeConfig = RuntimeConfig.getCurrentInstance(facesContext.getExternalContext());
- }
- return _runtimeConfig;
+ return (Scope) context.getExternalContext().getRequestMap().get(Scope.class.getName());
}
-}
-
-
-interface ImplicitObject
-{
- //~ Methods ---------------------------------------------------------------
-
- public Object get(FacesContext facesContext);
-}
-
-
-interface Scope
-{
- //~ Methods ---------------------------------------------------------------
-
- public void put(ExternalContext extContext, String name, Object obj);
-}
+}
\ No newline at end of file
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java?view=diff&rev=511514&r1=511513&r2=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java Sun Feb 25 05:47:48 2007
@@ -24,6 +24,7 @@
import javax.el.PropertyNotWritableException;
import javax.faces.FactoryFinder;
import javax.faces.application.ApplicationFactory;
+import javax.faces.el.EvaluationException;
import javax.faces.el.PropertyResolver;
import java.beans.FeatureDescriptor;
@@ -31,137 +32,191 @@
import java.util.List;
/**
- * Wrapper that converts a VariableResolver into an ELResolver.
- * See JSF 1.2 spec section 5.6.1.6
- *
- * @author Stan Silvert
+ * Wrapper that converts a VariableResolver into an ELResolver. See JSF 1.2 spec section 5.6.1.6
+ *
+ * @author Stan Silvert (latest modification by $Author$)
+ * @author Mathias Broekelmann
+ * @version $Revision$ $Date$
*/
@SuppressWarnings("deprecation")
-public class PropertyResolverToELResolver extends ELResolver {
+public class PropertyResolverToELResolver extends ELResolver
+{
private PropertyResolver propertyResolver;
-
+
private ExpressionFactory expressionFactory;
-
+
/**
* Creates a new instance of PropertyResolverToELResolver
*/
- public PropertyResolverToELResolver(PropertyResolver propertyResolver) {
+ public PropertyResolverToELResolver(PropertyResolver propertyResolver)
+ {
this.propertyResolver = propertyResolver;
}
- public void setValue(ELContext context, Object base, Object property, Object value)
- throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException {
-
- if ( (base == null) || (property == null)) return;
-
- context.setPropertyResolved(true);
-
- try {
- if (needsCoersion(base)) {
- propertyResolver.setValue(base, coerceToInt(property), value);
- return;
+ @Override
+ public void setValue(ELContext context, Object base, Object property, final Object value)
+ throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException
+ {
+ invoke(context, base, property, new ResolverInvoker<Object>()
+ {
+ @Override
+ public Object invoke(Object base, Object property)
+ {
+ if (needsCoersion(base))
+ {
+ propertyResolver.setValue(base, coerceToInt(property), value);
+ }
+ else
+ {
+ propertyResolver.setValue(base, property, value);
+ }
+ return null;
}
-
- propertyResolver.setValue(base, property, value);
-
- } catch (Exception e) {
- context.setPropertyResolved(false);
- throw new ELException(e);
- }
-
+ });
}
- public boolean isReadOnly(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if ( (base == null) || (property == null)) return true;
-
- context.setPropertyResolved(true);
-
- try {
- if (needsCoersion(base)) {
- return propertyResolver.isReadOnly(base, coerceToInt(property));
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property) throws NullPointerException,
+ PropertyNotFoundException, ELException
+ {
+ return invoke(context, base, property, new ResolverInvoker<Boolean>()
+ {
+ @Override
+ public Boolean invoke(Object base, Object property)
+ {
+ if (needsCoersion(base))
+ {
+ return propertyResolver.isReadOnly(base, coerceToInt(property));
+ }
+ return propertyResolver.isReadOnly(base, property);
}
- return propertyResolver.isReadOnly(base, property);
-
- } catch (Exception e) {
- context.setPropertyResolved(false);
- throw new ELException(e);
- }
- }
-
- public Object getValue(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if ( (base == null) || (property == null)) return null;
-
- context.setPropertyResolved(true);
-
- try {
- if (needsCoersion(base)) {
- return propertyResolver.getValue(base, coerceToInt(property));
+ @Override
+ Boolean getValueIfBaseAndPropertyIsNull()
+ {
+ return true;
}
+ });
+ }
- return propertyResolver.getValue(base, property);
-
- } catch (Exception e) {
- context.setPropertyResolved(false);
- throw new ELException(e);
- }
+ @Override
+ public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
+ PropertyNotFoundException, ELException
+ {
+ return invoke(context, base, property, new ResolverInvoker<Object>()
+ {
+ @Override
+ Object invoke(Object base, Object property)
+ {
+ if (needsCoersion(base))
+ {
+ return propertyResolver.getValue(base, coerceToInt(property));
+ }
+ return propertyResolver.getValue(base, property);
+ }
+ });
}
- public Class<?> getType(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if ( (base == null) || (property == null)) return null;
-
- context.setPropertyResolved(true);
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException,
+ PropertyNotFoundException, ELException
+ {
+ return invoke(context, base, property, new ResolverInvoker<Class<?>>()
+ {
+ @Override
+ Class<?> invoke(Object base, Object property)
+ {
+ if (needsCoersion(base))
+ {
+ return propertyResolver.getType(base, coerceToInt(property));
+ }
- try {
- if (needsCoersion(base)) {
- return propertyResolver.getType(base, coerceToInt(property));
+ return propertyResolver.getType(base, property);
}
-
- return propertyResolver.getType(base, property);
-
- } catch (Exception e) {
- context.setPropertyResolved(false);
- throw new ELException(e);
- }
+ });
}
-
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
-
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
return null;
}
- public Class<?> getCommonPropertyType(ELContext context, Object base) {
-
- if (base == null) return null;
-
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+
+ if (base == null)
+ return null;
+
return Object.class;
}
-
- private boolean needsCoersion(Object base) {
+
+ private boolean needsCoersion(Object base)
+ {
return (base instanceof List) || base.getClass().isArray();
}
-
- /**
- * @return the expressionFactory
- */
- public ExpressionFactory getExpressionFactory()
+
+ protected ExpressionFactory getExpressionFactory()
{
- if(expressionFactory == null) {
- ApplicationFactory appFactory = (ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ if (expressionFactory == null)
+ {
+ ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
expressionFactory = appFactory.getApplication().getExpressionFactory();
}
return expressionFactory;
}
-
- private int coerceToInt(Object property) throws Exception {
- Integer coerced = (Integer)getExpressionFactory().coerceToType(property, Integer.class);
+
+ public void setExpressionFactory(ExpressionFactory expressionFactory)
+ {
+ this.expressionFactory = expressionFactory;
+ }
+
+ private int coerceToInt(Object property)
+ {
+ Integer coerced = (Integer) getExpressionFactory().coerceToType(property, Integer.class);
return coerced.intValue();
}
-
+
+ private <T> T invoke(ELContext context, Object base, Object property, ResolverInvoker<T> invoker)
+ throws PropertyNotFoundException, ELException
+ {
+ if (base == null || property == null)
+ {
+ return invoker.getValueIfBaseAndPropertyIsNull();
+ }
+
+ try
+ {
+ context.setPropertyResolved(true);
+ return invoker.invoke(base, property);
+ }
+ catch (javax.faces.el.PropertyNotFoundException e)
+ {
+ context.setPropertyResolved(false);
+ throw new PropertyNotFoundException(e.getMessage(), e);
+ }
+ catch (EvaluationException e)
+ {
+ context.setPropertyResolved(false);
+ throw new ELException(e.getMessage(), e);
+ }
+ catch (RuntimeException e)
+ {
+ context.setPropertyResolved(false);
+ throw e;
+ }
+ }
+
+ private abstract class ResolverInvoker<T>
+ {
+ abstract T invoke(Object base, Object property) throws PropertyNotFoundException, EvaluationException,
+ RuntimeException;
+
+ T getValueIfBaseAndPropertyIsNull()
+ {
+ return null;
+ }
+ }
}
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java?view=diff&rev=511514&r1=511513&r2=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java Sun Feb 25 05:47:48 2007
@@ -16,94 +16,130 @@
package org.apache.myfaces.el.convert;
-import java.beans.FeatureDescriptor;
-import java.util.Iterator;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
import javax.faces.el.VariableResolver;
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
/**
- * Wrapper that converts a VariableResolver into an ELResolver.
- * See JSF 1.2 spec section 5.6.1.5
- *
- * @author Stan Silvert
+ * Wrapper that converts a VariableResolver into an ELResolver. See JSF 1.2 spec section 5.6.1.5
+ *
+ * @author Stan Silvert (latest modification by $Author$)
+ * @author Mathias Broekelmann
+ * @version $Revision$ $Date$
*/
-public class VariableResolverToELResolver extends ELResolver {
-
+@SuppressWarnings("deprecation")
+public class VariableResolverToELResolver extends ELResolver
+{
+
private VariableResolver variableResolver;
-
+
/**
* Creates a new instance of VariableResolverToELResolver
*/
- public VariableResolverToELResolver(VariableResolver variableResolver) {
+ public VariableResolverToELResolver(VariableResolver variableResolver)
+ {
this.variableResolver = variableResolver;
}
- public Object getValue(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if (base != null) return null;
- if (property == null) throw new PropertyNotFoundException();
- if (! (property instanceof String)) return null;
-
- String strProperty = (String)property;
+ public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
+ PropertyNotFoundException, ELException
+ {
+
+ if (base != null)
+ return null;
+ if (property == null)
+ throw new PropertyNotFoundException();
- // This differs from the spec slightly. I'm wondering if the spec is
+ context.setPropertyResolved(true);
+
+ if (!(property instanceof String))
+ return null;
+
+ String strProperty = (String) property;
+
+ // This differs from the spec slightly. I'm wondering if the spec is
// wrong because it is legal for the resolveVariable method to return
- // null. In that case you would not want to setPropertyResolved(true).
- try {
+ // null. In that case you would not want to setPropertyResolved(true).
+ try
+ {
Object value = variableResolver.resolveVariable(facesContext(context), strProperty);
- if (value != null) {
- context.setPropertyResolved(true);
+ if (value != null)
+ {
return value;
}
- } catch (Exception e) {
+ }
+ catch (javax.faces.el.PropertyNotFoundException e)
+ {
context.setPropertyResolved(false);
- throw new ELException(e);
+ throw new PropertyNotFoundException(e.getMessage(), e);
}
-
+ catch (EvaluationException e)
+ {
+ context.setPropertyResolved(false);
+ throw new ELException(e.getMessage(), e);
+ }
+ catch (RuntimeException e)
+ {
+ context.setPropertyResolved(false);
+ throw e;
+ }
+
return null;
}
-
+
// get the FacesContext from the ELContext
- private FacesContext facesContext(ELContext context) {
- return (FacesContext)context.getContext(FacesContext.class);
+ private FacesContext facesContext(ELContext context)
+ {
+ return (FacesContext) context.getContext(FacesContext.class);
}
- public Class<?> getCommonPropertyType(ELContext context, Object base) {
- if (base != null) return null;
-
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+ if (base != null)
+ return null;
+
return String.class;
}
- public void setValue(ELContext context, Object base, Object property, Object value)
- throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException {
-
- if ( (base == null) && (property == null) ) throw new PropertyNotFoundException();
+ public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException, ELException
+ {
+
+ if ((base == null) && (property == null))
+ throw new PropertyNotFoundException();
}
- public boolean isReadOnly(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if ( (base == null) && (property == null) ) throw new PropertyNotFoundException();
-
+ public boolean isReadOnly(ELContext context, Object base, Object property) throws NullPointerException,
+ PropertyNotFoundException, ELException
+ {
+
+ if ((base == null) && (property == null))
+ throw new PropertyNotFoundException();
+
return false;
}
- public Class<?> getType(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if ( (base == null) && (property == null) ) throw new PropertyNotFoundException();
-
+ public Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException,
+ PropertyNotFoundException, ELException
+ {
+
+ if ((base == null) && (property == null))
+ throw new PropertyNotFoundException();
+
return null;
}
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
return null;
}
-
+
}
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java?view=auto&rev=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java Sun Feb 25 05:47:48 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.el.unified;
+
+import javax.el.CompositeELResolver;
+import javax.faces.application.Application;
+
+/**
+ * The ELResolverBuilder is responsible to build the el resolver which is used by the application through
+ * {@link Application#getELResolver()} according to 1.2 spec section 5.6.2 or to be used as the el resolver for jsp
+ * according to 1.2 spec section 5.6.1
+ *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public interface ELResolverBuilder
+{
+ void build(CompositeELResolver elResolver);
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ELResolverBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java?view=auto&rev=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java Sun Feb 25 05:47:48 2007
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.el.unified;
+
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.el.convert.PropertyResolverToELResolver;
+import org.apache.myfaces.el.convert.VariableResolverToELResolver;
+
+import javax.el.CompositeELResolver;
+import javax.el.ELResolver;
+import javax.faces.application.Application;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.VariableResolver;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class ResolverBuilderBase
+{
+ private final RuntimeConfig _config;
+
+ public ResolverBuilderBase(RuntimeConfig config)
+ {
+ _config = config;
+ }
+
+ /**
+ * add the el resolvers from the faces config, the el resolver wrapper for variable resolver, the el resolver
+ * wrapper for the property resolver and the el resolvers added by {@link Application#addELResolver(ELResolver)}.
+ * The resolvers where only added if they are not null
+ *
+ * @param elResolver
+ * the composite el resolver to which the resolvers where added
+ */
+ protected void addFromRuntimeConfig(CompositeELResolver elResolver)
+ {
+ if (_config.getFacesConfigElResolvers() != null)
+ {
+ elResolver.add(_config.getFacesConfigElResolvers());
+ }
+
+ if (_config.getVariableResolver() != null)
+ {
+ elResolver.add(createELResolver(_config.getVariableResolver()));
+ }
+ else if (_config.getVariableResolverChainHead() != null)
+ {
+ elResolver.add(createELResolver(_config.getVariableResolverChainHead()));
+ }
+
+ if (_config.getPropertyResolver() != null)
+ {
+ elResolver.add(createELResolver(_config.getPropertyResolver()));
+ }
+ else if (_config.getPropertyResolverChainHead() != null)
+ {
+ elResolver.add(createELResolver(_config.getPropertyResolverChainHead()));
+ }
+
+ if (_config.getApplicationElResolvers() != null)
+ {
+ elResolver.add(_config.getApplicationElResolvers());
+ }
+ }
+
+ protected ELResolver createELResolver(VariableResolver resolver)
+ {
+ return new VariableResolverToELResolver(resolver);
+ }
+
+ protected ELResolver createELResolver(PropertyResolver resolver)
+ {
+ return new PropertyResolverToELResolver(resolver);
+ }
+
+}
\ No newline at end of file
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderBase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java?view=auto&rev=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java Sun Feb 25 05:47:48 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.el.unified;
+
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.el.unified.resolver.ManagedBeanResolver;
+import org.apache.myfaces.el.unified.resolver.ResourceBundleResolver;
+import org.apache.myfaces.el.unified.resolver.implicitobject.ImplicitObjectResolver;
+
+import javax.el.CompositeELResolver;
+
+/**
+ * build the el resolver for jsp. see 1.2 spec section 5.6.1
+ *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class ResolverBuilderForJSP extends ResolverBuilderBase implements ELResolverBuilder
+{
+ public ResolverBuilderForJSP(RuntimeConfig config)
+ {
+ super(config);
+ }
+
+ public void build(CompositeELResolver elResolver)
+ {
+ elResolver.add(ImplicitObjectResolver.makeResolverForJSP());
+ elResolver.add(new ManagedBeanResolver());
+ elResolver.add(new ResourceBundleResolver());
+
+ addFromRuntimeConfig(elResolver);
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverBuilderForJSP.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverFactoryForFaces.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverFactoryForFaces.java?view=auto&rev=511514
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverFactoryForFaces.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/ResolverFactoryForFaces.java Sun Feb 25 05:47:48 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.el.unified;
+
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.el.unified.resolver.ManagedBeanResolver;
+import org.apache.myfaces.el.unified.resolver.ResourceBundleResolver;
+import org.apache.myfaces.el.unified.resolver.ScopedAttributeResolver;
+import org.apache.myfaces.el.unified.resolver.implicitobject.ImplicitObjectResolver;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.ResourceBundleELResolver;
+
+/**
+ * Create the el resolver for faces. see 1.2 spec section 5.6.2
+ *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class ResolverFactoryForFaces extends ResolverBuilderBase implements ELResolverBuilder
+{
+ public ResolverFactoryForFaces(RuntimeConfig config)
+ {
+ super(config);
+ }
+
+ public void build(CompositeELResolver elResolver)
+ {
+ elResolver.add(ImplicitObjectResolver.makeResolverForFaces());
+
+ addFromRuntimeConfig(elResolver);
+
+ elResolver.add(new ManagedBeanResolver());
+ elResolver.add(new ResourceBundleELResolver());
+ elResolver.add(new ResourceBundleResolver());
+ elResolver.add(new MapELResolver());
+ elResolver.add(new ListELResolver());
+ elResolver.add(new ArrayELResolver());
+ elResolver.add(new BeanELResolver());
+ elResolver.add(new ScopedAttributeResolver());
+ }
+
+}