Solaris WBEM Developer's Guide

Retrieving Class Definitions

The getClass method gets a CIM class. When a class is created, the class inherits the methods and properties of all parent classes in the class hierarchy. The getClass method takes the localOnly Boolean argument.

Example 4–16 Retrieving a Class Definition

This example uses the following methods to retrieve a class definition:

import java.rmi.*;
import javax.wbem.client.CIMClient;
import javax.wbem.cim.CIMInstance;
import javax.wbem.cim.CIMValue;
import javax.wbem.cim.CIMProperty;
import javax.wbem.cim.CIMNameSpace;
import javax.wbem.cim.CIMObjectPath;
import javax.wbem.cim.CIMClass;
import javax.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]);
         UserPrincipal up = new UserPrincipal("root");
         PasswordCredential pc = new PasswordCredential("root_password");
         cc = new CIMClient(cns);
         CIMObjectPath cop = new CIMObjectPath(args[1]);
             // Returns only the methods and properties that 
             // are local to the specified class (localOnly is true).
         cc.getClass(cop, true);
      } catch (Exception e) {
         System.out.println("Exception: "+e);
      if(cc != null) {