Java Dynamic Management Kit 5.1 Tools Reference Guide

1.4 Output From the mibgen Compiler

The mibgen compiler also generates the Java source code that is required for representing a whole MIB in an SNMP manager. The mibgen compiler parses an SNMP MIB and generates the following.

MBeans generated by the mibgen compiler need to be updated to provide the definitive implementation. For more information, see the corresponding section in the Java Dynamic Management Kit 5.1 Tutorial.

1.4.1 Representation of the Whole MIB

The mibgen compiler generates a Java file that represents and initializes the whole MIB. This class extends the class SnmpMib. SnmpMib is an abstract Java class in the com.sun.management.snmp.agent package and is a logical abstraction of an SNMP MIB. The SNMP adaptor uses the SnmpMib class to implement agent behavior. The generated MIB file offers factory methods for group MBeans.

To Implement the Generated MIB File
  1. Subclass the group MBean skeleton you want to implement, and complete the getter, checker, and setter methods.

  2. Subclass the generated MIB file.

  3. Redefine the factory methods for the group MBeans you have implemented, and ensure that they instantiate the actual implementation class and not the skeleton.

The mibgen compiler uses the module name specified in the MIB definition to name files representing whole MIBs. The compiler removes special characters and replaces them with an underscore character (_).

1.4.2 Representation of the Whole MIB in an SNMP OidTable

The mibgen compiler generates a Java file that contains the code required to represent a whole MIB in an SNMP manager OidTable. This class extends the com.sun.management.snmp.snmpOidTableSupport class, which implements the com.sun.management.snmp.snmpOidTable class and maintains a database of MIB variables. A name can be resolved against the database. This file can be used by both the agent and the manager API and contains metadata definitions for the compiled MIB. The metadata can then be loaded into the SnmpOid table.

The file is always generated when mibgen is invoked. The generated file is called MIBnameOidTable. The -mo option generates only the MIBnameOidTable file. This file is the only file generated for SNMP managers. All other files are dedicated to the SNMP agents.