}
Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
// Create a beans ManagedProperty, a list of BeanMetaData ManagedObjects
Fields fields = getFields("beans", beansType);
ManagedPropertyImpl beansMP = new ManagedPropertyImpl(bmdfMO, fields);
newProps.put("beans", beansMP);
// Create a ManagedObject for each of the beans BeanMetaData
List<BeanMetaData> beans = bmdf.getBeans();
if(beans != null)
{
for(BeanMetaData bmd : beans)
{
DeploymentUnit compUnit = unit.getComponent(bmd.getName());
if(compUnit == null)
{
log.debug("Failed to find component for bean: "+bmd.getName());
continue;
}
MetaData compMetaData = compUnit.getMetaData();
GenericValue gv = getManagedObjectValue(bmd, compMetaData, bmdfMO);
if(gv != null)
{
// The component managed objects need to be in the root map
ManagedObject compMO = (ManagedObject) gv.getValue();
// Use the ManagedObject name if it's not the same as the attachmentName
String managedObjectName = compUnit.getName();
if(compMO != null && compMO.getAttachmentName() != null)
{
managedObjectName = compMO.getAttachmentName().equals(compMO.getName()) ?
compUnit.getName() : compMO.getName();
}
// Add the managed object
managedObjects.put(managedObjectName, compMO);
// Add the bean MO to the beans list
tmpBeans.add(gv);
}
}
}
GenericValue[] beanMOs = new GenericValue[tmpBeans.size()];
tmpBeans.toArray(beanMOs);
CollectionValueSupport values = new CollectionValueSupport(beansType, beanMOs);
beansMP.setValue(values);
// Update the bean factory properties
bmdfMMO.setProperties(newProps);
}
}
GenericValue[] mos = new GenericValue[tmpBFs.size()];