WBEMfor Solaris on Sun Developer's Guide

Example -- Retrieving a Class Definition

The code shown in Example 6-12, uses the following methods to retrieve a class definition:


Example 6-12 Retrieving a Class Definition (getClass)

import java.rmi.*;
import com.sun.wbem.client.CIMClient;
import com.sun.wbem.cim.CIMInstance;
import com.sun.wbem.cim.CIMValue;
import com.sun.wbem.cim.CIMProperty;
import com.sun.wbem.cim.CIMNameSpace;
import com.sun.wbem.cim.CIMObjectPath;
import com.sun.wbem.cim.CIMClass;
import com.sun.wbem.cim.CIMException;
import java.util.Enumeration;
 
/**
 * Gets the class specified in the command line. Works in the default
 * namespace /root/cimv2.
 */
public class GetClass {
    public static void main(String args[]) throws CIMException {
        CIMClient cc = null;
        try {
            CIMNameSpace cns = new CIMNameSpace(args[0]);
 
            cc = new CIMClient(cns);
 
            CIMObjectPath cop = new CIMObjectPath(args[1]);
            cc.getClass(cop);
        }
        catch (Exception e) {
            System.out.println("Exception: "+e);
        }
        if(cc != null) {
            cc.close();
        }
    }
}