The MethodProvider method takes the following arguments:
op - Object path to the instance whose method must be invoked.
originClass - Name of the class in which this method was originally defined in the class hierarchy. CIM properties are attributes of a CIM class that are inherited from a parent class. A CIM property is uniquely identified within a namespace by its name and origin class. For example, two properties named speed can be distinguished by their respective origin classes DiskDrive and CPU.
inParams - Vector of CIMValues that are the input parameters for the method.
CIMValue - Return value of the method. If the method has no return value, it must return null. A CIM value stores the CIM data type and value of a CIM property. CIM data types (defined in the CIM Specification) are limited to intrinsic data types. The following table provides the WBEM data type name for each CIM data type.
Table 7-4 Sun WBEM SDK and CIM Data Type Names
CIM Data Type |
WBEM Data Type |
Description |
---|---|---|
uint8 |
UnsignedInt8 |
Unsigned 8-bit integer |
sint8 |
Byte |
Signed 8-bit integer |
uint16 |
UnsignedInt16 |
Unsigned 16-bit integer |
sint16 |
Short |
Signed 16-bit integer |
uint32 |
UnsignedInt32 |
Unsigned 32-bit integer |
sint32 |
Integer |
Signed 32-bit integer |
uint64 |
UnsignedInt64 |
Unsigned 64-bit integer |
sint64 |
Long |
Signed 64-bit integer |
string |
String |
UCS-2 string |
boolean |
Boolean |
Boolean |
real32 |
Float |
IEEE 4-byte floating point |
real64 |
Double |
IEEE 8-byte floating point |
datetime |
CIMDateTime |
String containing a date-time |
classname ref |
CIMObjectPath |
Strongly typed reference |
char16 |
Character |
16-bit UCS-2 character |
The following table describes the method in the Method Provider interface.
Table 7-5 MethodProvider Interface Methods
Method |
Description |
---|---|
invokeMethod |
The CIM Object Manager calls this method when the specified method is invoked. |
The code segment in Example 7-4 creates a Solaris provider class that routes requests to execute methods from the CIM Object Manager to one or more specialized providers. These specialized providers service requests for dynamic data for a particular type of Solaris object. For example, the Solaris_Package provider services requests to execute methods in the Solaris_Package class.
The method provider in this example implements a single method invokeMethod that calls the appropriate provider to perform one of following operations:
Reboot a Solaris system
Reboot or shut down a Solaris system
Delete a Solaris serial port
public class Solaris implements MethodProvider { public void initialize(CIMONHandle, ch) throws CIMException { } public void cleanup() throws CIMException { } public CIMValue invokeMethod(CIMObjectPath op, String methodName, Vector inParams, Vector outParams) throws CIMException { if (op.getObjectName().equalsIgnoreCase("solaris_computersystem")) { Solaris_ComputerSystem sp = new Solaris_ComputerSystem(); if (methodName.equalsIgnoreCase("reboot")) { return new CIMValue (sp.Reboot()); } } if (op.getObjectName().equalsIgnoreCase("solaris_operatingsystem")) { Solaris_OperatingSystem sos = new Solaris_OperatingSystem(); if (methodName.equalsIgnoreCase("reboot")) { return new CIMValue (sos.Reboot()); } if (methodName.equalsIgnoreCase("shutdown")) { return new CIMValue (sos.Shutdown()); } } if (op.getObjectName().equalsIgnoreCase("solaris_serialport")) { Solaris_SerialPort ser = new Solaris_SerialPort(); if (methodName.equalsIgnoreCase("disableportservice")) { return new CIMValue (ser.DeletePort(op)); } } return null; } } |