Sun WBEM SDK Developer's Guide

Example — Creating an Instance

The code segment in Example 4–6 uses the newInstance method to create a Java class representing a CIM instance (for example, a Solaris package) from the Solaris_Package class.


Example 4–6 Creating an Instance (newInstance())

...
{ 
/*Connect to the CIM Object Manager in the root\cimv2 
namespace on the local host. Specify the username and password of an 
account that has write permission to the objects in the 
root\cimv2namespace. */
 
CIMClient cc = new CIMClient(cns, "root", "root_password");
 
// Get the Solaris_Package class
cimclass = cc.getClass(new CIMObjectPath("Solaris_Package"), true, true, true, null);
 
/* Create a new instance of the Solaris_Package 
 class populated with the default values for properties. If the provider
 for the class does not specify default values, the values of the 
 properties will be null and must be explicitly set. */
 
 ci = cimclass.newInstance();
}
...