Before you can proceed with this example, you need to generate the JMX-MBEAN-SERVER-MIB and it's associated classes, by using the mibgen compiler supplied with Java DMK. For details of the mibgen compiler, see the Java Dynamic Management Kit 5.1 Tools Reference Guide.
The example MIB is contained in the configuration file JMX-MBEAN-SERVER-MIB.mib, which is found in examplesDir/current/Snmp/MBeanTable. You should run the example from within this directory.
Ensure that your PATH environment variable knows where to find mibgen.
In a default installation, mibgen is found in installDir/bin.
Create a new directory, generated, inside examplesDir/current/Snmp/MBeanTable.
$ mkdir generated |
This directory is where mibgen generates the classes associated with JMX-MBEAN-SERVER-MIB.mib.
Run the mibgen compiler.
$ mibgen -X:use-display-hint -d generated JMX-MBEAN-SERVER-MIB.mib |
The advanced mibgen option use-display-hint instructs mibgen to generate an attribute of type String for any object using a textual convention whose DISPLAY-HINT is 255a. This option is used because JMX-MBEAN-SERVER-MIB defines textual conventions (for example, JmxMBeanObjectNameTC) which must be translated into java.lang.String attributes, rather than the default Byte[] attributes.
The -d generated option sends the output of mibgen to the newly created generated directory
Within the generated directory, you see that mibgen has generated the following Java classes.
EnumJmxMBeanRowStatus, an enumerated type generated for the jmxMBeanRowStatus columnar variable defined in the MIB.
JmxMBeanAttrEntry, which implements the JmxMBeanAttrEntryMBean interface and is generated from the jmxMBeanAttrEntry conceptual row defined in the MIB. The JmxMBeanAttrEntry is an empty skeleton class that can be subclassed to implement a row in the jmxMBeanAttrTable defined in the MIB. This example shows how this generated class can be subclassed to provide an instrumented implementation, JmxMBeanAttrEntryImpl, that is linked to the actual resource exposed.
JmxMBeanAttrEntryMBean, which represents the public interface for the jmxMBeanAttrEntry conceptual row. An object implementing the JmxMBeanAttrEntryMBean interface represents a row in the jmxMBeanAttrTable, that is defined in the MIB.
JmxMBeanAttrEntryMeta, which constructs the SNMP metadata for the JmxMBeanAttrEntry conceptual row, that is defined in the MIB.
JmxMBeanAttrTableMeta, which constructs the SNMP metadata for the jmxMBeanAttrTable table, that is defined in the MIB.
JmxMBeanEntry, which implements the JmxMBeanEntryMBean interface and is generated from the jmxMBeanEntry conceptual row defined in the MIB. The JmxMBeanEntry is an empty skeleton class that can be subclassed to implement a row in the jmxMBeanTable defined in the MIB. This example shows how this generated class can be subclassed in order to provide an instrumented implementation, JmxMBeanEntryImpl. that is linked to the actual resource exposed.
JmxMBeanEntryMBean, which represents the public interface for the jmxMBeanEntry conceptual row. An object implementing the JmxMBeanEntryMBean interface represents a row in the jmxMBeanTable, that is defined in the MIB.
JmxMBeanEntryMeta, which constructs the SNMP metadata for the jmxMBeanEntry conceptual row defined in the MIB.
JmxMBeanServer, which represents the jmxMBeanServer group that is defined in the MIB. The JmxMBeanServer is an empty skeleton class that can be subclassed to implement the jmxMBeanServer group. This default implementation of the jmxMBeanServer group instantiates the generated default implementation for the two SNMP tables defined in that group:
TableJmxMBeanAttrTable for the jmxMBeanAttrTable.
TableJmxMBeanTable for the jmxMBeanTable.
This example shows how the generated class JmxMBeanServer, can be subclassed by JmxMBeanServerImpl, to instantiate specialized generated table classes that instantiate JmxMBeanAttrEntryImpl and JmxMBeanEntryImpl objects instead of the generated JmxMBeanAttrEntry and JmxMBeanEntry skeletons.
JmxMBeanServerMBean, which represents the public interface for the object that represents the jmxMBeanServer group.
JmxMBeanServerMeta, which constructs the SNMP metadata for the jmxMBeanServer group, that is defined in the MIB.
JMX_MBEAN_SERVER_MIB, which instantiates the metadata and instrumentation classes for all the objects defined in the JMX-MBEAN-SERVER-MIB module. This example shows how JMX_MBEAN_SERVER_MIB_Impl subclasses the generated JMX_MBEAN_SERVER_MIB, to instantiate the customized class JmxMBeanServerImpl instead of the generated skeletons.
JMX_MBEAN_SERVER_MIBOidTable, which is a convenience class generated by mibgen to make it possible to map symbolic OID definitions from the JMX-MBEAN-SERVER-MIB. For example, jmxMBeanAttrName is mapped to the corresponding OID value, 1.3.6.1.4.1.42.2.145.1.3.1.1.1.1.4.1.2.
JmxMBeanTableMeta, which constructs the metadata definitions for the jmxMBeanTable table defined in the MIB.
TableJmxMBeanAttrTable, which is the default implementation of the jmxMBeanAttrTable table defined in the MIB. By default, the table is empty.
TableJmxMBeanTable, which is the default implementation of the jmxMBeanTable table defined in the MIB. By default, the table is empty. If remote creation of rows through SNMP is enabled, the default implementation creates instances of the generated JmxMBeanEntry empty skeleton. The JmxMBeanServerImpl class provided in this example shows how to instantiate a specialized version of this class that creates customized JmxMBeanEntryImpl objects instead of the default implementation.