ページの先頭行へ戻る
Interstage Application Server アプリケーション作成ガイド(CORBAサービス編)
Interstage

9.1 ネーミングサービスの概要

ネーミングサービスは、オブジェクトリファレンスをバインディング名と呼ばれる論理的な名前と関連付けて管理するサービスです。クライアントアプリケーションは、サーバアプリケーションのオブジェクトリファレンスの内容をプログラム中に抱える必要がなく、論理的な名前を使って最新のサーバアプリケーションのオブジェクトリファレンスを獲得することが可能となります。



ネーミングサービスは、以下の3種類のオブジェクトリファレンスを管理しています。

ネーミングサービスの例を以下に示します。



ネーミングサービスは、以下のインタフェースを提供しています。

module CosNaming {
   typedef string    Istring; 
   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, CannotProceed, InvalidName, 
                             AlreadyBound ); 

       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 ); 

   };
};

ネーミングサービスで提供しているインタフェースの機能説明を以下に示します。

インタフェース名

メソッド名

機能説明

NamingContext

bind

オブジェクトリファレンスを、指定されたバインディング名でネーミングサービスに登録します。この関連付けをバインディングと呼びます。

rebind

オブジェクトリファレンスを、指定されたバインディング名でネーミングサービスに登録します。
すでに同じ名前のバインディングが存在する場合は、古いバインディングは削除され、新しいバインディングが登録されます。

bind_context

ネーミングコンテキストのオブジェクトリファレンスを、指定されたバインディング名でネーミングサービスに登録します。

rebind_context

ネーミングコンテキストのオブジェクトリファレンスを、指定されたバインディング名でネーミングサービスに登録します。
すでに同じ名前のバインディングが存在する場合は、古いバインディングは削除され、新しいバインディングが登録されます。

resolve

指定されたバインディング名に関係付けられたオブジェクトリファレンスを獲得します。
バインディング名として構造体型のバインディング名を指定します。

unbind

指定されたバインディング名のバインディングをネーミングサービスから削除します。

new_context

新しいネーミングコンテキストを作成します。作成されたネーミングコンテキストのオブジェクトリファレンスはどのネーミングコンテキストにも登録されていません。

bind_new_context

新規にネーミングコンテキストを作成し、このネーミングコンテキストのオブジェクトリファレンスを指定されたバインディング名でネーミングサービスに登録します。(new_context+bind_contextと同様)

destroy

ネーミングコンテキストを削除します。

list

ネーミングコンテキストに登録されているバインディングの一覧を獲得します。

BindingIterator

next_one

ネーミングコンテキスト内の次のバインディングを獲得します。

next_n

ネーミングコンテキスト内の次のn個のバインディングを獲得します。

destroy

BindingIteratorオブジェクトを破壊します。

NamingContextExt

to_string

構造体型のバインディング名を文字列表記のバインディング名に変換します。

to_name

文字列表記のバインディング名から構造体型のバインディング名に変換します。

to_url

与えられたアドレスと、文字列表記のバインディング名からURLアドレスを作成します。

resolve_str

指定されたバインディング名に関係付けられたオブジェクトリファレンスを獲得します。
バインディング名として文字列表記のバインディング名が指定されます。