Class clazz = method.getParameterTypes()[0];
Object value = null;
if (clazz == ObjectName.class)
{
value = on;
}
else
{
MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
value = MBeanProxyExt.create(clazz, on, server);
}
try
{
method.invoke(instance, value);
}
catch (InvocationTargetException e)
{
throw new RuntimeException(e);
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e);
}