Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
Chapter 4, Writing a Provider Program Implementing the Provider Interfaces Writing a Native Provider   Previous   Contents   Next 
   
 

Creating a Provider

Follow these steps to create a provider.

  1. Create or edit your provider program.

  2. Compile the Java program to create the class files.

  3. Copy any shared object files (.so) to /usr/sadm/lib/wbem.

  4. Set your CLASSPATH to the location of your .class and .jar files.

  5. Register the provider.

    How to Set the Provider CLASSPATH

    You set the provider CLASSPATH to tell the CIM Object Manager where the .class and .jar files are located.

  1. Create an instance of the Solaris_ProviderPath class.

    For example:

    /* Create a namespace object initialized with root\system  
    (name of namespace) on the local host. */
    CIMNameSpace cns = new CIMNameSpace("", "root\system"); 
    
    // Connect to the root\system namespace as root. 
    cc = new CIMClient(cns, "root", "root_password");
    
    // Get the Solaris_ProviderPath class 
    cimclass = cc.getClass(new CIMObjectPath("Solaris_ProviderPath");
    
    // Create a new instance of Solaris_ProviderPath. 
    class ci = cimclass.newInstance();

  2. Set the pathurl property to the location of the files using standard URL format.

    For example:

    /* Set the provider CLASSPATH to /myhome/myproviders */
    ci.setProperty("pathurl", new CIMValue(new String
                              ("file:///myhome/myproviders/"))); 

    Standard URL format is shown in the following table:
    Provider CLASSPATH

    Standard URL Format

    Absolute path to directory

    file:///a/b/c/

    Absolute path to .jar file

    file:///a/b/my.jar

  3. Create the instance.

    For example:

    // Pass the updated instance to the CIM Object Manager 
    cc.createInstance(new CIMObjectPath(), ci);  

    How to Register a Provider

    You register a new or modified provider with the CIM Object Manager to communicate information about the data and operations the provider supports, and to notify the CIM Object Manager of the provider's location. The CIM Object Manager uses this information to load and initialize the provider, and to determine the appropriate provider for a particular client request.

  1. Create a Managed Object Format (MOF) file that defines the classes that the provider supports.


    Note - For more information on creating MOF files, see the DMTF Website at http://www.dmtf.org.


  2. Include the provider qualifier in the MOF file to specify the provider type and location for the CIM Object Manager.

    For example:
    [Provider("java:com.sun.providers.myprovider")]
    Class_name {
    ...
    };

    This qualifier indicates the following:

    • java: - The provider is written in the Java language and implements the javax.wbem.provider interfaces.

    • com.sun.providers.myprovider - The name of the Java class that implements the provider.

  3. Compile the MOF file by using themofcomp(1M) command.


Example 4-4 Registering a Provider

This MOF file declares the Ex_SimpleCIMInstanceProvider class that is served by SimpleCIMInstanceProvider.

// ========================================================
// Title:       SimpleCIMInstanceProvider
// Filename:    SimpleCIMInstanceProvider.mof
// Description:
// ==================================================================

// ==================================================================
// Pragmas
// ==================================================================
#pragma Locale ("en-US")

// ==================================================================
//   SimpleCIMInstanceProvider
// ==================================================================
[Provider("java:SimpleCIMInstanceProvider")]
class Ex_SimpleCIMInstanceProvider
{
   // Properties
      [Key, Description("First Name of the User")]
   string First;
      [Description("Last Name of the User")]
   string Last;
};


 
 
 
  Previous   Contents   Next