401641 Fixed MBean setter for String[]

This commit is contained in:
Greg Wilkins 2013-02-25 13:28:39 +11:00
parent 7a2b775f03
commit d4ad2ccfc7
1 changed files with 13 additions and 15 deletions

View File

@ -622,27 +622,25 @@ public class ObjectMBean implements DynamicMBean
boolean convert = false;
// determine if we should convert
Class<?> returnType = method.getReturnType();
Class<?> return_type = method.getReturnType();
if ( returnType.isArray() )
// get the component type
Class<?> component_type = return_type;
while ( component_type.isArray() )
{
returnType = returnType.getComponentType();
component_type = component_type.getComponentType();
}
// Test to see if the returnType or any of its super classes are managed objects
convert = isAnnotationPresent(returnType, ManagedObject.class);
convert = isAnnotationPresent(component_type, ManagedObject.class);
String uName = name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1);
Class<?> oClass = onMBean ? this.getClass() : _managed.getClass();
LOG.debug("defineAttribute {} {}:{}:{}:{}",name,onMBean,readonly,oClass,description);
Class<?> type = null;
Method setter = null;
type = returnType;//method.getReturnType();
// dig out a setter if one exists
if (!readonly)
{
@ -667,7 +665,7 @@ public class ObjectMBean implements DynamicMBean
continue;
}
setter = methods[m];
if ( !type.equals(methods[m].getParameterTypes()[0]))
if ( !component_type.equals(methods[m].getParameterTypes()[0]))
{
LOG.warn("Type conflict for mbean attr {} in {}", name, oClass);
continue;
@ -685,8 +683,8 @@ public class ObjectMBean implements DynamicMBean
continue;
}
setter = methods[m];
if ( !type.equals(methods[m].getParameterTypes()[0]))
{
if ( !return_type.equals(methods[m].getParameterTypes()[0]))
{
LOG.warn("Type conflict for mbean attr {} in {}", name, oClass);
continue;
}
@ -696,18 +694,18 @@ public class ObjectMBean implements DynamicMBean
if (convert)
{
if (type==null)
if (component_type==null)
{
LOG.warn("No mbean type for {} on {}", name, _managed.getClass());
return null;
}
if (type.isPrimitive() && !type.isArray())
if (component_type.isPrimitive() && !component_type.isArray())
{
LOG.warn("Cannot convert mbean primative {}", name);
return null;
}
LOG.debug("passed convert checks {} for type {}", name, type);
LOG.debug("passed convert checks {} for type {}", name, component_type);
}
try
@ -721,7 +719,7 @@ public class ObjectMBean implements DynamicMBean
{
_convert.add(name);
if (type.isArray())
if (component_type.isArray())
{
info= new MBeanAttributeInfo(name,OBJECT_NAME_ARRAY_CLASS,description,true,setter!=null,method.getName().startsWith("is"));
}