Java Dynamic Management Kit 5.1 Tools Reference Guide

1.7 Information Mapping

For each group defined in your MIB, the mibgen compiler generates an MBean. Each variable in the group is represented as a property of the MBean. If the MIB allows read access to a variable, the mibgen compiler generates a getter method for the corresponding property. If the MIB allows write access to a variable, the mibgen compiler generates a setter method for the property. Tables are seen as indexed properties whose type corresponds to the table entry type. The SNMP view of the table is maintained by a specific table object contained in the generated MBean. The mibgen compiler maps the MIB variable syntax to a well-defined Java type.

The MBeans that the mibgen compiler generates do not have any dependencies on specific SNMP objects. Therefore, these MBeans can be easily browsed or integrated into the various Java DMK components. The translation between the SNMP syntax and the MBean syntax is performed by the metadata.

MBeans generated by the mibgen compiler must be updated to provide the definitive implementation. The generated code is an operational agent. Thus, the code can be compiled, run, and tested without any modification.

As a general rule, use subclassing to implement your custom behavior. Do not edit the generated file, or your modification will be lost when you regenerate your MIB. Instead of subclassing the generated skeleton classes, you can also provide your own implementation that simply implements the corresponding generated interface, as shown in the SNMP Virtual Tables example in the Java Dynamic Management Kit 5.1 Tutorial.

Example 1–1 shows how to implement a skeletal MBean.


Example 1–1 Implementing a Skeletal MBean

public class g1 implements g1MBean, Serializable { 	
	    protected Integer myVar = new Integer (1);
      public g1(SnmpMib myMib) {
      {
      public Integer getMyVar() throws SnmpStatusException {
          return myVar;
      }

       public void setMyVar(Integer x)  throws SnmpStatusException {
           myVar = x;
      }

}

You must subclass or provide an implementation of the skeletal MBean to implement your MIB behavior. For information about developing an SNMP agent, SNMP Manager, SNMP API, and SNMP Proxy, see the corresponding sections in the Java Dynamic Management Kit 5.1 Tutorial.