The mibgen compiler also generates the Java source code required for representing a whole MIB in an SNMP manager. The mibgen compiler parses an SNMP MIB and generates the following:
For agents and managers:
A class mapping symbolic names with object identifiers of MIB variables
For agents:
An MBean representing the whole MIB
Classes representing SNMP groups or entities as MBeans (and their corresponding metadata classes)
Classes representing SNMP tables
Classes representing SNMP enumerated types
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.0 Tutorial.
The mibgen compiler generates a Java file that represents and initializes the whole MIB. This class extends the class SnmpMib, which is an abstract Java class in the com.sun.jdmk.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.
Subclass the group MBean skeleton you want to implement, completing the getter, checker, and setter methods.
Subclass the generated MIB file.
Redefine the factory methods for the group MBeans you have implemented, ensuring 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 (_).
The mibgen compiler generates a Java file that contains the code required for representing a whole MIB in an SNMP manager OidTable. This class extends the com.sun.jdmk.snmp.snmpOidTableSupport class, which implements the javax.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. It contains metadata definitions for the compiled MIB. The metadata can then be loaded into the SNMP OidTable.
The file is always generated when mibgen is invoked, and 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.