Naming Service


Naming Service

The first version of CosNaming service for VBOrb was written by Craig Neuwirt. He figured out how the old tnameserv of Sun's JDK ORB works. So it is possible now to use any Naming Service of any ORB even the tnameserv. It is also possible to use the Naming Service of VBOrb (NameServ.exe) instead of the tnameserv for your Java applications. For real life applications I recommend using a better Naming Service than NameServ or tnameserv.

Query a Naming Service

The easiest way to query a Naming Service for object references is to use a corbaname URL and the stringToObject function of the ORB. You don't need to compile the CosNaming IDL then. Just use the build in function of VBOrb.

Using a Naming Service

You can compile following CosNaming IDL with IDL2VB to use all functions of a Naming Service server or to implement your own Naming Service.
 /*
    CORBA Naming Service
 */
 
 #if !defined(COSNAMING_IDL)
 #define COSNAMING_IDL
 
 #pragma prefix "omg.org"
 
 module CosNaming
 {
     typedef string Istring;
 
     struct NameComponent
     {    Istring id;
         Istring kind;
     };
 
     typedef sequence Name;
 
     enum BindingType
     {    nobject, ncontext
     };
 
     struct Binding
     {    Name binding_name;    // One NameComponent
         BindingType binding_type;
     };
     // Note: in struct Binding, binding_name is incorrectly defined as
     // a Name instead of a NameComponent. This definition is unchanged
     // for compatibility reasons.
     
     typedef sequence 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();
     };
 
     interface NamingContextExt: NamingContext
     {
         typedef string StringName;
         typedef string Address;
         typedef string URLString;
 
         StringName to_string(in Name n)
             raises(InvalidName);
 
         Name to_name(in StringName sn)
             raises(InvalidName);
 
         exception InvalidAddress
         {
         };
 
         URLString to_url(in Address addr, in StringName sn)
             raises(InvalidAddress, InvalidName);
 
         Object resolve_str(in StringName sn)
             raises(NotFound, CannotProceed, InvalidName);
     };
 };
 
 // Map long IDL names to short Visual Basic names
 //
 #pragma vbname CosNaming Nm
 #pragma vbname CosNaming::NamingContext NmContext
 #pragma vbname CosNaming::NamingContext::NotFound NmNotFoundEx
 #pragma vbname CosNaming::NamingContext::CannotProceed NmCannotProceedEx
 #pragma vbname CosNaming::NamingContext::InvalidName NmInvalidNameEx
 #pragma vbname CosNaming::NamingContext::AlreadyBound NmAlreadyBoundEx
 #pragma vbname CosNaming::NamingContext::NotEmpty NmNotEmptyEx
 #pragma vbname CosNaming::NamingContextExt NmContextExt
 #pragma vbname CosNaming::NamingContextExt::InvalidAddress NmInvalidAddressEx
 
 #endif // COSNAMING_IDL