WBEMfor Solaris on Sun Developer's Guide

Creating an Instance

Use the newInstance method to create an instance of an existing class. If the existing class has a key property, an application must set it to a value that is guaranteed to be unique. As an option, an instance can define additional qualifiers that are not defined for the class. These qualifiers can be defined for the instance or for a particular property of the instance and do not need to appear in the class declaration.

Applications can use the getQualifiers method to get the set of qualifiers defined for a class.

Example -- Creating an Instance

The code segment in Example 6-4 uses the newInstance method to create a Java class representing a CIM instance (for example, a Solaris package) from the Solaris_Package class.


Example 6-4 Creating an Instance (newInstance())

 
/*Connect to the CIM Object Manager in the root\cimv2 namespace 
on the local host. */
CIMClient cc = new CIMClient();
 
// Get the Solaris_Package class
cimclass = cc.getClass(newCIMObjectPath("Solaris_Package");
 
/* Create a new instance of the Solaris_Package class,
 populated with the default values for properties. If the provider
 for the class does not specify default values, the values of the 
 properties will be null and must be explicitly set. */
 ci = cimclass.newInstance();