Map<String, Annotation> moAnns = mo.getAnnotations();
ManagementObject managementObject = (ManagementObject) moAnns.get(ManagementObject.class.getName());
if (managementObject != null && managementObject.isRuntime())
{
boolean merged = false;
ManagementComponent mc = managementObject.componentType();
boolean isMC = !(mc.type().length() == 0 && mc.subtype().length() == 0);
// Merge this with the ManagedObject
ManagedObject parentMO = moRegistry.get(key);
if (parentMO == null && isMC == false)
{
log.debug("Deferring resolution of runtime ManagedObject: "+managementObject);
// Save the runtime mo for merging
runtimeMOs.put(key, mo);
}
else
{
mergeRuntimeMO(parentMO, mo);
merged = true;
runtimeMOs.remove(key);
}
// Update the runtime state of any ManagedComponent associated with this runtime mo
ManagedComponent comp = md.getComponent(mo.getName());
if (comp != null)
{
RunState state = updateRunState(mo, comp);
log.debug("Updated component: "+comp+" run state to: "+state);
}
// There is no further processing of runtime ManagedObjects, unless its marked as a component
if (isMC == false)
return;
//
else if (merged == false)
{
Set<ManagedOperation> runtimeOps = mo.getOperations();
runtimeOps = createOperationProxies(mo, runtimeOps);
MutableManagedObject moi = (MutableManagedObject) mo;
moi.setOperations(runtimeOps);
}
}
else
{
// See if there is runtime info to merge
ManagedObject runtimeMO = runtimeMOs.get(key);
if (runtimeMO != null)
{
mergeRuntimeMO(mo, runtimeMO);
runtimeMOs.remove(key);
// Update the runtime state of any ManagedComponent associated with this runtime mo
ManagedComponent comp = md.getComponent(mo.getName());
if (comp != null)
{
RunState state = updateRunState(runtimeMO, comp);
log.debug("Updated component: "+comp+" run state to: "+state);
}
}
}
// Update the MO registry
// TODO - does this make sense? In case of a MetaType.isCollection we could get different results then
// ManagedObject prevMO = moRegistry.put(key, mo);
// if( prevMO != null )
// {
// // This should only matter for ManagedObjects that have a ManagementObjectID
// log.debug("Duplicate mo for key: "+key+", prevMO: "+prevMO);
// return;
// }
// Check for unresolved refs
checkForReferences(key, mo);
// Map any existing ManagedComponent types
for(ManagedComponent comp : md.getComponents().values())
{
log.debug("Updating ManagementComponent: "+comp);
ComponentType type = comp.getType();
Set<ManagedComponent> typeComps = compByCompType.get(type);
if (typeComps == null)
{
typeComps = new HashSet<ManagedComponent>();
compByCompType.put(type, typeComps);
}
typeComps.add(comp);
}
// Create ManagedComponents for ManagedObjects annotated with ManagementComponent
ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
if (mc != null && md.getComponent(mo.getName()) == null)
{
ComponentType type = new ComponentType(mc.type(), mc.subtype());
ManagedComponentImpl comp = new TempManagedComponentImpl(type, md, mo);
md.addComponent(mo.getName(), comp);
log.debug("Processing ManagementComponent("+mo.getName()+"): "+comp);
Set<ManagedComponent> typeComps = compByCompType.get(type);
if (typeComps == null)