Class clazz = field.getType();
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
{
field.set(instance, value);
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e);
}