
After getting a reference to the MBean server, you have to instantiate an MBean and register it using either the standard methods from the MBeanServer interface or a convenience method from the class com.sap.jmx.ObjectNameFactory (available in the JMX library).
In this case you have to use the convenience method getNameForApplicationResourcePerNode(..) to build the ObjectName under which the MBean is registered.
<text-monitor name="Bank name" configuration-group="Name"> <monitored-resource name="BankMBean" type="APPLICATION"/> <text-attribute-mapping> <text-attribute> <observed-resource-attribute name="BankName"/> </text-attribute> </text-attribute-mapping> </text-monitor>
ObjectName monitoringObjectName = ObjectNameFactory.getNameForApplicationResourcePerNode( "BankMBean", RuntimeProperties.get(RuntimeProperties.PROPERTY_APPLICATION), ObjectNameFactory.EMPTY_VALUE, ObjectNameFactory.EMPTY_VALUE);
The second parameter in the method g etNameForApplicationResourcePerNode(..) is the name of the application that registers the MBean. If you do not want to hardcode the name, you can call RuntimeProperties.get(RuntimeProperties.PROPERTY_APPLICATION) , as shown in the example, to get the name of the currently executed application.
As a result, an ObjectName similar to the one listed below, is created and used for the resource MBean, but this is completely transparent to the resource developer:
com.sap.default:name=BankMBean,SAP_J2EEApplicationPerNode=sap.com/Bank,j2eeType=SAP_ApplicationResourcePerNode,SAP_J2EEClusterNode=5939850,SAP_J2EECluster=C11
Next, see Registering the MBean .