How to get notification of jconsole connection inside mxbean
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.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.