{
boolean trace = log.isTraceEnabled();
BeanInfo beanInfo = configuration.getBeanInfo(clazz);
ClassInfo classInfo = beanInfo.getClassInfo();
ManagementObject managementObject = getAnnotation(ManagementObject.class, classInfo, metaData);
if( managementObject == null )
{
if (trace)
log.trace("No ManagementObject annotation, skipping ManagedObject for class: "+clazz);
// Skip the ManagedObject creation
return null;
}
// If a targetInterface exists, rebuild the BeanInfo from that
Class<?> targetInterface = managementObject.targetInterface();
if(targetInterface != Object.class)
{
beanInfo = getBeanInfo(targetInterface);
classInfo = beanInfo.getClassInfo();
}
HashMap<String, Annotation> moAnnotations = new HashMap<String, Annotation>();
moAnnotations.put(ManagementObject.class.getName(), managementObject);
ManagementDeployment mnagementDeployment = getAnnotation(ManagementDeployment.class, classInfo, metaData);
if(mnagementDeployment != null)
moAnnotations.put(ManagementDeployment.class.getName(), mnagementDeployment);
ManagementObjectID moID = getAnnotation(ManagementObjectID.class, classInfo, metaData);
if (moID != null)
moAnnotations.put(ManagementObjectID.class.getName(), moID);
// Process the ManagementObject fields
boolean isRuntime = managementObject.isRuntime();
String name = classInfo.getName();
String nameType = null;
String attachmentName = classInfo.getName();
Class<? extends Fields> moFieldsFactory = null;
ConstraintsPopulatorFactory moCPF = null;
Class<? extends ManagedPropertyConstraintsPopulatorFactory> moConstraintsFactory = null;
Class<? extends ManagedProperty> moPropertyFactory = null;
if (managementObject != null)
{
name = managementObject.name();
if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
name = classInfo.getName();
nameType = managementObject.type();
if (nameType.length() == 0)
nameType = null;
attachmentName = managementObject.attachmentName();
if (attachmentName.length() == 0)
attachmentName = classInfo.getName();
// Check for a component specification
ManagementComponent mc = null;
if (metaData != null )
mc = metaData.getAnnotation(ManagementComponent.class);
if (mc == null)
mc = managementObject.componentType();
// Work around JBMDR-51 by checking type/subtype
// if (mc.equals(AnnotationDefaults.COMP_TYPE) == false)
if (mc.type().length() > 0 || mc.subtype().length() > 0)
{
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());