@Override public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // Register MBean first on this MBean Server ObjectInstance ret = super.registerMBean(object, name); // Check, whether it is annotated with @JsonMBean. Only the outermost class of an inheritance is // considered. JsonMBean anno = extractJsonMBeanAnnotation(object); if (anno != null) { // The real name can be different than the given one in case the default // domain was omitted and/or the MBean implements MBeanRegistration ObjectName realName = ret.getObjectName(); try { // Fetch real MBeanInfo and create a dynamic MBean with modified signature MBeanInfo info = super.getMBeanInfo(realName); JsonDynamicMBeanImpl mbean = new JsonDynamicMBeanImpl(this,realName,info,getJsonConverterOptions(anno)); // Register MBean on delegate MBeanServer delegatedMBeans.add(realName); delegateServer.registerMBean(mbean,realName); } catch (InstanceNotFoundException e) { throw new MBeanRegistrationException(e,"Cannot obtain MBeanInfo from Jolokia-Server for " + realName); } catch (IntrospectionException e) { throw new MBeanRegistrationException(e,"Cannot obtain MBeanInfo from Jolokia-Server for " + realName); } catch (ReflectionException e) { throw new MBeanRegistrationException(e,"Cannot obtain MBeanInfo from Jolokia-Server for " + realName); } } return ret; }
@Override public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // Register MBean first on this MBean Server ObjectInstance ret = super.registerMBean(object, name); // Check, whether it is annotated with @JsonMBean. Only the outermost class of an inheritance is // considered. JsonMBean anno = extractJsonMBeanAnnotation(object); if (anno != null) { // The real name can be different than the given one in case the default // domain was omitted and/or the MBean implements MBeanRegistration ObjectName realName = ret.getObjectName(); try { // Fetch real MBeanInfo and create a dynamic MBean with modified signature MBeanInfo info = super.getMBeanInfo(realName); JsonDynamicMBeanImpl mbean = new JsonDynamicMBeanImpl(this,realName,info,getJsonConverterOptions(anno)); // Register MBean on delegate MBeanServer delegatedMBeans.add(realName); delegateServer.registerMBean(mbean,realName); } catch (InstanceNotFoundException e) { throw new MBeanRegistrationException(e,"Cannot obtain MBeanInfo from Jolokia-Server for " + realName); } catch (IntrospectionException e) { throw new MBeanRegistrationException(e,"Cannot obtain MBeanInfo from Jolokia-Server for " + realName); } catch (ReflectionException e) { throw new MBeanRegistrationException(e,"Cannot obtain MBeanInfo from Jolokia-Server for " + realName); } } return ret; }