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.
If localOnly is true, getClass returns only noninherited properties and methods.
If localOnly is false, getClass returns all properties in the class.
This example uses the following methods to retrieve a class definition:
CIMNameSpace – Create a new name space
CIMClient – Create a new client connection to the CIM Object Manager
CIMObjectPath – Create an object path, which is an object to contain the name of the class to retrieve
getClass – Retrieve the class from the CIM Object Manager
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 * name space 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) { cc.close(); } } }