WBEMfor Solaris on Sun Developer's Guide

Example -- Calling a Method

The code segment in Example 6-11 gets the instances of the CIM_Service class (services that manage device or software features) and uses the invokeMethod method to stop each service.


Example 6-11 Calling a Method (invokeMethod)

{
 
 
/* Pass the CIM Object Path of the CIM_Service class 
to the CIM Object Manager. We want to get instances of this class. */ 
 
CIMObjectPath op = new CIMObjectPath("CIM_Service"); 
 
/* The CIM Object Manager returns a vector of object paths, the names 
of instances of the CIM_Service class. */
 
Vector v = cc.enumInstances(op, true); 
 
/* Iterate through the vector of instance object paths.
Use the CIM Client getInstance interface to get 
the instances referred to by each object name. */
 
for (int i=0; i < v.size(); i++) {
		
			// Get the instance
		
			CIMInstance ci = cc.getInstance(v.elementAt(i));
 
 		//Invoke the Stop Service method to stop the CIM services.
 
		c.invokeMethod(v.element(i), "StopService", null, null);
	
}
 
}