Top Description Fields Constructors Methods
javax.el

public Class BeanNameELResolver

extends ELResolver
Class Inheritance
Imports
java.util.Iterator, java.beans.FeatureDescriptor

An ELResolver for resolving user or container managed beans.

A BeanNameResolver is required for its proper operation. The following example creates an ELResolver that 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
EL 3.0

Field Summary

Modifier and TypeField and Description
private BeanNameResolver
Inherited from javax.el.ELResolver:
RESOLVABLE_AT_DESIGN_TIMETYPE

Constructor Summary

AccessConstructor and Description
public
BeanNameELResolver(BeanNameResolver
The BeanNameResolver that resolves a bean name.
beanNameResolver
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public Class<?>

Returns:

String.class.
getCommonPropertyType
(ELContext
The context of this evaluation.
context
,
Object
null.
base
)

Implements abstract javax.el.ELResolver.getCommonPropertyType.

Always returns String.class, since a bean name is a String.
public Iterator<FeatureDescriptor>

Returns:

null.
getFeatureDescriptors
(ELContext
The context of this evaluation.
context
,
Object
null.
base
)

Implements abstract javax.el.ELResolver.getFeatureDescriptors.

Always returns null, since there is no reason to iterate through a list of one element: bean name.
public Class<?>

Returns:

If the propertyResolved property of ELContext was set to true, then the type of the bean with the given name. Otherwise, undefined.
getType
(ELContext
The context of this evaluation.
context
,
Object
null
base
,
Object
The name of the bean.
property
)

Implements abstract javax.el.ELResolver.getType.

If the base is null and the property is a name resolvable by the BeanNameResolver, return the type of the bean.
public Object

Returns:

If the propertyResolved property of ELContext was set to true, then the value of the bean with the given name. Otherwise, undefined.
getValue
(ELContext
The context of this evaluation.
context
,
Object
null
base
,
Object
The name of the bean.
property
)

Implements abstract javax.el.ELResolver.getValue.

If the base object is null and the property is a name that is resolvable by the BeanNameResolver, returns the value resolved by the BeanNameResolver.
public boolean

Returns:

If the propertyResolved property of ELContext was set to true, then true if the property is read-only or false if not; otherwise undefined.
isReadOnly
(ELContext
The context of this evaluation.
context
,
Object
null
base
,
Object
The name of the bean.
property
)

Implements abstract javax.el.ELResolver.isReadOnly.

If the base is null and the property is a name resolvable by the BeanNameResolver, attempts to determine if the bean is writable.
public void
setValue(ELContext
The context of this evaluation.
context
,
Object
null
base
,
Object
The name of the bean
property
,
Object
The value to set the bean with the given name to.
value
)

Implements abstract javax.el.ELResolver.setValue.

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.
Inherited from javax.el.ELResolver:
convertToTypeinvoke

Field Detail

beanNameResolverback to summary
private BeanNameResolver beanNameResolver

Constructor Detail

BeanNameELResolverback to summary
public BeanNameELResolver(BeanNameResolver beanNameResolver)

Constructor

Parameters
beanNameResolver:BeanNameResolver

The BeanNameResolver that resolves a bean name.

Method Detail

getCommonPropertyTypeback to summary
public Class<?> getCommonPropertyType(ELContext context, Object base)

Implements abstract javax.el.ELResolver.getCommonPropertyType.

Always returns String.class, since a bean name is a String.

Parameters
context:ELContext

The context of this evaluation.

base:Object

null.

Returns:Class<?>

String.class.

Annotations
@Override
getFeatureDescriptorsback to summary
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)

Implements abstract javax.el.ELResolver.getFeatureDescriptors.

Always returns null, since there is no reason to iterate through a list of one element: bean name.

Parameters
context:ELContext

The context of this evaluation.

base:Object

null.

Returns:Iterator<FeatureDescriptor>

null.

getTypeback to summary
public Class<?> getType(ELContext context, Object base, Object property)

Implements abstract javax.el.ELResolver.getType.

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 propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller can safely assume no value has been set.

Parameters
context:ELContext

The context of this evaluation.

base:Object

null

property:Object

The name of the bean.

Returns:Class<?>

If the propertyResolved property of ELContext was set to true, then the type of the bean with the given name. Otherwise, undefined.

Annotations
@Override
Exceptions
NullPointerException:
if context is null.
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.
getValueback to summary
public Object getValue(ELContext context, Object base, Object property)

Implements abstract javax.el.ELResolver.getValue.

If the base object is null and 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 propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

Parameters
context:ELContext

The context of this evaluation.

base:Object

null

property:Object

The name of the bean.

Returns:Object

If the propertyResolved property of ELContext was set to true, then the value of the bean with the given name. Otherwise, undefined.

Annotations
@Override
Exceptions
NullPointerException:
if context is null.
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.
isReadOnlyback to summary
public boolean isReadOnly(ELContext context, Object base, Object property)

Implements abstract javax.el.ELResolver.isReadOnly.

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 propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller can safely assume no value has been set.

Parameters
context:ELContext

The context of this evaluation.

base:Object

null

property:Object

The name of the bean.

Returns:boolean

If the propertyResolved property of ELContext was set to true, then true if the property is read-only or false if not; otherwise undefined.

Annotations
@Override
Exceptions
NullPointerException:
if context is null.
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.
setValueback to summary
public void setValue(ELContext context, Object base, Object property, Object value)

Implements abstract javax.el.ELResolver.setValue.

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 propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller can safely assume no value has been set.

Parameters
context:ELContext

The context of this evaluation.

base:Object

null

property:Object

The name of the bean

value:Object

The value to set the bean with the given name to.

Annotations
@Override
Exceptions
NullPointerException:
if context is null
PropertyNotWritableException:
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.