Sun WBEM SDK Developer's Guide

Example — Creating a Namespace

The code segment in Example 4–20 uses a two-step process to create a namespace within an existing namespace.


Example 4–20 Creating a Namespace (CIMNameSpace)

{
    ...
    /* Creates a namespace 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 namespace (for example, the toplevel directory.) */
     
    CIMNameSpace cns = new CIMNameSpace (args[0], args[1]); 
     
    /* Connects to the CIM Object Manager and passes it three parameters:
    the namespace object (cns), which contains the host name (args[0]) and
    parent namespace name (args[1]), a user name string (args[3]), and a
    password string (args[4]). */
     
    CIMClient cc = new CIMClient (cns, "root", "secret");	
     
    /* Passes to the CIM Object Manager another namespace object that 
    contains a null string (host name) and args[2], the name of a 
    child namespace (for example, secondlevel). */
     
    CIMNameSpace cop = new CIMNameSpace("", args[2]);
    
    /* Creates a new namespace called secondlevel under the
    toplevel namespace on myhost./*
     
    cc.createNameSpace(cop);
    ...
}