Sun WBEM SDK Developer's Guide

Specifying the Source Class or Instance

The association methods each take one required argument, CIMObjectPath, which is the name of a source CIM class or CIM instance whose associations or associated classes or instances you want to return. If the CIM Object Manager finds no associations or associated classes or instances, it returns nothing.

If the CIMObjectpath is a class, the association methods return the associated classes and the subclasses of each associated class. If the CIMObjectpath is an instance, the methods return the associated instances and the class from which each instance is derived.

Using the Model Path to Specify an Instance

To specify the name of an instance or class, you must specify its model path. The model path for a class includes the namespace and class name. The model path for an instance uniquely identifies a particular managed resource. The model path for an instance includes the namespace, class name, and keys. A key is a property or set of properties used to uniquely identify managed resource. Key properties are marked with the KEY qualifier.

The model path \\myserver\\Root\cimv2\Solaris_ComputerSystem.Name=mycomputer: CreationClassName=Solaris_ComputerSystem has three parts:

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