VDanyliuk
VDanyliuk

Reputation: 1049

How to specify name of mbean with annotation @MBean

I have SAR archive for JBoss and there is one MBean registered in jboss-service.xml. Now I want to migrate to TomEE and use standard javax.management annotation @MBean, but I can't find out how to specify name of it and it creates with default name. Can anyone help me?

Upvotes: 1

Views: 639

Answers (2)

Adriaan Koster
Adriaan Koster

Reputation: 16209

You have to specify the name when registering the bean as described here:

  MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
  ObjectName name = new ObjectName("com.example.mbeans:type=Hello"); 
  Hello mbean = new Hello(); 
  mbs.registerMBean(mbean, name); 

Upvotes: 1

Related Questions