com.sun.jdmk.tools
Class MibGen
java.lang.Object
com.sun.jdmk.tools.MibGen
public final class MibGen
- extends Object
The main class of the mibgen
tool.
The class compiles a SNMP MIB expressed using SNMP V1 or SNMP V2 SMI
and generates code for implementing the MIB as a set of MBeans.
The compiler accepts SNMPv1 or SNMPv2 definitions mixed into a same MIB
module.
A MIB file can contain several MIB modules.
In order to invoke the class, you need to invoke:
java com.sun.jdmk.tools.MibGen <options> <mib files>
where:
- -n: Parses the mib files without generating code
- -d dir: Generates code in the specified target directory
- -tp packageName: Generates code within the specified Java
package
- -desc: Includes the "DESCRIPTION" clause of OBJECT-TYPE as a
comment in the generated code
- -mo: Only generates the metadata definitions file for the MIB
variables (
SnmpOidTable
file);
Incompatible with -n
- -mc: Do not use the default MIB_CORE definitions file provided
with Java Dynamic Management(TM) Kit;
In this case, the user must specify the MIB_CORE definitions file
as one of the <mib files>
(ex: java com.sun.jdmk.tools.MibGen -mc mib my_mib_core)
- -a: Generates code for all the mib files;
Without this option, the java code is generated only for the first mib
file. In this case, the following mib files are simply used to resolve
some definitions of the first mib file.
- -p prefix: Uses the specified prefix for naming generated
classes
- -g: Generates a generic version of the metadata that
will access the MBeans through the MBeanServer instead of
using a direct reference.
- -gp prefix: Uses the specified prefix to name the generic
metadata classes. (e.g. the metadata class for group
system will be named SystemprefixMeta)
- -sp prefix: Uses the specified prefix to name the standard
metadata classes. (e.g. the metadata class for group
system will be named SystemprefixMeta)
- -help: Prints a usage message explaining how to invoke the
compiler
- <mib files>: List of MIB files to compile
In order to directly invoke the class, Java Dynamic Management(TM) Kit
provides a script called mibgen.
On UNIX platforms the script is provided under
<install_dir>/SUNWjdmk/5.1/bin.
On Windows platforms the script is provided under
<install_dir>\SUNWjdmk\5.1\bin.
Note:
The order followed by mibgen to find the MIB_CORE definitions file is:
- The user MIB_CORE definitions file specified in the <mib files>
using the
-mc
mibgen option.
- The user command line parameter specified using the
-Dmibcore.file
java option.
- The default MIB_CORE definitions file provided with jdmk under
<install_dir>/etc/mibgen (mib_core.txt).
To succeed, you must be able to derive the jdmk installation directory
from the CLASSPATH environment variable.
Otherwise, mibgen will look for the mib_core.txt file under
<current_dir>/etc/mibgen.
Method Summary |
static int |
compile(String[] args)
The compile method of the mibgen compiler. |
static void |
main(String[] args)
The main method of the mibgen compiler. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
main
public static void main(String[] args)
- The
main
method of the mibgen
compiler.
This method creates an instance of MibGen
and invokes
the compiler.
If an error occurs, the method exits the VM with a status of 1.
If the compilation succeeds, the method exits the VM with a status of 0.
This method allows you to specify optional command-line parameters
listed above
.
compile
public static int compile(String[] args)
- The
compile
method of the mibgen
compiler.
This method creates an instance of MibGen
and invokes the
compiler.
If an error occurs, the method returns with a status of 1.
If the compilation succeeds, the method return with a status of 0.
Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.