CORBAにおけるオブジェクト参照
ここでは、CORBAの仕様書 08-01-07.pdfの P.25, 7.6 An Information Model for Object Refercencesを基にCORBAにおけるオブジェクト参照について説明しておきます。
IORについて
IORは、Interoperable Object Referenceの略で、CORBAオブジェクトの参照のことです。通常、IOR は印字可能な文字列で表現され、接頭辞 IOR: の後に16進数の文字列が並んだものになっています。典型的な IOR には、リモートホストのインターネットアドレス、CORBAサーバが対応しているリモートポート番号、呼び出されるメソッドを持つリモートオブジェクトのクラスを定義する文字列、個々のオブジェクトを識別するキー(ビット列)から構成されています。
IORのデータ構造
IORのデータ構造は、下記のようになっています。
module IOP { // IDL
// Standard Protocol Profile tag values
typedef unsigned long ProfileId;
typedef CORBA::OctetSeq ProfileData;
struct TaggedProfile {
ProfileId tag;
ProfileData profile_data;
};
typedef sequence <TaggedProfile> TaggedProfileSeq ;
// an Interoperable Object Reference is a sequence of
// object-specific protocol profiles, plus a type ID.
struct IOR {
string type_id;
TaggedProfileSeq profiles;
};
// Standard way of representing multicomponent profiles.
// This would be encapsulated in a TaggedProfile.
typedef unsigned long ComponentId;
typedef CORBA::OctetSeq ComponentData;
struct TaggedComponent {
ComponentId tag;
ComponentData component_data;
};
typedef sequence<TaggedComponent> TaggedComponentSeq;
typedef sequence <TaggedComponent> MultipleComponentProfile;
typedef CORBA::OctetSeq ObjectKey;
};
RtORBでは、IORは、TaggedComponent は、サポートしておりません。(GIOP1.1のみの動作)また、IIOP以外は実装しないという方針で実装を行うましたので、ProfileIdもTAG_INTERNET_IOP = 0 の対応のみにとどめています。
文字列化されたIOR
CORBAでは、オブジェクトの参照を作成するときに、ORB::object_to_string関数を用いて、”文字列化されたIOR”を用います。また、その逆関数であるORB::string_to_object関数もあり、これらの関数を用いて、ORB内のオブジェクトを参照することが可能になっています。
”文字列化されたIOR”は、次のような表現になっています。
<oref> ::= <prefix> <hex_Octets>
<prefix> ::= <i><o><r>“:”
<hex_Octets> ::= <hex_Octet> {<hex_Octet>}*
<hex_Octet> ::= <hexDigit> <hexDigit>
<hexDigit> ::= <digit> | <a> | <b> | <c> | <d> | <e> | <f>
<digit> ::= “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”
<a> ::= “a” | “A”
<b> ::= “b” | “B”
<c> ::= “c” | “C”
<d> ::= “d” | “D”
<e> ::= “e” | “E”
<f> ::= “f” | “F”
<i> :: = “i” | “I”
<o> :: = “o” | “O”
<r> :: = “r” | “R”
このように、”文字列化されたIOR”とは、”IOR:”で始まる16進数であわらされる文字列 ということができます。16進で表される文字列は、IIOPであれば、IIOP IOP Profileをmarshalingしたoctet列を文字列化したものに他なりません。ちなみに、IIOP IOP Profileは、下記のようになっています。
module IIOP { // IDL extended for version 1.1, 1.2, and later
struct Version {
octet major;
octet minor;
};
struct ProfileBody_1_0 {// renamed from ProfileBody
Version iiop_version;
string host;
unsigned short port;
IOP::ObjectKey object_key;
};
struct ProfileBody_1_1 {// also used for 1.2 and later
Version iiop_version;
string host;
unsigned short port;
IOP::ObjectKey object_key;
// Added in 1.1 unchanged for 1.2 and later
IOP::TaggedComponentSeq components;
};
};
URLによるオブジェクト参照について
CORBAにおいてオブジェクトの参照は、通常、前述の”文字列化されたIOR”が使用される。しかし、この表現は、人間にとってすぐに理解できるような文字列ではない(慣れればそうではないが)ので、ORB::string_to_object関数では、URL表現を許可している実装もある。
RtORBでは、corbaloc:iiop URLとcorbaname URLをサポートしています。
URL表現では、実装によってfile://やftp://, http:// のスキーマも許可しているものもある。
corbaloc URL
corbaloc URLは、IIOPまたは、resolve_initial_referencesによって接続するオブジェクトを表したものである。その表現としては、下記のようになっている。
corbaloc::555xyz.com/Prod/TradingService corbaloc:iiop:1.1@555xyz.com/Prod/TradingService corbaloc::555xyz.com,:556xyz.com:80/Dev/NameService corbaloc:rir:/TradingService corbaloc:rir:/NameService corbaloc:iiop:192.168.14.25:555/NameService corbaloc::[1080::8:800:200C:417A]:88/DefaultEventChannel
corbaloc URLは、1つ以上のプロトコルIDとプロトコルの仕様(アドレスやプロトコルのバージョン情報等)を含んでいる。(しかし、RIRプロトコルの場合には、他のプロトコルは使えない)また、corbaloc URL は、1つのオブジェクトキーで終わっている。corbaloc URLのFull Syntaxは、次のようになっている。
<corbaloc> = “corbaloc:”<obj_addr_list>[“/”<key_string>] <obj_addr_list> = [<obj_addr> “,”]* <obj_addr> <obj_addr> = <prot_addr> | <future_prot_addr> <prot_addr> = <rir_prot_addr> | <iiop_prot_addr> <rir_prot_addr> = <rir_prot_token>”:” <rir_prot_token> = “rir” <iiop_prot_addr> = <iiop_id><iiop_addr> <iiop_id> = “:” | <iiop_prot_token>”:” <iiop_prot_token> = “iiop” <iiop_addr> = [<version> <host> [“:” <port>]] <host> = DNS_style_host_name | ip_address <host> = DNS_style_host_name | IPv4_address| "[" IPv6_address "]" <version> = <major> “.” <minor> “@” | empty_string <port> = number <major> = number <minor> = number <future_prot_addr> = <future_prot_id><future_prot_addr> <future_prot_id> = <future_prot_token>”:” <future_prot_token> = possible examples: “atm” | “dce” <future_prot_addr> = protocol specific address <key_string> = <string> | empty_string
RtORBでは、IIOPのみをサポートしています。そのため、Corbaloc URLは、必ず."corbaloc:iiop:"又は"corbaloc::"で始まらなければいけません。また、IPv6では動作しないので、当然、上記のIPv6に関わる記法はサポートしていません。
corbaloc:rir URL
この表記で書かれているオブジェクトりファンレンスは、resolve_initial_references関数で戻ってきたIORという意味になります。
例えば、
corbaloc:rir:/NamveService
というオブジェクトリファレンスは、
resolve_initi_references("NameSerivece")
の戻り値になることを表しています。
ただし、resolve_initial_reference関数は、その中身は、実装依存になっていますので、この表記自体は、あまり使われません。
そのため、RtORBでもこの表記のオブジェクトリファレンスは、サポートしないようにしています。
corbaloc:iiop URL
この表記は、IIOPのCORBAのオブジェクトリファレンスを表すものです。RtORBでも corbaloc URLは、この表記しかサポートしていません。
このURL表記のアドレス部の Full Syntaxは、
<iiop_prot_addr> = <iiop_id><iiop_addr> <iiop_id> = <iiop_default> | <iiop_prot_token>”:” <iiop_default> = “:” <iiop_prot_token> = “iiop” <iiop_addr> = [<version> <host> [“:” <port>]] <host> = DNS_style_host_name | IPv4_address| "[" IPv6_address "]" <version> = <major> “.” <minor> “@” | empty_string <port> = number <major> = number <minor> = number
となっています。
corbaname URL
このcorbaname URLは、corbaloc URLとほとんど同じなのですが、どのNamingServeiceに登録されたオブジェクトリファレンスかを表しています。
例えば、
corbaname::555objs.com#a/string/path/to/obj
の表記の場合には、555objs.comのホスト上で提供されているNameServiceの、a/string/path/to/obj で登録されているオブジェクトリファレンスを示しています。

