Class BeanNameELResolver
- java.lang.Object
-
- jakarta.el.ELResolver
-
- jakarta.el.BeanNameELResolver
-
public class BeanNameELResolver extends ELResolver
An
ELResolverfor resolving user or container managed beans.A
BeanNameResolveris required for its proper operation. The following example creates anELResolverthat resolves the name "bean" to an instance of MyBean.ELResovler elr = new BeanNameELResolver(new BeanNameResolver { public boolean isNameResolved(String beanName) { return "bean".equals(beanName); } public Object getBean(String beanName) { return "bean".equals(beanName)? new MyBean(): null; } });- Since:
- Jakarta Expression Language 3.0
-
-
Field Summary
-
Fields inherited from class jakarta.el.ELResolver
RESOLVABLE_AT_DESIGN_TIME, TYPE
-
-
Constructor Summary
Constructors Constructor Description BeanNameELResolver(BeanNameResolver beanNameResolver)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Class<?>getCommonPropertyType(ELContext context, Object base)Always returnsString.class, since a bean name is a String.Iterator<FeatureDescriptor>getFeatureDescriptors(ELContext context, Object base)Deprecated, for removal: This API element is subject to removal in a future version.This method will be removed without replacement in EL 6.0Class<?>getType(ELContext context, Object base, Object property)If the base is null and the property is a name resolvable by the BeanNameResolver, return the type of the bean.ObjectgetValue(ELContext context, Object base, Object property)If the base object isnulland the property is a name that is resolvable by the BeanNameResolver, returns the value resolved by the BeanNameResolver.booleanisReadOnly(ELContext context, Object base, Object property)If the base is null and the property is a name resolvable by the BeanNameResolver, attempts to determine if the bean is writable.voidsetValue(ELContext context, Object base, Object property, Object value)If the base is null and the property is a name that is resolvable by the BeanNameResolver, the bean in the BeanNameResolver is set to the given value.-
Methods inherited from class jakarta.el.ELResolver
convertToType, invoke
-
-
-
-
Constructor Detail
-
BeanNameELResolver
public BeanNameELResolver(BeanNameResolver beanNameResolver)
Constructor- Parameters:
beanNameResolver- TheBeanNameResolverthat resolves a bean name.
-
-
Method Detail
-
getValue
public Object getValue(ELContext context, Object base, Object property)
If the base object isnulland the property is a name that is resolvable by the BeanNameResolver, returns the value resolved by the BeanNameResolver.If name is resolved by the BeanNameResolver, the
propertyResolvedproperty of theELContextobject must be set totrueby this resolver, before returning. If this property is nottrueafter this method is called, the caller should ignore the return value.- Specified by:
getValuein classELResolver- Parameters:
context- The context of this evaluation.base-nullproperty- The name of the bean.- Returns:
- If the
propertyResolvedproperty ofELContextwas set totrue, then the value of the bean with the given name. Otherwise, undefined. - Throws:
NullPointerException- if context isnull.ELException- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
setValue
public void setValue(ELContext context, Object base, Object property, Object value)
If the base is null and the property is a name that is resolvable by the BeanNameResolver, the bean in the BeanNameResolver is set to the given value.If the name is resolvable by the BeanNameResolver, or if the BeanNameResolver allows creating a new bean, the
propertyResolvedproperty of theELContextobject must be set totrueby the resolver, before returning. If this property is nottrueafter this method is called, the caller can safely assume no value has been set.- Specified by:
setValuein classELResolver- Parameters:
context- The context of this evaluation.base-nullproperty- The name of the beanvalue- The value to set the bean with the given name to.- Throws:
NullPointerException- if context isnullPropertyNotWritableException- if the BeanNameResolver does not allow the bean to be modified.ELException- if an exception was thrown while attempting to set the bean with the given name. The thrown exception must be included as the cause property of this exception, if available.
-
getType
public Class<?> getType(ELContext context, Object base, Object property)
If the base is null and the property is a name resolvable by the BeanNameResolver, return the type of the bean.If the name is resolvable by the BeanNameResolver, the
propertyResolvedproperty of theELContextobject must be set totrueby the resolver, before returning. If this property is nottrueafter this method is called, the caller can safely assume no value has been set.- Specified by:
getTypein classELResolver- Parameters:
context- The context of this evaluation.base-nullproperty- The name of the bean.- Returns:
- If the
propertyResolvedproperty ofELContextwas set totrueand the associated BeanNameResolver is not read-only then the type of the bean with the given name. If the given bean name was resolved but the associated BeanNameResolver is read-only thennull. Otherwise, undefined. - Throws:
NullPointerException- if context isnull.ELException- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
isReadOnly
public boolean isReadOnly(ELContext context, Object base, Object property)
If the base is null and the property is a name resolvable by the BeanNameResolver, attempts to determine if the bean is writable.If the name is resolvable by the BeanNameResolver, the
propertyResolvedproperty of theELContextobject must be set totrueby the resolver, before returning. If this property is nottrueafter this method is called, the caller can safely assume no value has been set.- Specified by:
isReadOnlyin classELResolver- Parameters:
context- The context of this evaluation.base-nullproperty- The name of the bean.- Returns:
- If the
propertyResolvedproperty ofELContextwas set totrue, thentrueif the property is read-only orfalseif not; otherwise undefined. - Throws:
NullPointerException- if context isnull.ELException- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
getFeatureDescriptors
@Deprecated(forRemoval=true, since="5.0") public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
Deprecated, for removal: This API element is subject to removal in a future version.This method will be removed without replacement in EL 6.0Always returnsnull, since there is no reason to iterate through a list of one element: bean name.- Overrides:
getFeatureDescriptorsin classELResolver- Parameters:
context- The context of this evaluation.base-null.- Returns:
null.- See Also:
FeatureDescriptor
-
getCommonPropertyType
public Class<?> getCommonPropertyType(ELContext context, Object base)
Always returnsString.class, since a bean name is a String.- Specified by:
getCommonPropertyTypein classELResolver- Parameters:
context- The context of this evaluation.base-null.- Returns:
String.class.
-
-