Sun WBEM SDK Developer's Guide

Example — Setting Instances

The code segment in Example 4–11 gets a CIM instance, updates one of its property values, and passes the updated instances to the CIM Object Manager.

A CIM property is a value used to describe a characteristic of a CIM class. Properties can be thought of as a pair of functions, one to set the property value and one to get the property value.


Example 4–11 Setting Instances (setInstance)

...
{
    // 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);
		}
}
...