The example provider is a Java program that returns system properties and prints the string, "Hello World." The provider calls native C methods to execute the code and return the values to the provider.
The following table describes the files that make up the example Provider program.
Table 8-2 Provider Example Files
File |
Purpose |
---|---|
NativeProvider |
Top level provider program that fulfills requests from the CIM Object Manager and routes them to the Native_Example provider. The NativeProvider program implements the instanceProvider and methodProvider APIs, and declares methods that enumerate instances and get an instance of the Native_Example class. It also declares a method that invokes a method to print the string "Hello World." |
Native_Example.mof |
Creates a class that registers the NativeProvider provider with the CIM Object Manager. The Native_Example.mof file identifies NativeProvider as the provider to service requests for dynamic data in the Native_Example class. This MOF file also declares the properties and methods to be implemented by the NativeProvider. |
Native_Example.java |
The NativeProvider program calls this provider to implement methods that enumerate instances and get an instance of the Native_Example class. The Native_Example provider uses the APIs to enumerate objects and create instances of objects. The Native_Example class declares native methods, which call C functions in the native.c file to get system-specific values, such as host name, serial number, release, machine, architecture, and manufacturer. |
native.c |
C program that implements calls from the Native_Example Java provider in native C code. |
Native_Example.h |
Machine-generated header file for Native_Example class. Defines the correspondence between the Java native method names and the native C functions that execute those methods. |
libnative.so |
Binary native C code compiled from the native.c file. |
For detailed information on writing and integrating Java programs with native methods, visit the Java Web page at http://www.javasoft.com/docs/books/tutorial/native1.1/TOC.html.
The example provider program, NativeProvider, enumerates instances and gets properties for instances of the Native_Example class. You can use the CIM WorkShop to view this class and its instances.
Specify the location of shared library files in one of the following ways:
Set the LD_LIBRARY_PATH environment variable to the location of the shared library files. For example:
% set LD_LIBRARY_PATH /install_dir/SUNWconn/wbem/demo/provider/jni/ |
Copy the shared library files to the directory specified by the LD_LIBRARY_PATH environment variable. Installation sets this environment variable to /install_dir/opt/SUNWconn/wbem/lib. For example:
% cp libnative.so /install_dir/opt/SUNWconn/wbem/lib % cp native.c /install_dir/opt/SUNWconn/wbem/lib % cp Native_Example.h /install_dir/opt/SUNWconn/wbem/lib |
Move the provider class files to the directory containing the CIM Object Manager. For example:
% mv Native*.class /install_dir/opt/SUNWconn/wbem/bin |
Make sure the CIM Object Manager is running.
The installation starts the CIM Object Manager. If it is not running, see "Restarting the CIM Object Manager".
Compile the Native_Example.mof file. For example:
% mofcomp Native_Example.mof |
Compiling this MOF file loads the Native_Example class in the CIM Object Manager and identifies NativeProvider as its provider.
Run CIM WorkShop and view the Native_Example class. For example:
% /opt/SUNWconn/wbem/bin/cimworkshop & |
In the Toolbar, click the Find Class icon.
In the Input dialog box, type Native_Example and click OK.