Every MBean must have a name, more accurately, an ObjectName. Although, MBean could be named anything, E.g. “DogBean” or “SunnyDay”, it is important to choose consistent and well defined names to avoid inflicting mental torture on the poor soul who is interacting with your application via JMX.
Fortunately, MBean names follow some standard conventions and names can determine how Clients display MBeans. MBean names look like this:
domain:key=property
Remember this convention. Read the last line carefully. Notice that there are two parts with a : separating them. The first part is called domain and the second part is called key-properties-list.
Here’s an example MBean name with both domain and properties: com.somecompany.app:type=ThreadPool
Domain Naming Conventions
The domain could be any arbitrary string, but it cannot contain a : since it is used as a separator. Slash (/) isn’t allowed as well. If the domain name is not provided, then the MBean shows up under “DefaultDomain“. As mentioned earlier, domain names should be predictable. According to Oracle Technet:
….if you know that there is going to be an MBean representing a certain object, then you should be able to know what its name will be.
And then add further:
The domain part of an Object Name should start with a Java package name. This prevents collisions between MBeans coming from different subsystems. There might be additional text after the package name. Examples:
com.sun.someapp:type=Whatsit,name=5
com.sun.appserv.Domain1:type=Whatever
Key=Property Naming Conventions
The property list is optional and is in the following format:
name=property
If you wish to specify multiple properties, separate each of them by comma(,). For example:
com.somecompany.app:type=ThreadPool,poolname=Parser,scope=internal
They Key=Property should be used to uniquely identify MBean Objects, such as, each Object in the same domain may have different properties. For example:
com.somecompany.app:type=ThreadPool,name=Parser
com.somecompany.app:type=ThreadPool,name=Generator
That’s MBean naming convention from 1000 feet. If you want to get more information, please read here.
Wonderful article! We are linking to this particularly great
content on our website. Keep up the great writing.