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/03/16 14:24:21 UTC
svn commit: r518967 [15/20] - in /myfaces/core/branches/jsf12:
api/src/main/java-templates/javax/faces/component/
api/src/main/java/javax/faces/application/
api/src/main/java/javax/faces/component/
api/src/main/java/javax/faces/context/ api/src/main/ja...
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=518967&r1=518966&r2=518967
==============================================================================
--- 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 Fri Mar 16 06:24:10 2007
@@ -1,222 +1,222 @@
-/*
- * 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.convert;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ELResolver;
-import javax.el.ExpressionFactory;
-import javax.el.PropertyNotFoundException;
-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;
-import java.util.Iterator;
-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 (latest modification by $Author$)
- * @author Mathias Broekelmann
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("deprecation")
-public class PropertyResolverToELResolver extends ELResolver
-{
- private PropertyResolver propertyResolver;
-
- private ExpressionFactory expressionFactory;
-
- /**
- * Creates a new instance of PropertyResolverToELResolver
- */
- public PropertyResolverToELResolver(PropertyResolver propertyResolver)
- {
- this.propertyResolver = propertyResolver;
- }
-
- @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;
- }
- });
- }
-
- @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);
- }
-
- @Override
- Boolean getValueIfBaseAndPropertyIsNull()
- {
- return true;
- }
- });
- }
-
- @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);
- }
- });
- }
-
- @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));
- }
-
- return propertyResolver.getType(base, property);
- }
- });
- }
-
- @Override
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
- {
- return null;
- }
-
- @Override
- public Class<?> getCommonPropertyType(ELContext context, Object base)
- {
-
- if (base == null)
- return null;
-
- return Object.class;
- }
-
- private boolean needsCoersion(Object base)
- {
- return (base instanceof List) || base.getClass().isArray();
- }
-
- protected ExpressionFactory getExpressionFactory()
- {
- if (expressionFactory == null)
- {
- ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
- expressionFactory = appFactory.getApplication().getExpressionFactory();
- }
- return expressionFactory;
- }
-
- 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;
- }
- }
-}
+/*
+ * 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.convert;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.PropertyNotFoundException;
+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;
+import java.util.Iterator;
+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 (latest modification by $Author$)
+ * @author Mathias Broekelmann
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class PropertyResolverToELResolver extends ELResolver
+{
+ private PropertyResolver propertyResolver;
+
+ private ExpressionFactory expressionFactory;
+
+ /**
+ * Creates a new instance of PropertyResolverToELResolver
+ */
+ public PropertyResolverToELResolver(PropertyResolver propertyResolver)
+ {
+ this.propertyResolver = propertyResolver;
+ }
+
+ @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;
+ }
+ });
+ }
+
+ @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);
+ }
+
+ @Override
+ Boolean getValueIfBaseAndPropertyIsNull()
+ {
+ return true;
+ }
+ });
+ }
+
+ @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);
+ }
+ });
+ }
+
+ @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));
+ }
+
+ return propertyResolver.getType(base, property);
+ }
+ });
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+
+ if (base == null)
+ return null;
+
+ return Object.class;
+ }
+
+ private boolean needsCoersion(Object base)
+ {
+ return (base instanceof List) || base.getClass().isArray();
+ }
+
+ protected ExpressionFactory getExpressionFactory()
+ {
+ if (expressionFactory == null)
+ {
+ ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
+ expressionFactory = appFactory.getApplication().getExpressionFactory();
+ }
+ return expressionFactory;
+ }
+
+ 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;
+ }
+ }
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueBindingToValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueBindingToValueExpression.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueBindingToValueExpression.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueBindingToValueExpression.java Fri Mar 16 06:24:10 2007
@@ -1,277 +1,277 @@
-/*
- * 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.convert;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.PropertyNotFoundException;
-import javax.el.PropertyNotWritableException;
-import javax.el.ValueExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.ValueBinding;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.shared_impl.util.ClassUtils;
-
-/**
- * Wraps a ValueBinding inside a ValueExpression. Also allows access to the original ValueBinding object.
- *
- * Although ValueExpression implements Serializable, this class implements StateHolder instead.
- *
- * ATTENTION: If you make changes to this class, treat {@link ValueBindingToValueExpression} accordingly.
- *
- * @author Stan Silvert
- * @see javax.faces.component._ValueBindingToValueExpression
- */
-@SuppressWarnings("deprecation")
-public class ValueBindingToValueExpression extends ValueExpression implements StateHolder
-{
- private static final long serialVersionUID = 8071429285360496554L;
-
- private static final Log logger = LogFactory.getLog(ValueBindingToValueExpression.class);
-
- private ValueBinding _valueBinding;
-
- private boolean _transient;
-
- /**
- * No-arg constructor used during restoreState
- */
- protected ValueBindingToValueExpression()
- {
- }
-
- private ValueBinding getNotNullValueBinding()
- {
- if (_valueBinding == null)
- {
- throw new IllegalStateException("value binding is null");
- }
- return _valueBinding;
- }
-
- /** Creates a new instance of ValueBindingToValueExpression */
- public ValueBindingToValueExpression(ValueBinding valueBinding)
- {
- if (valueBinding == null)
- {
- throw new IllegalArgumentException("value binding must not be null");
- }
- this._valueBinding = valueBinding;
- }
-
- public ValueBinding getValueBinding()
- {
- return _valueBinding;
- }
-
- @Override
- public boolean isReadOnly(final ELContext context) throws NullPointerException, PropertyNotFoundException,
- ELException
- {
- return invoke(new Invoker<Boolean>()
- {
- public Boolean invoke()
- {
- return getNotNullValueBinding().isReadOnly(getFacesContext(context));
- }
- });
- }
-
- @Override
- public Object getValue(final ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
- {
- return invoke(new Invoker<Object>()
- {
- public Object invoke()
- {
- return getNotNullValueBinding().getValue(getFacesContext(context));
- }
- });
- }
-
- @Override
- public Class<?> getType(final ELContext context) throws NullPointerException, PropertyNotFoundException,
- ELException
- {
- return invoke(new Invoker<Class<?>>()
- {
- public Class<?> invoke()
- {
- return getNotNullValueBinding().getType(getFacesContext(context));
- }
- });
- }
-
- @Override
- public void setValue(final ELContext context, final Object value) throws NullPointerException,
- PropertyNotFoundException, PropertyNotWritableException, ELException
- {
- invoke(new Invoker<Object>()
- {
- public Object invoke()
- {
- getNotNullValueBinding().setValue(getFacesContext(context), value);
- return null;
- }
- });
- }
-
- @Override
- public int hashCode()
- {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + (_transient ? 1231 : 1237);
- result = PRIME * result + ((_valueBinding == null) ? 0 : _valueBinding.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ValueBindingToValueExpression other = (ValueBindingToValueExpression) obj;
- if (_transient != other._transient)
- return false;
- if (_valueBinding == null)
- {
- if (other._valueBinding != null)
- return false;
- }
- else if (!_valueBinding.equals(other._valueBinding))
- return false;
- return true;
- }
-
- @Override
- public boolean isLiteralText()
- {
- return false;
- }
-
- @Override
- public String getExpressionString()
- {
- return getNotNullValueBinding().getExpressionString();
- }
-
- @Override
- public Class<?> getExpectedType()
- {
- if (_valueBinding != null)
- {
- try
- {
- Object value = getNotNullValueBinding().getValue(FacesContext.getCurrentInstance());
- if (value != null)
- {
- return value.getClass();
- }
- }
- catch (Throwable e)
- {
- logger.warn("Could not determine expected type for '" + _valueBinding.getExpressionString() + "': "
- + e.getMessage(), e);
- }
- }
- return null;
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- if (state instanceof ValueBinding)
- {
- _valueBinding = (ValueBinding) state;
- }
- else if (state != null)
- {
- Object[] stateArray = (Object[]) state;
- _valueBinding = (ValueBinding) ClassUtils.newInstance((String) stateArray[0], ValueBinding.class);
- ((StateHolder) _valueBinding).restoreState(context, stateArray[1]);
- }
- }
-
- public Object saveState(FacesContext context)
- {
- if (!_transient)
- {
- if (_valueBinding instanceof StateHolder)
- {
- Object[] state = new Object[2];
- state[0] = _valueBinding.getClass().getName();
- state[1] = ((StateHolder) _valueBinding).saveState(context);
- return state;
- }
- return _valueBinding;
- }
- return null;
- }
-
- public void setTransient(boolean newTransientValue)
- {
- _transient = newTransientValue;
- }
-
- public boolean isTransient()
- {
- return _transient;
- }
-
- private FacesContext getFacesContext(ELContext context)
- {
- if (context == null)
- {
- throw new IllegalArgumentException("el context must not be null.");
- }
- FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
- if (context == null)
- {
- throw new IllegalStateException("faces context not available in el context.");
- }
- return facesContext;
- }
-
- private <T> T invoke(Invoker<T> invoker)
- {
- try
- {
- return invoker.invoke();
- }
- catch (javax.faces.el.PropertyNotFoundException e)
- {
- throw new PropertyNotFoundException(e.getMessage(), e);
- }
- catch (EvaluationException e)
- {
- throw new ELException(e.getMessage(), e);
- }
- }
-
- private interface Invoker<T>
- {
- T invoke();
- }
+/*
+ * 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.convert;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.ValueBinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+
+/**
+ * Wraps a ValueBinding inside a ValueExpression. Also allows access to the original ValueBinding object.
+ *
+ * Although ValueExpression implements Serializable, this class implements StateHolder instead.
+ *
+ * ATTENTION: If you make changes to this class, treat {@link ValueBindingToValueExpression} accordingly.
+ *
+ * @author Stan Silvert
+ * @see javax.faces.component._ValueBindingToValueExpression
+ */
+@SuppressWarnings("deprecation")
+public class ValueBindingToValueExpression extends ValueExpression implements StateHolder
+{
+ private static final long serialVersionUID = 8071429285360496554L;
+
+ private static final Log logger = LogFactory.getLog(ValueBindingToValueExpression.class);
+
+ private ValueBinding _valueBinding;
+
+ private boolean _transient;
+
+ /**
+ * No-arg constructor used during restoreState
+ */
+ protected ValueBindingToValueExpression()
+ {
+ }
+
+ private ValueBinding getNotNullValueBinding()
+ {
+ if (_valueBinding == null)
+ {
+ throw new IllegalStateException("value binding is null");
+ }
+ return _valueBinding;
+ }
+
+ /** Creates a new instance of ValueBindingToValueExpression */
+ public ValueBindingToValueExpression(ValueBinding valueBinding)
+ {
+ if (valueBinding == null)
+ {
+ throw new IllegalArgumentException("value binding must not be null");
+ }
+ this._valueBinding = valueBinding;
+ }
+
+ public ValueBinding getValueBinding()
+ {
+ return _valueBinding;
+ }
+
+ @Override
+ public boolean isReadOnly(final ELContext context) throws NullPointerException, PropertyNotFoundException,
+ ELException
+ {
+ return invoke(new Invoker<Boolean>()
+ {
+ public Boolean invoke()
+ {
+ return getNotNullValueBinding().isReadOnly(getFacesContext(context));
+ }
+ });
+ }
+
+ @Override
+ public Object getValue(final ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
+ {
+ return invoke(new Invoker<Object>()
+ {
+ public Object invoke()
+ {
+ return getNotNullValueBinding().getValue(getFacesContext(context));
+ }
+ });
+ }
+
+ @Override
+ public Class<?> getType(final ELContext context) throws NullPointerException, PropertyNotFoundException,
+ ELException
+ {
+ return invoke(new Invoker<Class<?>>()
+ {
+ public Class<?> invoke()
+ {
+ return getNotNullValueBinding().getType(getFacesContext(context));
+ }
+ });
+ }
+
+ @Override
+ public void setValue(final ELContext context, final Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException, ELException
+ {
+ invoke(new Invoker<Object>()
+ {
+ public Object invoke()
+ {
+ getNotNullValueBinding().setValue(getFacesContext(context), value);
+ return null;
+ }
+ });
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + (_transient ? 1231 : 1237);
+ result = PRIME * result + ((_valueBinding == null) ? 0 : _valueBinding.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ValueBindingToValueExpression other = (ValueBindingToValueExpression) obj;
+ if (_transient != other._transient)
+ return false;
+ if (_valueBinding == null)
+ {
+ if (other._valueBinding != null)
+ return false;
+ }
+ else if (!_valueBinding.equals(other._valueBinding))
+ return false;
+ return true;
+ }
+
+ @Override
+ public boolean isLiteralText()
+ {
+ return false;
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return getNotNullValueBinding().getExpressionString();
+ }
+
+ @Override
+ public Class<?> getExpectedType()
+ {
+ if (_valueBinding != null)
+ {
+ try
+ {
+ Object value = getNotNullValueBinding().getValue(FacesContext.getCurrentInstance());
+ if (value != null)
+ {
+ return value.getClass();
+ }
+ }
+ catch (Throwable e)
+ {
+ logger.warn("Could not determine expected type for '" + _valueBinding.getExpressionString() + "': "
+ + e.getMessage(), e);
+ }
+ }
+ return null;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ if (state instanceof ValueBinding)
+ {
+ _valueBinding = (ValueBinding) state;
+ }
+ else if (state != null)
+ {
+ Object[] stateArray = (Object[]) state;
+ _valueBinding = (ValueBinding) ClassUtils.newInstance((String) stateArray[0], ValueBinding.class);
+ ((StateHolder) _valueBinding).restoreState(context, stateArray[1]);
+ }
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ if (!_transient)
+ {
+ if (_valueBinding instanceof StateHolder)
+ {
+ Object[] state = new Object[2];
+ state[0] = _valueBinding.getClass().getName();
+ state[1] = ((StateHolder) _valueBinding).saveState(context);
+ return state;
+ }
+ return _valueBinding;
+ }
+ return null;
+ }
+
+ public void setTransient(boolean newTransientValue)
+ {
+ _transient = newTransientValue;
+ }
+
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+
+ private FacesContext getFacesContext(ELContext context)
+ {
+ if (context == null)
+ {
+ throw new IllegalArgumentException("el context must not be null.");
+ }
+ FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
+ if (context == null)
+ {
+ throw new IllegalStateException("faces context not available in el context.");
+ }
+ return facesContext;
+ }
+
+ private <T> T invoke(Invoker<T> invoker)
+ {
+ try
+ {
+ return invoker.invoke();
+ }
+ catch (javax.faces.el.PropertyNotFoundException e)
+ {
+ throw new PropertyNotFoundException(e.getMessage(), e);
+ }
+ catch (EvaluationException e)
+ {
+ throw new ELException(e.getMessage(), e);
+ }
+ }
+
+ private interface Invoker<T>
+ {
+ T invoke();
+ }
}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueBindingToValueExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueExpressionToValueBinding.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueExpressionToValueBinding.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueExpressionToValueBinding.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueExpressionToValueBinding.java Fri Mar 16 06:24:10 2007
@@ -1,238 +1,238 @@
-/*
- * 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.convert;
-
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-
-import org.apache.myfaces.shared_impl.util.ClassUtils;
-
-/**
- * Converter for legacy ValueBinding objects. See JSF 1.2 section 5.8.3
- *
- * ATTENTION: If you make changes to this class, treat javax.faces.component.ValueExpressionToValueBinding accordingly.
- *
- * @author Stan Silvert
- * @see javax.faces.component.ValueExpressionToValueBinding
- */
-@SuppressWarnings("deprecation")
-public class ValueExpressionToValueBinding extends ValueBinding implements StateHolder
-{
-
- private ValueExpression _valueExpression;
-
- private boolean isTransient = false;
-
- // required no-arg constructor for StateHolder
- protected ValueExpressionToValueBinding()
- {
- _valueExpression = null;
- }
-
- @Override
- public int hashCode()
- {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + ((_valueExpression == null) ? 0 : _valueExpression.hashCode());
- result = PRIME * result + (isTransient ? 1231 : 1237);
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ValueExpressionToValueBinding other = (ValueExpressionToValueBinding) obj;
- if (_valueExpression == null)
- {
- if (other._valueExpression != null)
- return false;
- }
- else if (!_valueExpression.equals(other._valueExpression))
- return false;
- if (isTransient != other.isTransient)
- return false;
- return true;
- }
-
- /**
- * @return the valueExpression
- */
- public ValueExpression getValueExpression()
- {
- return getNotNullValueExpression();
- }
-
- /**
- * @return the valueExpression
- */
- private ValueExpression getNotNullValueExpression()
- {
- if (_valueExpression == null)
- {
- throw new IllegalStateException("value expression is null");
- }
- return _valueExpression;
- }
-
- @Override
- public String getExpressionString()
- {
- return getNotNullValueExpression().getExpressionString();
- }
-
- /** Creates a new instance of ValueExpressionToValueBinding */
- public ValueExpressionToValueBinding(ValueExpression valueExpression)
- {
- if (valueExpression == null)
- {
- throw new IllegalArgumentException("value expression must not be null.");
- }
- _valueExpression = valueExpression;
- }
-
- @Override
- public void setValue(FacesContext facesContext, Object value) throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- getNotNullValueExpression().setValue(facesContext.getELContext(), value);
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
- }
-
- @Override
- public boolean isReadOnly(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
- {
-
- try
- {
- return getNotNullValueExpression().isReadOnly(facesContext.getELContext());
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
-
- }
-
- @Override
- public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- return getNotNullValueExpression().getValue(facesContext.getELContext());
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
- }
-
- @Override
- public Class getType(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- return getNotNullValueExpression().getType(facesContext.getELContext());
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
- }
-
- // -------- StateHolder methods -------------------------------------------
-
- public void restoreState(FacesContext facesContext, Object state)
- {
- if (state != null)
- {
- if (state instanceof ValueExpression)
- {
- _valueExpression = (ValueExpression) state;
- }
- else
- {
- Object[] stateArray = (Object[]) state;
- _valueExpression = (ValueExpression) ClassUtils.newInstance((String) stateArray[0],
- ValueExpression.class);
- ((StateHolder) _valueExpression).restoreState(facesContext, stateArray[1]);
- }
- }
- }
-
- public Object saveState(FacesContext context)
- {
- if (!isTransient)
- {
- if (_valueExpression instanceof StateHolder)
- {
- Object[] state = new Object[2];
- state[0] = _valueExpression.getClass().getName();
- state[1] = ((StateHolder) _valueExpression).saveState(context);
- return state;
- }
- else
- {
- return _valueExpression;
- }
- }
- return null;
- }
-
- public void setTransient(boolean newTransientValue)
- {
- isTransient = newTransientValue;
- }
-
- public boolean isTransient()
- {
- return isTransient;
- }
-
-}
+/*
+ * 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.convert;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+
+/**
+ * Converter for legacy ValueBinding objects. See JSF 1.2 section 5.8.3
+ *
+ * ATTENTION: If you make changes to this class, treat javax.faces.component.ValueExpressionToValueBinding accordingly.
+ *
+ * @author Stan Silvert
+ * @see javax.faces.component.ValueExpressionToValueBinding
+ */
+@SuppressWarnings("deprecation")
+public class ValueExpressionToValueBinding extends ValueBinding implements StateHolder
+{
+
+ private ValueExpression _valueExpression;
+
+ private boolean isTransient = false;
+
+ // required no-arg constructor for StateHolder
+ protected ValueExpressionToValueBinding()
+ {
+ _valueExpression = null;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((_valueExpression == null) ? 0 : _valueExpression.hashCode());
+ result = PRIME * result + (isTransient ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ValueExpressionToValueBinding other = (ValueExpressionToValueBinding) obj;
+ if (_valueExpression == null)
+ {
+ if (other._valueExpression != null)
+ return false;
+ }
+ else if (!_valueExpression.equals(other._valueExpression))
+ return false;
+ if (isTransient != other.isTransient)
+ return false;
+ return true;
+ }
+
+ /**
+ * @return the valueExpression
+ */
+ public ValueExpression getValueExpression()
+ {
+ return getNotNullValueExpression();
+ }
+
+ /**
+ * @return the valueExpression
+ */
+ private ValueExpression getNotNullValueExpression()
+ {
+ if (_valueExpression == null)
+ {
+ throw new IllegalStateException("value expression is null");
+ }
+ return _valueExpression;
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return getNotNullValueExpression().getExpressionString();
+ }
+
+ /** Creates a new instance of ValueExpressionToValueBinding */
+ public ValueExpressionToValueBinding(ValueExpression valueExpression)
+ {
+ if (valueExpression == null)
+ {
+ throw new IllegalArgumentException("value expression must not be null.");
+ }
+ _valueExpression = valueExpression;
+ }
+
+ @Override
+ public void setValue(FacesContext facesContext, Object value) throws EvaluationException, PropertyNotFoundException
+ {
+ try
+ {
+ getNotNullValueExpression().setValue(facesContext.getELContext(), value);
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+ }
+
+ @Override
+ public boolean isReadOnly(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
+ {
+
+ try
+ {
+ return getNotNullValueExpression().isReadOnly(facesContext.getELContext());
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+
+ }
+
+ @Override
+ public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
+ {
+ try
+ {
+ return getNotNullValueExpression().getValue(facesContext.getELContext());
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+ }
+
+ @Override
+ public Class getType(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
+ {
+ try
+ {
+ return getNotNullValueExpression().getType(facesContext.getELContext());
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+ }
+
+ // -------- StateHolder methods -------------------------------------------
+
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ if (state != null)
+ {
+ if (state instanceof ValueExpression)
+ {
+ _valueExpression = (ValueExpression) state;
+ }
+ else
+ {
+ Object[] stateArray = (Object[]) state;
+ _valueExpression = (ValueExpression) ClassUtils.newInstance((String) stateArray[0],
+ ValueExpression.class);
+ ((StateHolder) _valueExpression).restoreState(facesContext, stateArray[1]);
+ }
+ }
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ if (!isTransient)
+ {
+ if (_valueExpression instanceof StateHolder)
+ {
+ Object[] state = new Object[2];
+ state[0] = _valueExpression.getClass().getName();
+ state[1] = ((StateHolder) _valueExpression).saveState(context);
+ return state;
+ }
+ else
+ {
+ return _valueExpression;
+ }
+ }
+ return null;
+ }
+
+ public void setTransient(boolean newTransientValue)
+ {
+ isTransient = newTransientValue;
+ }
+
+ public boolean isTransient()
+ {
+ return isTransient;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/ValueExpressionToValueBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
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=518967&r1=518966&r2=518967
==============================================================================
--- 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 Fri Mar 16 06:24:10 2007
@@ -1,160 +1,160 @@
-/*
- * 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.convert;
-
-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.Collection;
-import java.util.HashSet;
-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 (latest modification by $Author$)
- * @author Mathias Broekelmann
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("deprecation")
-public class VariableResolverToELResolver extends ELResolver
-{
-
- // holds a flag to check if this instance is already called in current thread
- private static final ThreadLocal<Collection<String>> propertyGuard = new ThreadLocal<Collection<String>>() {
- @Override
- protected Collection<String> initialValue()
- {
- return new HashSet<String>();
- }
- };
-
- private VariableResolver variableResolver;
-
- /**
- * Creates a new instance of VariableResolverToELResolver
- */
- 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();
-
- context.setPropertyResolved(true);
-
- if (!(property instanceof String))
- return null;
-
- String strProperty = (String) property;
-
- Object result = null;
- try
- {
- // only call the resolver if we haven't done it in current stack
- if(!propertyGuard.get().contains(strProperty)) {
- propertyGuard.get().add(strProperty);
- result = variableResolver.resolveVariable(facesContext(context), strProperty);
- }
- }
- 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;
- }
- finally
- {
- propertyGuard.get().remove(strProperty);
- // set property resolved to false in any case if result is null
- context.setPropertyResolved(result != null);
- }
-
- return result;
- }
-
- // get the FacesContext from the ELContext
- private FacesContext facesContext(ELContext context)
- {
- return (FacesContext) context.getContext(FacesContext.class);
- }
-
- 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 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();
-
- return null;
- }
-
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
- {
- return null;
- }
-
-}
+/*
+ * 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.convert;
+
+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.Collection;
+import java.util.HashSet;
+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 (latest modification by $Author$)
+ * @author Mathias Broekelmann
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class VariableResolverToELResolver extends ELResolver
+{
+
+ // holds a flag to check if this instance is already called in current thread
+ private static final ThreadLocal<Collection<String>> propertyGuard = new ThreadLocal<Collection<String>>() {
+ @Override
+ protected Collection<String> initialValue()
+ {
+ return new HashSet<String>();
+ }
+ };
+
+ private VariableResolver variableResolver;
+
+ /**
+ * Creates a new instance of VariableResolverToELResolver
+ */
+ 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();
+
+ context.setPropertyResolved(true);
+
+ if (!(property instanceof String))
+ return null;
+
+ String strProperty = (String) property;
+
+ Object result = null;
+ try
+ {
+ // only call the resolver if we haven't done it in current stack
+ if(!propertyGuard.get().contains(strProperty)) {
+ propertyGuard.get().add(strProperty);
+ result = variableResolver.resolveVariable(facesContext(context), strProperty);
+ }
+ }
+ 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;
+ }
+ finally
+ {
+ propertyGuard.get().remove(strProperty);
+ // set property resolved to false in any case if result is null
+ context.setPropertyResolved(result != null);
+ }
+
+ return result;
+ }
+
+ // get the FacesContext from the ELContext
+ private FacesContext facesContext(ELContext context)
+ {
+ return (FacesContext) context.getContext(FacesContext.class);
+ }
+
+ 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 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();
+
+ return null;
+ }
+
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
+ return null;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/FacesELContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/FacesELContext.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/FacesELContext.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/FacesELContext.java Fri Mar 16 06:24:10 2007
@@ -1,67 +1,67 @@
-/*
- * 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.unified;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.FunctionMapper;
-import javax.el.VariableMapper;
-import javax.faces.context.FacesContext;
-
-/**
- * ELContext used for JSF.
- *
- * @author Stan Silvert
- */
-public class FacesELContext extends ELContext {
-
- private ELResolver _elResolver;
- private FunctionMapper _functionMapper;
- private VariableMapper _variableMapper;
-
- public FacesELContext(ELResolver elResolver,
- FacesContext facesContext) {
- this._elResolver = elResolver;
- putContext(FacesContext.class, facesContext);
-
- // TODO: decide if we need to implement our own FunctionMapperImpl and
- // VariableMapperImpl instead of relying on Tomcat's version.
- //this.functionMapper = new FunctionMapperImpl();
- //this.variableMapper = new VariableMapperImpl();
- }
-
- public VariableMapper getVariableMapper() {
- return _variableMapper;
- }
-
- public void setVariableMapper(VariableMapper varMapper) {
- _variableMapper = varMapper;
- }
-
- public FunctionMapper getFunctionMapper() {
- return _functionMapper;
- }
-
- public void setFunctionMapper(FunctionMapper functionMapper) {
- _functionMapper = functionMapper;
- }
-
- public ELResolver getELResolver() {
- return _elResolver;
- }
-
-}
+/*
+ * 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.unified;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+import javax.faces.context.FacesContext;
+
+/**
+ * ELContext used for JSF.
+ *
+ * @author Stan Silvert
+ */
+public class FacesELContext extends ELContext {
+
+ private ELResolver _elResolver;
+ private FunctionMapper _functionMapper;
+ private VariableMapper _variableMapper;
+
+ public FacesELContext(ELResolver elResolver,
+ FacesContext facesContext) {
+ this._elResolver = elResolver;
+ putContext(FacesContext.class, facesContext);
+
+ // TODO: decide if we need to implement our own FunctionMapperImpl and
+ // VariableMapperImpl instead of relying on Tomcat's version.
+ //this.functionMapper = new FunctionMapperImpl();
+ //this.variableMapper = new VariableMapperImpl();
+ }
+
+ public VariableMapper getVariableMapper() {
+ return _variableMapper;
+ }
+
+ public void setVariableMapper(VariableMapper varMapper) {
+ _variableMapper = varMapper;
+ }
+
+ public FunctionMapper getFunctionMapper() {
+ return _functionMapper;
+ }
+
+ public void setFunctionMapper(FunctionMapper functionMapper) {
+ _functionMapper = functionMapper;
+ }
+
+ public ELResolver getELResolver() {
+ return _elResolver;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/FacesELContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ManagedBeanResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ManagedBeanResolver.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ManagedBeanResolver.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ManagedBeanResolver.java Fri Mar 16 06:24:10 2007
@@ -1,290 +1,290 @@
-/*
- * 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.unified.resolver;
-
-import java.beans.FeatureDescriptor;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ELResolver;
-import javax.el.PropertyNotFoundException;
-import javax.el.PropertyNotWritableException;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.config.ManagedBeanBuilder;
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.element.ManagedBean;
-
-/**
- * See JSF 1.2 spec section 5.6.1.2
- *
- * @author Stan Silvert
- */
-public class ManagedBeanResolver extends ELResolver {
- private static final Log log = LogFactory.getLog(ManagedBeanResolver.class);
- private static final String BEANS_UNDER_CONSTRUCTION = "org.apache.myfaces.el.unified.resolver.managedbean.beansUnderConstruction";
-
- // adapted from Manfred's JSF 1.1 VariableResolverImpl
- 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();
-
- /** Creates a new instance of ManagedBeanResolver */
- public ManagedBeanResolver() {
- }
-
- 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();
- }
-
- return false;
- }
-
- public Object getValue(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
-
- if (base != null) return null;
-
- if (property == null) {
- throw new PropertyNotFoundException();
- }
-
- ExternalContext extContext = externalContext(context);
-
- if (extContext == null) return null;
- if (extContext.getRequestMap().containsKey(property)) return null;
- if (extContext.getSessionMap().containsKey(property)) return null;
- if (extContext.getApplicationMap().containsKey(property)) return null;
-
- if ( !(property instanceof String) ) return null;
-
- String strProperty = (String)property;
-
- ManagedBean managedBean = runtimeConfig(context).getManagedBean(strProperty);
- if (managedBean != null) {
- storeManagedBean(managedBean, facesContext(context));
- context.setPropertyResolved(true);
- }
-
- return null;
- }
-
- // adapted from Manfred's JSF 1.1 VariableResolverImpl
- private void storeManagedBean(ManagedBean managedBean,
- FacesContext facesContext)
- throws ELException {
-
- ExternalContext extContext = facesContext.getExternalContext();
- Map requestMap = extContext.getRequestMap();
-
- // check for cyclic references
- List beansUnderConstruction = (List)requestMap.get(BEANS_UNDER_CONSTRUCTION);
- if (beansUnderConstruction == null) {
- beansUnderConstruction = new ArrayList();
- requestMap.put(BEANS_UNDER_CONSTRUCTION, beansUnderConstruction);
- }
-
- String managedBeanName = managedBean.getManagedBeanName();
- if (beansUnderConstruction.contains(managedBeanName)) {
- throw new ELException( "Detected cyclic reference to managedBean " + managedBeanName);
- }
-
- beansUnderConstruction.add(managedBeanName);
-
- Object obj = null;
- try {
- obj = beanBuilder.buildManagedBean(facesContext, managedBean);
- } finally {
- beansUnderConstruction.remove(managedBeanName);
- }
-
- putInScope(managedBean, extContext, obj);
- }
-
- 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);
- }
- }
-
- }
-
- // get the FacesContext from the ELContext
- private FacesContext facesContext(ELContext context) {
- return (FacesContext)context.getContext(FacesContext.class);
- }
-
- private ExternalContext externalContext(ELContext context) {
- FacesContext facesContext = facesContext(context);
-
- return facesContext != null ? facesContext.getExternalContext() : null;
- }
-
- 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 getFeatureDescriptors(ELContext context, Object base) {
-
- if (base != null) return null;
-
- ArrayList<FeatureDescriptor> descriptors = new ArrayList<FeatureDescriptor>();
-
- Map<String, ManagedBean> managedBeans = runtimeConfig(context).getManagedBeans();
- for (String beanName : managedBeans.keySet()) {
- descriptors.add(makeDescriptor(beanName, managedBeans.get(beanName)));
- }
-
- return descriptors.iterator();
- }
-
- private FeatureDescriptor makeDescriptor(String beanName, ManagedBean managedBean) {
- FeatureDescriptor fd = new FeatureDescriptor();
- fd.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
- fd.setValue(ELResolver.TYPE, managedBean.getManagedBeanClass());
- fd.setName(beanName);
- fd.setDisplayName(beanName);
- fd.setShortDescription(managedBean.getDescription());
- fd.setExpert(false);
- fd.setHidden(false);
- fd.setPreferred(true);
- return fd;
- }
-
- protected RuntimeConfig runtimeConfig(ELContext context) {
- FacesContext facesContext = facesContext(context);
-
- // application-level singleton - we can safely cache this
- if (this.runtimeConfig == null) {
- this.runtimeConfig = RuntimeConfig.getCurrentInstance(facesContext.getExternalContext());
- }
-
- return runtimeConfig;
- }
-
- public Class<?> getCommonPropertyType(ELContext context, Object base) {
-
- if (base != null) return null;
-
- return Object.class;
- }
-
- interface Scope {
- public void put(ExternalContext extContext, String name, Object obj);
- }
-
-}
+/*
+ * 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.unified.resolver;
+
+import java.beans.FeatureDescriptor;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.config.ManagedBeanBuilder;
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.config.element.ManagedBean;
+
+/**
+ * See JSF 1.2 spec section 5.6.1.2
+ *
+ * @author Stan Silvert
+ */
+public class ManagedBeanResolver extends ELResolver {
+ private static final Log log = LogFactory.getLog(ManagedBeanResolver.class);
+ private static final String BEANS_UNDER_CONSTRUCTION = "org.apache.myfaces.el.unified.resolver.managedbean.beansUnderConstruction";
+
+ // adapted from Manfred's JSF 1.1 VariableResolverImpl
+ 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();
+
+ /** Creates a new instance of ManagedBeanResolver */
+ public ManagedBeanResolver() {
+ }
+
+ 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();
+ }
+
+ return false;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+
+ if (base != null) return null;
+
+ if (property == null) {
+ throw new PropertyNotFoundException();
+ }
+
+ ExternalContext extContext = externalContext(context);
+
+ if (extContext == null) return null;
+ if (extContext.getRequestMap().containsKey(property)) return null;
+ if (extContext.getSessionMap().containsKey(property)) return null;
+ if (extContext.getApplicationMap().containsKey(property)) return null;
+
+ if ( !(property instanceof String) ) return null;
+
+ String strProperty = (String)property;
+
+ ManagedBean managedBean = runtimeConfig(context).getManagedBean(strProperty);
+ if (managedBean != null) {
+ storeManagedBean(managedBean, facesContext(context));
+ context.setPropertyResolved(true);
+ }
+
+ return null;
+ }
+
+ // adapted from Manfred's JSF 1.1 VariableResolverImpl
+ private void storeManagedBean(ManagedBean managedBean,
+ FacesContext facesContext)
+ throws ELException {
+
+ ExternalContext extContext = facesContext.getExternalContext();
+ Map requestMap = extContext.getRequestMap();
+
+ // check for cyclic references
+ List beansUnderConstruction = (List)requestMap.get(BEANS_UNDER_CONSTRUCTION);
+ if (beansUnderConstruction == null) {
+ beansUnderConstruction = new ArrayList();
+ requestMap.put(BEANS_UNDER_CONSTRUCTION, beansUnderConstruction);
+ }
+
+ String managedBeanName = managedBean.getManagedBeanName();
+ if (beansUnderConstruction.contains(managedBeanName)) {
+ throw new ELException( "Detected cyclic reference to managedBean " + managedBeanName);
+ }
+
+ beansUnderConstruction.add(managedBeanName);
+
+ Object obj = null;
+ try {
+ obj = beanBuilder.buildManagedBean(facesContext, managedBean);
+ } finally {
+ beansUnderConstruction.remove(managedBeanName);
+ }
+
+ putInScope(managedBean, extContext, obj);
+ }
+
+ 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);
+ }
+ }
+
+ }
+
+ // get the FacesContext from the ELContext
+ private FacesContext facesContext(ELContext context) {
+ return (FacesContext)context.getContext(FacesContext.class);
+ }
+
+ private ExternalContext externalContext(ELContext context) {
+ FacesContext facesContext = facesContext(context);
+
+ return facesContext != null ? facesContext.getExternalContext() : null;
+ }
+
+ 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 getFeatureDescriptors(ELContext context, Object base) {
+
+ if (base != null) return null;
+
+ ArrayList<FeatureDescriptor> descriptors = new ArrayList<FeatureDescriptor>();
+
+ Map<String, ManagedBean> managedBeans = runtimeConfig(context).getManagedBeans();
+ for (String beanName : managedBeans.keySet()) {
+ descriptors.add(makeDescriptor(beanName, managedBeans.get(beanName)));
+ }
+
+ return descriptors.iterator();
+ }
+
+ private FeatureDescriptor makeDescriptor(String beanName, ManagedBean managedBean) {
+ FeatureDescriptor fd = new FeatureDescriptor();
+ fd.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
+ fd.setValue(ELResolver.TYPE, managedBean.getManagedBeanClass());
+ fd.setName(beanName);
+ fd.setDisplayName(beanName);
+ fd.setShortDescription(managedBean.getDescription());
+ fd.setExpert(false);
+ fd.setHidden(false);
+ fd.setPreferred(true);
+ return fd;
+ }
+
+ protected RuntimeConfig runtimeConfig(ELContext context) {
+ FacesContext facesContext = facesContext(context);
+
+ // application-level singleton - we can safely cache this
+ if (this.runtimeConfig == null) {
+ this.runtimeConfig = RuntimeConfig.getCurrentInstance(facesContext.getExternalContext());
+ }
+
+ return runtimeConfig;
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+
+ if (base != null) return null;
+
+ return Object.class;
+ }
+
+ interface Scope {
+ public void put(ExternalContext extContext, String name, Object obj);
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/unified/resolver/ManagedBeanResolver.java
------------------------------------------------------------------------------
svn:eol-style = native