Sun WBEM SDK Developer's Guide

Using the APIs to Specify an Instance

In practice, you will usually use the enumInstances method to return all instances of a given class. Then, use a loop structure to iterate through the instances In the loop, you can pass each instance to an association method. The code segment in the following example does the following:

  1. Enumerates the instances in the current class (op) and the subclasses of the current class.

  2. Uses a While loop to cast each instance to a CIMObjectPath (op),

  3. Passes each instance as the first argument to the associators method.

This code example passes null or false values for all other parameters.


Example 4–16 Passing Instances to the associators Method

 {
    ...
    Enumeration e = cc.enumInstances(op, true);
    while (e.hasMoreElements()) {
        op = (CIMObjectPath)e.nextElement();
        Enumeration e1 = cc.associators(op, null, null, 
                null, null, false, false, null);
    ...
    }