Solaris WBEM SDK Developer's Guide

About The MOF Compiler

Managed Object Format (MOF) is a compiled language developed by the Distributed Management Task Force (DMTF) to define static and dynamic classes and instances for CIM and WBEM. You can use the CIM and Solaris MOFs that are included with Solaris WBEM Services, and you can create your own MOFs. For more information on creating your own MOFs using the DMTF's MOF language, see the DMTF Website at http://www.dmtf.org.

The MOF Compiler, mofcomp(1M), parses MOF files, converts the classes and instances to Java classes, and then adds the classes to the CIM Object Manager Repository in the default (root\cimv2) or other specified namespace. Because you can easily convert MOF files to Java, Java-based applications can interpret and exchange the data contained within MOF files on any machine that runs a Java Virtual Machine.

During a Solaris installation, the MOF Compiler automatically compiles the bundled MOF files that describe the CIM and Solaris Schema and adds them to the CIM Object Manager Repository.

Generating JavaBeans Using mofcomp

In the context of WBEM, JavaBeansTM or beans, define methods and instances for accessing and manipulating CIM classes and data elements. To simplify your development efforts, you can use the -j option with the mofcomp command to automatically generate JavaBeans that represent the CIM classes defined in your MOF files. These automatically-generated JavaBeans define the interfaces; it is up to you to add the implementation code.


Note -

To safeguard your program from changes that you make to the underlying JavaBeans implementation, use the interfaces rather than the original JavaBeans.


When you specify the -j option with mofcomp, a base Java interface named CIMBean.java and a base bean that implements the interface named CIMBeanImpl.java is generated. CIMBeanImpl.java contains all of the code that is common to the generated beans. All generated Java interfaces inherit from CIMBean.java and all generated beans inherit from CIMBeanImpl.java, consequently inheriting the base implementation.

For each CIM class that is defined in a MOF file, The MOF Compiler JavaBeans Generation Feature generates a Java interface that contains the following:

The Java interfaces are named CIMClassBean.java. Bean classes that implement those Java interfaces are named CIMClassBeanImpl.java. In addition, accessor methods for properties that contain the CIM DisplayName, Units, and Version qualifiers are generated.

For each invokeMethod that contains an OUT qualified parameter in a CIM class, a container interface that holds the output that the invoking of the method generates is generated. These interfaces are named CIMClass_MethodNameOutput.java. An instance of this CIMClass_MethodNameOutput.java container interface is required as the last parameter of the bean's method. This container interface is required because the Object datatype or datatypes that the bean's method takes as parameters are not mutatable, and therefore they cannot be used to hold both input and output data.

MOF File Elements

You must include the PACKAGE element in your MOF file to take advantage of the -j option. In addition, you can specify the IMPORTS and EXCEPTIONS elements, in the following format:

PACKAGE=NameOfJavaPackage
IMPORTS=JavaClassName1:JavaClassName2:...
EXCEPTIONS=Exception1:Exception2:...

Th following table describes these elements.

Table 2-1 MOF File Elements

Element 

Description 

PACKAGE

Required. Specifies the name of the Java package that contains the source files generated by the MOF Compiler. 

IMPORTS

Optional. Specifies the name(s) of the Java classes to import into the generated source files, separated with a colon (:). You can specify as many Java classes as you want, on as many lines as you want. 

EXCEPTIONS

Optional. Specifies the name(s) of the Java exceptions included in the generated source files, separated with a colon (:). You can specify as many Java class exceptions as you want, on as many lines as you want. 


Note -

If you specify EXCEPTIONS, you must specify IMPORTS.