public class BeanNameELResolver extends ELResolver
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; } });
RESOLVABLE_AT_DESIGN_TIME, TYPE
Constructor and Description |
---|
BeanNameELResolver(BeanNameResolver beanNameResolver)
Constructor
|
Modifier and Type | Method and Description |
---|---|
Class<?> |
getCommonPropertyType(ELContext context,
Object base)
Always returns
String.class , since a bean name is a String. |
Iterator<FeatureDescriptor> |
getFeatureDescriptors(ELContext context,
Object base)
Always returns
null , since there is no reason to
iterate through a list of one element: bean name. |
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.
|
Object |
getValue(ELContext context,
Object base,
Object property)
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. |
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.
|
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.
|
convertToType, invoke
public BeanNameELResolver(BeanNameResolver beanNameResolver)
beanNameResolver
- The BeanNameResolver
that resolves a bean name.public Object getValue(ELContext context, Object base, Object property)
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.
getValue
in class ELResolver
context
- The context of this evaluation.base
- null
property
- The name of the bean.propertyResolved
property of
ELContext
was set to true
, then
the value of the bean with the given name. Otherwise, undefined.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.public void setValue(ELContext context, Object base, Object property, Object 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.
setValue
in class ELResolver
context
- The context of this evaluation.base
- null
property
- The name of the beanvalue
- The value to set the bean with the given name to.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.public Class<?> getType(ELContext context, Object base, Object property)
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.
getType
in class ELResolver
context
- The context of this evaluation.base
- null
property
- The name of the bean.propertyResolved
property of
ELContext
was set to true
, then
the type of the bean with the given name. Otherwise, undefined.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.public boolean isReadOnly(ELContext context, Object base, Object property)
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.
isReadOnly
in class ELResolver
context
- The context of this evaluation.base
- null
property
- The name of the bean.propertyResolved
property of
ELContext
was set to true
, then
true
if the property is read-only or
false
if not; otherwise undefined.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.public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
null
, since there is no reason to
iterate through a list of one element: bean name.getFeatureDescriptors
in class ELResolver
context
- The context of this evaluation.base
- null
.null
.FeatureDescriptor
public Class<?> getCommonPropertyType(ELContext context, Object base)
String.class
, since a bean name is a String.getCommonPropertyType
in class ELResolver
context
- The context of this evaluation.base
- null
.String.class
.Copyright © 1996-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.