Solaris WBEM SDK Developer's Guide

Getting and Setting Instances

Client applications commonly use the getInstance method to retrieve CIM instances from the CIM Object Manager. When an instance of a class is created, it inherits the properties of the class it is derived from and all parent classes in its class hierarchy. The getInstance method takes the Boolean argument localOnly.

Use the setInstance method to update an existing instance.


Example 3-7 Getting and Setting Instances

The following example gets instances of an object path in an enumeration, updates the property value of b to 10 in each instance, and passes the updated instances to the CIM Object Manager.

...
{
    // Create an object path, an object that contains the CIM name for 
    // "myclass"
    CIMObjectPath cop = new CIMObjectPath("myclass"); 

    /* Get instances for each instance object path in an enumeration, 
    update the property value of b to 10 in each instance, and pass the 
    updated instance to the CIM Object Manager. */
    
    while(e.hasMoreElements()) {
           CIMInstance ci = cc.getInstance((CIMObjectPath)(e.nextElement
                                          ()),true, true, true, null);
           ci.setProperty("b", new CIMValue(new Integer(10)));
           cc.setInstance(new CIMObjectPath(),ci);
           }
}
...