The installation compiles the standard CIM MOF files into the default namespaces, /root/cimv2 and /root/security. If you create a new namespace, you must compile the appropriate CIM MOF files into the new namespace before creating objects in it. For example, if you plan to create classes that use the standard CIM elements, compile the CIM Core Schema into the namespace. If you plan to create classes that extend the CIM Application Schema, compile the CIM Application into the namespace.
The code segment in Example 6-14 uses a two-step process to create a namespace within an existing namespace.
First, it uses the CIMNameSpace method to construct a namespace object. This namespace object contains the parameters to be passed to the CIM Object Manager when the namespace is actually created.
Second, the example uses the CIMClient class to connect to the CIM Object Manager and pass it the namespace object. The CIM Object Manager creates the namespace, using the parameters contained in the namespace object.
{ /*Creates a namespace object on the client, which stores the parameters passed to it. args[0] contains the host name (for example, myhost); args[1] contains the namespace (for example, the toplevel directory.) */ CIMNameSpace cns = new CIMNameSpace (args[0], args[1]); /* Connects to the CIM Object Manager and passes it the namespace object (cns) containing the namespace parameters. */ CIMClient cc = new CIMClient (cns); /* Passes to the CIM Object Manager another namespace object that contains a null string (host name) and args[2], the name of a name space (for example, secondlevel). */ CIMNameSpace cop = new CIMNameSpace("", args[2]); /* Creates a new namespace called secondlevel under the toplevel namespace on myhost./* cc.createNameSpace(cop); } |