The method invokeMethod is the only way that a client program can call the methods of Solaris WBEM providers. This condition is true for both providers that are built in or that are added by developers.
Built–in – The “platform-free” CIM_* providers or the Solaris_* providers specific to the Solaris platform.
Added by developers – For example, a method provider, whether the provider supplies provider or non-WBEM methods, is created by implementing the MethodProvider interface.
The following sample code creates the Solaris_ComputerSystem provider class that routes requests from the CIMOM to one or more specialized providers. These providers handle requests for dynamic data for a particular type of managed object. For example, the Solaris_Package provider handles requests to execute methods in the Solaris_Package class.
The method provider implements a single method, invokeMethod. This method calls the appropriate provider to either reboot a system, shut down a system, or delete a serial port.
...
public class Solaris_ComputerSystem implements MethodProvider {
ProviderCIMOMHandle pch = null;
public void initialize(CIMOMHandle ch) throws CIMException {
pch = (ProviderCIMOMHandle)ch;
}
public void cleanup() throws CIMException {
}
public CIMValue invokeMethod(CIMObjectPath op, String methodName,
Vector inParams, Vector outParams) throws CIMException {
if (op.getObjectName().equalsIgnoreCase("solaris_computersystem")) {
if (methodName.equalsIgnoreCase("reboot")) {
// call helper function, not shown here
return new CIMValue(rebootSystem());
}
if (methodName.equalsIgnoreCase("shutdown")) {
// call helper function, not shown here
return new CIMValue(shutdownSystem());
}
}
if (op.getObjectName().equalsIgnoreCase("solaris_serialport")) {
if (methodName.equalsIgnoreCase("disableportservice")) {
// call helper function, not shown here
return new CIMValue(deletePort(op));
}
}
// error if we get here
throw new CIMException(CIMException.CIM_ERR_NOT_SUPPORTED,
"The requested function does not exist");
}
// helper functions would be defined below
...
}