| Method from com.sun.faces.el.ManagedBeanELResolver Detail: |
public Class getCommonPropertyType(ELContext context,
Object base) {
if (base != null) {
return null;
}
return Object.class;
}
|
public Iterator getFeatureDescriptors(ELContext context,
Object base) {
if (base != null) {
return null;
}
FacesContext facesContext =
(FacesContext) context.getContext(FacesContext.class);
BeanManager beanManager =
ApplicationAssociate.getCurrentInstance().getBeanManager();
if (beanManager == null || beanManager.getRegisteredBeans().isEmpty()) {
List< FeatureDescriptor > l = Collections.emptyList();
return l.iterator();
}
Map< String,BeanBuilder > beans = beanManager.getRegisteredBeans();
List< FeatureDescriptor > list =
new ArrayList< FeatureDescriptor >(beans.size());
// iterate over the list of managed beans
for (Map.Entry< String,BeanBuilder > bean : beans.entrySet()) {
String beanName = bean.getKey();
BeanBuilder builder = bean.getValue();
String loc = Util.getLocaleFromContextOrSystem(facesContext).toString();
Map< String,String > descriptions = builder.getDescriptions();
String description = null;
if (descriptions != null) {
description = descriptions.get(loc);
if (description == null) {
description = descriptions.get("DEFAULT");
}
}
list.add(Util.getFeatureDescriptor(beanName,
beanName,
(description == null) ? "" : description,
false,
false,
true,
builder.getBeanClass(),
Boolean.TRUE));
}
return list.iterator();
}
|
public Class getType(ELContext context,
Object base,
Object property) throws ELException {
if (base == null && property == null) {
String message = MessageUtils.getExceptionMessageString
(MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "base and property"); // ?????
throw new PropertyNotFoundException(message);
}
return null;
}
|
public Object getValue(ELContext context,
Object base,
Object property) throws ELException {
if (base != null) {
return null;
}
if (property == null) {
String message = MessageUtils.getExceptionMessageString
(MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "property");
throw new PropertyNotFoundException(message);
}
Object result = null;
FacesContext facesContext = (FacesContext)
context.getContext(FacesContext.class);
BeanManager manager =
ApplicationAssociate.getCurrentInstance().getBeanManager();
String beanName = property.toString();
if (manager != null
&& manager.isManaged(beanName)
&& !manager.isBeanInScope(beanName, facesContext)) {
// no bean found in scope. create a new instance
result = manager.create(beanName, facesContext);
context.setPropertyResolved(result != null);
}
return result;
}
|
public boolean isReadOnly(ELContext context,
Object base,
Object property) throws ELException {
if (base != null) {
return false;
}
if (property == null) {
String message = MessageUtils.getExceptionMessageString
(MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "property");
throw new PropertyNotFoundException(message);
}
return false;
}
|
public void setValue(ELContext context,
Object base,
Object property,
Object val) throws ELException {
if (base == null && property == null) {
String message = MessageUtils.getExceptionMessageString
(MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "base and property"); // ?????
throw new PropertyNotFoundException(message);
}
// The spec states that nothing ManagedBeanELResolver should
// do nothing in setValue() so that the BeanELResolver can do its
// thing, however, in 1.1, calling setValue() for a reference
// that happened to be a managed bean cause the bean to be created
// and pushed to scope if it wasn't already there. So ultimately,
// the user should be able to create a ValueExpression and call
// setValue() and expect it to work without having to call getValue()
// first.
FacesContext facesContext = (FacesContext)
context.getContext(FacesContext.class);
BeanManager manager =
ApplicationAssociate.getCurrentInstance().getBeanManager();
String beanName = property.toString();
if (manager != null
&& manager.isManaged(beanName)
&& !manager.isBeanInScope(beanName, facesContext)) {
// no bean found in scope. create a new instance
manager.create(beanName, facesContext);
}
}
|