Our example only implements a fraction of the attributes, those that are used in this tutorial. The others are just initialized with some plausible value. These implementations are contained in the classes with the Impl suffix. These implementation classes extend those that are generated by mibgen so that we can regenerate them without overwriting our customizations.
Here is a summary of the implementation shown in the agent example:
InterfaceImpl.java - adds a new entry notification listener to the IfTable object, then creates two table entries with plausible values and adds them to the table; associated with:
TableEntryListenerImpl.java - the listener for table entry creation and deletion notifications: prints out the new table entry's values
IfEntryImpl.java - implements a table entry and provides an internal method for switching the OperStatus variable that triggers a trap (see Example 7-2); this method is not exposed in the MBean interface, so it is only available to the code of this agent application
SnmpImpl.java - initializes and implement variables of the Snmp group; many of these are state variables of the SNMP agent, so we call the getter methods of the SNMP adaptor object to return the information
SystemImpl.java - initializes the System group variables with some realistic values
The SnmpImpl.java and SystemImpl.java files provide code that you may reuse when you need to implement these common SNMP groups.
The only class that we need to replace is RFC1213_MIB. Our implementation is located in patchfiles/RFC1213_MIB.java so that we can overwrite the one generated by mibgen. The main function of this MBean is to register the other MBeans of the MIB during its pre-registration phase. Our customization consists of specifying our *Impl classes when instantiating the group and table entry MBeans.