if (!(property instanceof String))
return null;
final String strProperty = (String)property;
final ManagedBean managedBean = runtimeConfig(context).getManagedBean(strProperty);
Object beanInstance = null;
if (managedBean != null)
{
context.setPropertyResolved(true);
// managed-bean-scope could be a ValueExpression pointing to a Map (since 2.0)
if (managedBean.isManagedBeanScopeValueExpression())
{
// check for cyclic references in custom scopes, if we are not in Production stage
boolean checkCyclicReferences =
facesContext.getApplication().getProjectStage() != ProjectStage.Production;
List<String> cyclicReferences = null;
if (checkCyclicReferences)
{
final Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
final String managedBeanName = managedBean.getManagedBeanName();
cyclicReferences = (List<String>) requestMap.get(CUSTOM_SCOPE_CYCLIC_REFERENCE_DETECTION);
if (cyclicReferences == null)
{
cyclicReferences = new ArrayList<String>();
requestMap.put(CUSTOM_SCOPE_CYCLIC_REFERENCE_DETECTION, cyclicReferences);
}
else if (cyclicReferences.contains(managedBeanName))
{
throw new ELException("Detected cyclic reference to managedBean " + managedBeanName);
}
cyclicReferences.add(managedBeanName);
}
try
{
Object customScope = managedBean.getManagedBeanScopeValueExpression(facesContext)
.getValue(facesContext.getELContext());
if (customScope instanceof Map)
{
beanInstance = ((Map) customScope).get(managedBean.getManagedBeanName());
}
else if (customScope != null)
{
throw new FacesException("The expression '" + managedBean.getManagedBeanScope() +
"' does not evaluate to java.util.Map. It evaluates to '" + customScope +
"' of type " + customScope.getClass().getName());
}
else
{
log.warning("Custom scope '" + managedBean.getManagedBeanScope() +
"' evaluated to null. Unable to determine if managed bean '" +
managedBean.getManagedBeanName() + "' exists.");
}
}
finally
{
if (checkCyclicReferences)
{
cyclicReferences.remove(managedBean.getManagedBeanName());
}
}
}
if (beanInstance == null)