// Get the property from the bean
// First look to the mapped name
String name = property.getMappedName();
if (name == null)
name = property.getName();
PropertyInfo propertyInfo = property.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
if(propertyInfo == null)
propertyInfo = beanInfo.getProperty(name);
Object bean = locateBean(attachment.getName());
MetaValue mvalue = null;
if(propertyInfo.isReadable() == false)
{
if(log.isTraceEnabled())
log.trace("Skipping get of non-readable property: "+propertyInfo);
return null;
}
try
{
String getterClassName = propertyInfo.getGetter().getDeclaringClass().getName();
if(getterClassName.equals(attachment.getClass().getName()))
{
// use attachment
mvalue = delegateICF.getValue(beanInfo, property, metaData, attachment);
}
else if(bean != null)
{
// use bean (if installed)
mvalue = delegateICF.getValue(beanInfo, property, metaData, bean);
}
else
{
// Try to find the property in the meta data
PropertyMetaData md = null;
if(attachment.getProperties() != null && attachment.getProperties().isEmpty() == false)
{
for(PropertyMetaData bp : attachment.getProperties())
{
if(name.equals(bp.getName()))
{
md = bp;
break;
}
}
if(md != null)
{
// TODO add metaMapping
if(md.getValue() != null)
{
mvalue = metaValueFactory.create(md.getValue().getUnderlyingValue(),
propertyInfo.getType());
}
}
}
}
}
catch(Throwable e)
{
log.debug("Failed to get property value for bean: "+beanInfo.getName()
+", property: "+propertyInfo.getName(), e);
mvalue = metaValueFactory.create(null, propertyInfo.getType());
return mvalue;
}
return mvalue;
}