Solaris WBEM Developer's Guide

Generating JavaBeans Components Using mofcomp

In the context of WBEM, JavaBeans components, or beans, define methods for accessing and manipulating CIM classes and data. To simplify your development efforts, you can use the -j option to the mofcomp command to generate beans from the CIM classes in your MOF files. These automatically-generated beans define the interfaces. You must 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 components.


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

For each CIM class that is defined in a MOF file, the MOF compiler JavaBeans generation feature generates a Java programming language interface that contains the following methods:

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 mutable. Therefore these data types 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:...

The following table describes these elements.

Table 7–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 names of the Java classes to import into the generated source files. These classes are 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 names of the Java exceptions that are included in the generated source files. These exceptions are 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.