*/
@SuppressWarnings("unchecked")
protected void populateValues(MutableManagedObject managedObject, T object,
MetaData metaData)
{
InstanceClassFactory icf = getInstanceClassFactory(object.getClass(), metaData);
Class moClass;
try
{
moClass = icf.getManagedObjectClass(object);
}
catch(ClassNotFoundException e)
{
throw new IllegalStateException(e);
}
BeanInfo beanInfo = managedObject.getTransientAttachment(BeanInfo.class);
if(beanInfo == null)
beanInfo = configuration.getBeanInfo(moClass);
Object componentName = null;
Map<String, ManagedProperty> properties = managedObject.getProperties();
if (properties != null && properties.size() > 0)
{
for (ManagedProperty property : properties.values())
{
MetaValue value = null;
try
{
value = icf.getValue(beanInfo, property, metaData, object);
}
catch(Throwable t)
{
if(log.isTraceEnabled())
log.trace("Failed to access value for property: "+property, t);
}
if (value != null)
property.setField(Fields.VALUE, value);
/* Need to look for a ManagementObjectID at the property level which
defines the ManagedObject id name from the property value.
*/
Map<String, Annotation> annotations = property.getAnnotations();
if (annotations == null && metaData == null)
continue;
ManagementObjectID id = getAnnotation(ManagementObjectID.class, annotations, metaData);
if (id != null)
{
if (value == null || value.getMetaType().isSimple() == false)
{
log.warn("Cannot create String name from non-Simple property: " + property + ", value=" + value);
continue;
}
SimpleValue svalue = (SimpleValue) value;
String name = id.prefix() + svalue.getValue() + id.suffix();
log.debug("Created name: "+name+" from property: "+property.getName());
managedObject.setName(name);
}
ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, annotations, metaData);
if (runtimeRef != null)
{
componentName = icf.getComponentName(beanInfo, property, object, value);
if(componentName == null && defaultInstanceFactory != null)
{
InstanceClassFactory dicf = defaultInstanceFactory;
componentName = dicf.getComponentName(beanInfo, property, object, value);
}
}
}
}
if (componentName == null)