OrbixNames Programmer's and Administrator's Guide

Chapter 1

Introduction to the CORBA Naming Service

OrbixNames is IONA Technologies' implementation of the CORBA Naming Service, a service that allows you to associate abstract names with CORBA objects in your applications. This chapter describes the features of the CORBA Naming Service.

The Naming Service is a standard service for CORBA applications, defined in the Object Management Group's (OMG) CORBAservices specification. The Naming Service allows you to associate abstract names with CORBA objects and allows clients to find those objects by looking up the corresponding names. This service is both very simple and very useful.

A server that holds a CORBA object binds a name to the object by contacting the Naming Service. To obtain a reference to the object, a client requests the Naming Service to look up the object associated with a specified name. This is known as resolving the object name. The Naming Service provides interfaces defined in IDL that allow servers to bind names to objects and clients to resolve those names.

Most CORBA applications make some use of the Naming Service. Locating a particular object is a common requirement in distributed systems and the Naming Service provides a simple, standard way to do this.

The Interface to the Naming Service

The Naming Service maintains a database of names and the objects associated with them. An association between a name and an object is called a binding. The IDL interfaces to the Naming Service provide operations to access the database of bindings. For example, you can create new bindings, resolve names, and delete existing bindings.

OrbixNames is implemented as a normal Orbix server. This server contains objects which support the standard IDL interfaces to the Naming Service. These interfaces are defined in the IDL module CosNaming:

// IDL
module CosNaming {
  // Naming Service IDL definitions.

Part V of this guide on page 147 provides a full reference for the definitions in this module. The remainder of this chapter provides a brief overview of the most commonly used definitions.

Format of Names in the Naming Service

In the CORBA Naming Service, names can be associated with two types of object: a naming context or an application object. A naming context is an object in the Naming Service within which you can resolve the names of other objects.

Naming contexts are organized into a naming graph, which may form a naming hierarchy much like that of a filing system. Using this analogy, a name bound to a naming context would correspond to a directory and a name bound to an application object would correspond to a file.

The full name of an object, including all the associated naming contexts, is known as a compound name. The first component of a compound name gives the name of a naming context, in which the second component is accessed. This process continues until the last component of the compound name has been reached.

The notion of a compound name is common in filing systems. For example, in UNIX, compound names take the form /aaa/bbb/ccc; in Windows they take the form C:\aaa\bbb\ccc. A compound name in the Naming Service takes a more abstract form: an IDL sequence of name components.

Name components are not simple strings. Instead, a name component is defined as an IDL structure, of type CosNaming::NameComponent, that holds two strings:

// IDL
// In module CosNaming.
typedef string Istring;

struct NameComponent {
  Istring id;
  Istring kind;

A name is a sequence of these structures:

typedef sequence<NameComponent> Name;

The id member of a NameComponent is a simple identifier for the object; the kind member is a secondary way to differentiate objects and is intended to be used by the application layer. For example, you could use the kind member to distinguish the type of the object being referred to. The semantics you choose for this member are not interpreted by OrbixNames.

Both the id and kind members of a NameComponent are used in name resolution. Two names that differ only in the kind member of one NameComponent are considered to be different names.

IDL Interfaces to the Naming Service

The IDL module CosNaming contains two interfaces that allow your applications to access the Naming Service:
NamingContext Provides the operations that allow you to access the main features of the Naming Service, such as binding and resolving names.
BindingIterator Allows you to read each element in a list of bindings. Such a list may be returned by operations of the NamingContext interface.

The remainder of this chapter describes how you use the NamingContext interface to do simple Naming Service operations, such as binding names to your application objects and resolving those names in your clients.

Using the Naming Service

The first step in using the Naming Service is to get a reference to the root naming context. The root naming context is an object, of type CosNaming::NamingContext, which acts as an entry point to all the bindings in the Naming Service.

This section describes some of the operations you can call on the root naming context, or other naming contexts created by you, to do basic Naming Service tasks.

Associating a Name with an Object

The operation CosNaming::NamingContext::bind() allows you to bind a name to an object in your application. This operation is defined as:

void bind (in Name n, in Object o)
  raises (NotFound, CannotProceed,
          InvalidName, AlreadyBound);

To use this operation, you first create a CosNaming::Name structure containing the name you want to bind to your object. You then pass this structure and the corresponding object reference as parameters to bind().

Using Names to Find Objects

Given an abstract name for an object, you can retrieve a reference to the object by calling CosNaming::NamingContext::resolve(). This operation is defined as:

Object resolve (in Name n)
  raises (NotFound, CannotProceed, InvalidName);

When you call resolve(), the Naming Service retrieves the object reference associated with the specified CosNaming::Name value and returns it to your application.

Associating a Compound Name with an Object

Figure 1.1 shows an example of a simple compound name.

Figure 1.1: Example of a Compound Name

In this figure, a name with identifier company (and no kind value) is bound to a naming context in the Naming Service. This naming context contains one binding: between the name staff and another naming context. The staff naming context contains a binding between the name james and an application object.

If you want to associate a compound name with an object, you must first create the naming contexts that will allow you to build the compound name. For example, to create the compound name shown in Figure 1.1:

  1. Get a reference to the root naming context.
  2. Use the root naming context to create a new naming context and bind the name company to it. To do this, call the operation CosNaming::NamingContext::bind_new_context(), passing the name company as a parameter. This operation returns a reference to the newly created naming context.
  3. Call CosNaming::NamingContext::bind_new_context() on the company naming context object, passing the name staff as a parameter. This returns a reference to the new staff naming context.
  4. Call CosNaming::NamingContext::bind() on the staff naming context, to bind the name james to your application object.

The operation CosNaming::NamingContext::bind_new_context() is defined as:

NamingContext bind_new_context (in Name n)
  raises (NotFound, CannotProceed,
          InvalidName, AlreadyBound);

To create a new naming context and bind a name to it, create a CosNaming::Name structure for the context name and pass it to bind_new_context(). If the call is successful, the operation returns a reference to your newly created naming context.

Removing Bindings from the Naming Service

If you want to remove the association between a name and an object in the Naming Service, call the operation CosNaming::NamingContext::unbind(). This operation is defined as:

void unbind (in Name n)
  raises (NotFound, CannotProceed, InvalidName);

This operation takes a single parameter that indicates the name to be removed from the Naming Service.

The name passed as a parameter to unbind() may be associated with a naming context or an application object. If you unbind the name of a context and your applications have no further use for that context, you should delete the corresponding naming context object. To do this, call CosNaming::NamingContext::destroy() on a reference to the naming context. This operation is defined as:

void destroy ()
  raises (NotEmpty);

Before calling destroy() on a naming context object, remove any bindings contained in the context.

Convention for String Format of Names

To make it easier to describe examples, this guide uses a string representation of Naming Service names. This convention is specific to OrbixNames and is illustrated by the following example1:


In this example, the ID value of the first name component is documents and the kind value is dir. The next component has ID reports and kind dir, followed by a component with ID april97 and kind txt. This string format is used throughout the rest of this guide and is understood by the OrbixNames utilities described in Chapter 6 on page 115.

Note:   If the dash `-' character is omitted from a name component, the kind field is a zero length string. The forward slash character `/' may be used to escape the characters `-' (dash), `.' (period), and `/' (forward slash).

1 The Object Management Group (OMG) is expected to introduce a standard string format for Naming Service names. This standard will be adopted in a future release of OrbixNames.
Copyright © 2000, IONA Technologies PLC.