- java.lang.Object
-
- javax.el.ELResolver
-
- javax.el.BeanNameELResolver
-
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 anELResolver
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
-
Fields inherited from class javax.el.ELResolver
RESOLVABLE_AT_DESIGN_TIME, TYPE
-
-
Constructor Summary
Constructors Constructor and Description BeanNameELResolver(BeanNameResolver beanNameResolver)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Class<?>
getCommonPropertyType(ELContext context, Object base)
Always returnsString.class
, since a bean name is a String.Iterator<FeatureDescriptor>
getFeatureDescriptors(ELContext context, Object base)
Always returnsnull
, 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 isnull
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.-
Methods inherited from class javax.el.ELResolver
convertToType, invoke
-
-
-
-
Constructor Detail
-
BeanNameELResolver
public BeanNameELResolver(BeanNameResolver beanNameResolver)
Constructor- Parameters:
beanNameResolver
- TheBeanNameResolver
that resolves a bean name.
-
-
Method Detail
-
getValue
public Object getValue(ELContext context, Object base, Object property)
If the base object isnull
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 theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.- Specified by:
getValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
-null
property
- The name of the bean.- Returns:
- If the
propertyResolved
property ofELContext
was 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
propertyResolved
property of theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller can safely assume no value has been set.- Specified by:
setValue
in classELResolver
- Parameters:
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.- Throws:
NullPointerException
- if context isnull
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.
-
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
propertyResolved
property of theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller can safely assume no value has been set.- Specified by:
getType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
-null
property
- The name of the bean.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the type 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.
-
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
propertyResolved
property of theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller can safely assume no value has been set.- Specified by:
isReadOnly
in classELResolver
- Parameters:
context
- The context of this evaluation.base
-null
property
- The name of the bean.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thentrue
if the property is read-only orfalse
if 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
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
Always returnsnull
, since there is no reason to iterate through a list of one element: bean name.- Specified by:
getFeatureDescriptors
in 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:
getCommonPropertyType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
-null
.- Returns:
String.class
.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/el/beannameelresolver.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.