You use the invokeMethod interface 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 method returns a CIMValue. The return value is null when the method that you invoke does not define a return value.
The invokeMethod interface takes four arguments, as described in the following table.
Table 4–4 invokeMethod Parameters|
Parameter |
Data Type |
Description |
|---|---|---|
|
name |
CIMObjectPath |
The name of the instance on which the method must be invoked |
|
methodName |
String |
The name of the method to call |
|
inParams |
Vector |
Input parameters to pass to the method |
|
outParams |
Vector |
Output parameters to get from the method |
This example gets the instances of the CIM_Service class, which represent services that manage device or software features. The example 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 invoke a method defined in
this class. */
CIMObjectPath op = new CIMObjectPath("CIM_Service");
/* The CIM Object Manager returns an enumeration of instance
object paths, the names of instances of the CIM_Service
class. */
Enumeration e = cc.enumerateInstanceNames (op, true);
/* Iterate through the enumeration of instance object paths */
while(e.hasMoreElements()) {
// Get the instance
CIMObjectPath op = (CIMObjectPath) e.nextElement();
//Invoke the Stop Service method to stop the CIM services.
cc.invokeMethod("StopService", null, null);
}
}