Use the invokeMethod method to call a method in a class supported by a provider. To retrieve the signature of a method, an application must first get the definition of the class to which the method belongs. The invokeMethod interface takes four arguments:
|
Data Type |
Description |
|---|---|
|
CIMObjectPath |
The name of the instance on which the method must be invoked. |
|
String |
The name of the method to call. |
|
Vector |
Input parameters to pass to the method. |
|
Vector |
Output parameters to get from the method. |
The invokeMethod method returns a CIMValue. The return value is null when the method you invoke does not define a return value.
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.
{
/* 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);
}
}
|