Skip to main content

How to get notification of jconsole connection inside mxbean

No replies
byhisdeeds
Offline
Joined: 2006-01-06

I have an application that I monitor using jconsole and a MXBean. I want to get notification when I connect to it using jconsole. I tried using the following code but get no notifications or errors.

MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName object = new ObjectName("my.object:type=Mybean");
mbs.registerMBean(this, object);
mbs.addNotificationListener(object, this, null, null);

where 'this' is a reference to a class that extends the NotificationBroadcasterSupport class and implements the NotificationListener interface with the handleNotification(Notification notification, Object handback) method.

Can anybody say what I'm missing.