I want to register more than one MBean of same class.
I have Hello
class implementing the HelloMBean
interface.
Now in main i have two object of Hello
class and I want to register them both
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("mBeans:type=Hello");
Hello h1 = new Hello();
Hello h2 = new Hello();
mbs.registerMBean(h1, name);
mbs.registerMBean(h2, name);
This throws InstanceAlreadyExistsException
.
How can I register both h1 and h2, and using jConsole view both of them?
Reason of this,
I want to change the attribute value of both h1 and h2 object
through MBean