SDSU CS 696 Emerging Technologies: Distributed Objects
Spring Semester, 1998
Naming Service

To Lecture Notes Index
© 1998, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 21-Apr-98

Contents of Doc 26, Naming Service

  1. References
  2. Design Principles
  3. IDL Definition of Naming Service
    1. NameComponent
    2. Name
    3. Naming Context
    4. Name Space
    5. Naming Service, OrbixWeb, IOR's

References


CORBAservices, chapter 3, Naming Service Specification, March 1995

OrbixWeb Programmer's Guide, IONA Technologies PLC, November 1997, chapter 8 Making Objects Available in OrbixWeb pp. 180-202



Doc 26, Naming Service Slide # 2

Design Principles


Name Service does not give the names any semantic or interpretation

Names are structures of strings

Naming service clients need not be aware of the physical site of name servers or which server contains which part of a compound name

No security is provided by the naming service

Naming contexts can be combined into arbitrary structures


Doc 26, Naming Service Slide # 3

IDL Definition of Naming Service

module CosNaming
{
   typedef string Istring; 
      // Istring is a name holder for possible future international 
      // string type

   struct NameComponent {
      Istring id;
      Istring kind;
   };

   typedef sequence <NameComponent> Name;

   enum BindingType {nobject, ncontext};

   struct Binding {
      Name    binding_name;
      BindingType  binding_type;
   };

   typedef sequence <Binding> BindingList;

   interface BindingIterator;

   interface NamingContext {

      enum NotFoundReason { missing_node, not_context, 
                              not_object};

      exception NotFound {
            NotFoundReason why;
            Name rest_of_name;
      };

      exception CannotProceed {
            NamingContext cxt;
            Name rest_of_name;
      };

      exception InvalidName{};
      exception AlreadyBound {};
      exception NotEmpty{};

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

      void rebind(in Name n, in Object obj)
         raises(NotFound, CannotProceed, InvalidName);

      void bind_context(in Name n, in NamingContext nc) 
         raises(NotFound, CannotProceed, InvalidName, 
            AlreadyBound);

      void rebind_context(in Name n, in NamingContext nc)
         raises(NotFound, CannotProceed, InvalidName);

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

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

      NamingContext new_context();

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

      void destroy( ) raises(NotEmpty);

      void list (in unsigned long how_many, out BindingList bl, 
                  out BindingIterator bi);
   };

   interface BindingIterator {
      boolean next_one(out Binding b);
      boolean next_n(in unsigned long how_many, out BindingList bl);
      void destroy();
   };
};


Doc 26, Naming Service Slide # 4

NameComponent

   struct NameComponent {
      Istring id;
      Istring kind;
   };

A name in the naming service has two parts: id and kind

id
The name part of the name

kind
The type of thing

CORBA Naming Service does not provide any meaning to id or kind

That is your application can use them however you want
Sample Usage: file names

id = name of the file

kind = suffix of the file, .o, .java, .bin, .c, etc.



Doc 26, Naming Service Slide # 5

Name

   typedef sequence <NameComponent> Name;

A name is sequence of Naming components

This allows hierarchical names
Example

The file:

   /ma/home/whitney/CosNaming.idl

could be represented by:
NamingComponent[] name_module = 
   new NamingComponent[4];

name_module[0] = new NamingComponent("ma", "dir");
name_module[1] = new NamingComponent("home", "dir");
name_module[2] = new NamingComponent("whitney", "dir");
name_module[3] = new NamingComponent("CosNaming", "idl");


Doc 26, Naming Service Slide # 6

Naming Context


A NamingContext can contain other NamingContexts and objects

Each item in a NamingContext has an associated name

The name is bound to the item via Binding struct

Analogies

File structure
NamingContext is like a directory
Objects are like files


Tree
NamingContext is like an internal node of tree in that it can point (contain) to other internal nodes and leaves
Object is like a leaf
Note NamingContext structure is not limited to being a tree it can be an arbitrary graph


Doc 26, Naming Service Slide # 7

Name Space


All valid names recognized by the Naming Service is called a name space

A name space can span multiple machines and servers

A client can:
connect to the NamingService,
give it a name,
receive the object associated with that name
and not know which machine or server actually holds the object


Doc 26, Naming Service Slide # 8


Naming context's are combined together to form a naming network in the naming space
   enum BindingType {nobject, ncontext};

   struct Binding {
      Name    binding_name;
      BindingType  binding_type;
   };

A name can be bound to:
a Naming context (ncontext) to be part of the structure of the Name Space
an object (nobject) to be something we want to access in the Name Space


Doc 26, Naming Service Slide # 9
Operations to Create Contexts andName Space Structure
void bind_context(in Name n, in NamingContext nc) 
   raises(NotFound, CannotProceed, InvalidName, AlreadyBound);


Make parameter nc a subcontext of the receiver,
The parameter nc is bound to the name n

All but the final naming component of parameter n must be bound to naming contexts which are part of the Name Space structure

An exception is thrown if the last name component is already bound

The last name component is the context name
void rebind_context(in Name n, in NamingContext nc)
   raises(NotFound, CannotProceed, InvalidName);

Same as bind_context, but nc is an existing and bound naming context
NamingContext new_context();

Return a new context which is not bound to a name or part of a naming context, hence is not in the name space structure


Doc 26, Naming Service Slide # 10
 NamingContext bind_new_context(in Name n)
   raises(NotFound, AlreadyBound, CannotProceed, InvalidName);

Create a new naming context that is a bound subcontext of the receiver

The new context is also bound to the given name
Binding Names to Objects

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

Binds the object to the given name

If the name n only has one component, that is the name the object is bound to, and the name-object binding is added to the receiving naming context

If the name n has more than one component, all but the last component are used to find the naming context to which to add the name-object binding
void rebind(in Name n, in Object obj)
   raises(NotFound, CannotProceed, InvalidName);

Same as bind, but rebinds the name to a different object


Doc 26, Naming Service Slide # 11
Resolving Names
Object resolve (in Name n)
   raises(NotFound, CannotProceed, InvalidName);

Returns the object bound to the given name, relative to the target naming context

Note: returns a type org.omg.CORBA.Object

Use <type>Helper.narrow( ) to cast the object to its actual type

Do not use the normal Java cast operator to cast the object to its actual type
Deleting
void unbind(in Name n)
   raises(NotFound, CannotProceed, InvalidName);

Removes the binding between the specified name and the object it is resolved to
void destroy( ) raises(NotEmpty);

Deletes the naming context on which it is invoked

The naming context can not contain any bindings


Doc 26, Naming Service Slide # 12
Listing names

struct Binding {
   Name    binding_name;
   BindingType  binding_type;
   };

typedef sequence <Binding> BindingList;
interface BindingIterator {
   boolean next_one(out Binding b);
   boolean next_n(in unsigned long how_many, out BindingList bl);
   void destroy(); //destorys the BindingIterator
   };
void list (in unsigned long how_many, 
            out BindingList bl, 
            out BindingIterator bi);

how_many specifies the maximum number of bindings that should be returned in the BindingList parameter

If there are more than this, than the remainder are returned in the BindingIterator

If the naming context does not contain any additional bindings, the parameter bi will be a nil object reference

Note: bl and bi are out parameters, so in Java they will be passed in holder objects

next_one and next_n return true if they returned any bindings, other wise they return false

Doc 26, Naming Service Slide # 13

Naming Service, OrbixWeb, IOR's


The naming service stores bound objects as IOR, a string version of the object

The IOR is different for the different protocols: IIOP and Orbix native

In IIOP the port number of the server is part of the IOR for an object

If the server changes ports the IOR is no longer valid

So either make sure that the server always uses the same port or never goes down

I have not been successful in getting a server to use the same port on restart


visitors since 31-Mar-98