tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject [OT] Self-describing JMX Beans
Date Wed, 05 Jun 2019 14:38:52 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

I'm starting to wire some application-specific JMX Beans into my
application and I'm struggling to make them self-describing. Meaning,
I'd like for a JMX client such as jconsole to show my customized
descriptions for the bean, the attributes, etc.

At first, I had a simple interface like:

  public interface MyMBean {
    public int getSomeValue();
  }

And an implementation:

  public class MyMBeanImpl implements MyMbean {
    public int getSomeValue() {
      return ...;
    }
  }

Doing a bit of reading, it looked like I needed to implement
ModelMBeanInfo in order to be able to return the various Info objects
to describe the MBean.

So I did the simplest thing I could possibly do: I extended
ModelMBeanInfoSupport:

  public class MyMBeanImpl
    extends ModelMBeanInfoSupport
    implements MyMbean {
    public MeMBeanImpl() {
      super("name", "description", createMBeanAttributeInfos(), null,
null, null);
    }
    public int getSomeValue() {
      return ...;
    }

    static MBeanAttributeInfo[] createMBeanAttributeInfos() {
      return new MBeanAttributeInfo[] {
        new MBeanAttributeInfo("SomeValue", "description", "int",
true, false, false);
      };
    }
  }

When I do this, there does not seem to be any change in the display
from VisualVM for this bean. The "SomeValue" attribute is still
showing with a description of "SomeValue" and not my custom description.

When registering the MBean with the server, I just do this:

MBeanServerFactory.findMBeanServer(null)[0].registerMBean(new
MyBean(), new ObjectName("path-to-my-object"));

What am I missing, here?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlz30/wACgkQHPApP6U8
pFgJyxAAkfUL/ZhGcwfhzJjWAQi9NeOOr+SKGTDTNnaQush4R5igD2qP/TSNEdzM
A+bL+v01ApCtubIjowahKL+1lFQXFQmSU38svdhtyv0x8X8hwomZ7nkscR+gdInr
ian674mmdKJyEHc4DgBTwEEf5PC3TwjlE0ijUGs6+sddVXKXURl+TO6Jj2JclRKX
6SksfInt7XKhLVEmH4HNv9/EuYHncDBszaDM0JXcY3dRDmc9Y12j2pTH2aawA//v
9PBlsy20QYeKSqeWsnQ/C/bWWOo+0Jbr7zR5rrIpxZRc2J/L4S6boyOmEgw1/ZGm
G3gzxIKoFG6c6ZjKqqc4I7Prr7FXQK8XcYg/qaaoHbVRnh1X2uO2jVxztffn6a8G
dn4As5QW4ovkOg7V0FuiE7x6rxbnb5emjmFucXUB/nbnNuQTf/bAgZTjrJQ1EdXq
SpVRXzQMou0Upeb3FcycXywIUe/YJ+8LdbaiHmDjluGC5V4ajCQDPTe/iONhP0lr
D+CRTGF7LgqQCuESvqJzJHuPMlRO6luWXqBulmHbT4GPEAiq7S7guzseo7F0n0Pt
NPjSqm3MONmGC7FuTPXyeYr8UJkESoNwwyI6dlcvIpepdxO+OAmcx8ThtVIiNuYZ
W/Gx7xjvRwZhY8aO6PT7Yp0lcK6tt/QtytZNB2B+BibQIfFy2fc=
=0UY1
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message