Solaris WBEM Developer's Guide

Creating a Name Space

The Solaris OS installation compiles the standard CIM Managed Object Format (MOF) files into the default name space. If you create a new name space, you must compile the appropriate CIM .mof files into the new name space before you create objects in that name space. For example, if you plan to create classes that use the standard CIM elements, compile the CIM Core schema into the name space. If you plan to create classes that extend the CIM Application schema, compile the CIM Application into the name space.


Example 4–17 Creating a Name Space

This example uses a two-step process to create a name space within an existing name space:

  1. When the name space is created, the CIMNameSpace method constructs a name space object that contains the parameters to be passed to the CIM Object Manager.

  2. The CIMClient class connects to the CIM Object Manager and passes the name space object. The CIM Object Manager creates the name space, using the parameters contained in the name space object.

{
    ...
    /* Creates a name space object on the client, which stores parameters 
    passed to it from the command line. args[0] contains the host 
    name (for example, myhost); args[1] contains the 
    parent name space (for example, the toplevel directory.) */
     
    CIMNameSpace cns = new CIMNameSpace (args[0], args[1]); 

    UserPrincipal up = new UserPrincipal("root");
    PasswordCredential pc = new PasswordCredential("root_password"); 
     
    /* Connects to the CIM Object Manager and passes it three parameters:
    the name space object (cns), which contains the host name (args[0]) and
    parent name space name (args[1]), a user name string (args[3]), and a
    password string (args[4]). */
     
    CIMClient cc = new CIMClient (cns, up, pc);
     
    /* Passes to the CIM Object Manager another name space object that 
    contains a null string (host name) and args[2], the name of a 
    child name space (for example, secondlevel). */
     
    CIMNameSpace cop = new CIMNameSpace("", args[2]);
    
    /* Creates a new name space by the name passed in as args[2] under the
    toplevel name space on myhost./*
     
    cc.createNameSpace(cop);
    ...
}