CORBA defines an elaborate and powerful naming service, which you can use to make it easy for clients to find objects. The CORBA name service has much more function than the RMI naming registry. For example, in CORBA, you can organize your names into "contexts", which are similar in concept to directories on a file system. The trade-off is that the CORBA name service methods are more cumbersome than we saw with the RMI registry.

The code shown here first accesses the naming service itself by calling resolve_initial_references. This method returns a reference to the so-called "root context", which is similar to the root directory on a hard disk. We then call a special method named "narrow" to cast the returned reference to the correct type. This notion of narrowing is a CORBA programming idiom - it works much like a Java cast. For any given interface, the "narrow" method is defined on the "helper" class generated by the IDL compiler.

Once we have a correctly typed reference to the root context, we can then assign a name to the MeetingServant object that we showed creating on the last page. To do this, we need to define an array that contains the full name of the object, starting at the root. Since we will assign this name directly in the root context, the array contains a single NameComponent element. I think you can see that this is much more involved than the simple RMI registry!

Once we have built the name into the array, we can call the "rebind" method on the root naming context, passing the naming array and the MeetingServant object reference. Rebind stores the name and object reference in the name service, silently overwriting it if the name already exists.