try {
if (mBeanInfo == null) {
final Class managementInterface = getManagementInterface(componentInstance.getClass(), management, null);
return new StandardMBean(componentInstance, managementInterface);
} else if (mBeanInfo instanceof ModelMBeanInfo) {
final ModelMBean mBean = new RequiredModelMBean((ModelMBeanInfo)mBeanInfo);
try {
mBean.setManagedResource(componentInstance, "ObjectReference");
} catch (final InvalidTargetObjectTypeException e) {
// N/A: "ObjectReference" is a valid reference type
} catch (final InstanceNotFoundException e) {
// N/A: the instance was a valid object
}