{
log.debug("ManagedObject("+name+") is ManagedComponent type: "+mc);
moAnnotations.put(ManagementComponent.class.getName(), mc);
}
// ManagementObject level default factory classes
FieldsFactory ff = getAnnotation(FieldsFactory.class, classInfo, metaData);
if(ff != null)
moFieldsFactory = ff.value();
moCPF = getAnnotation(ConstraintsPopulatorFactory.class, classInfo, metaData);
if(moCPF != null)
moConstraintsFactory = moCPF.value();
ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, classInfo, metaData);
if(mpf != null)
moPropertyFactory = mpf.value();
}
if (trace)
{
log.trace("Building MangedObject(name="+name+",nameType="+nameType
+",attachmentName="+attachmentName+",isRuntime="+isRuntime+")");
}
ManagementProperties propertyType = ManagementProperties.ALL;
Set<String> classProperties = null;
if (managementObject != null)
{
propertyType = managementObject.properties();
if(propertyType == ManagementProperties.CLASS || propertyType == ManagementProperties.CLASS_AND_EXPLICIT)
{
classProperties = new HashSet<String>();
for(ManagementProperty mp : managementObject.classProperties())
{
if(mp.name().length() > 0)
classProperties.add(mp.name());
if(mp.mappedName().length() > 0)
classProperties.add(mp.mappedName());
}
}
}
// Build the ManagedProperties
Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
if (propertyInfos != null && propertyInfos.isEmpty() == false)
{
for (PropertyInfo propertyInfo : propertyInfos)
{
// Ignore the "class" property
if ("class".equals(propertyInfo.getName()))
continue;
ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
DefaultValueBuilderFactory defaultsFactory = getAnnotation(DefaultValueBuilderFactory.class, propertyInfo, metaData);
HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
if (managementProperty != null)
propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
if (id != null)
{
propAnnotations.put(ManagementObjectID.class.getName(), id);
// This overrides the MO nameType
nameType = id.type();
}
if (ref != null)
propAnnotations.put(ManagementObjectRef.class.getName(), ref);
if (runtimeRef != null)
propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
if (rsp != null)
propAnnotations.put(RunStateProperty.class.getName(), rsp);
if (masked != null)
propAnnotations.put(Masked.class.getName(), masked);
// Check whether this property should be included
boolean includeProperty = false;
switch(propertyType)
{
// Only if the property as a ManagementProperty
case EXPLICIT:
includeProperty = managementProperty != null &&
(managementProperty.ignored() == false);
break;
// Only if the property is listed in the classProperties
case CLASS:
includeProperty = classProperties.contains(propertyInfo.getName());
break;
// Only if the property is listed in the classProperties
case CLASS_AND_EXPLICIT:
includeProperty = classProperties.contains(propertyInfo.getName())
|| (managementProperty != null && managementProperty.ignored() == false);
break;
// Any property that is not ignored
case ALL:
includeProperty = managementProperty == null
|| managementProperty.ignored() == false;
break;
}
if (includeProperty)
{
Fields fields = null;
Class<? extends Fields> factory = moFieldsFactory;
FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
if(ff != null)
factory = ff.value();
if (factory != null)
{
try
{
fields = factory.newInstance();