Previous Up Next

Chapter 6  Interoperable Naming Service

omniORB supports the Interoperable Naming Service (INS). The following is a summary of its facilities.

6.1  Object URIs

As well as accepting IOR-format strings, ORB::string_to_object() also supports two Uniform Resource Identifier (URI) [BLFIM98] formats, which can be used to specify objects in a convenient human-readable form. IOR-format strings are now also considered URIs.

6.1.1  corbaloc

corbaloc URIs allow you to specify object references which can be contacted by IIOP, or found through ORB::resolve_initial_references(). To specify an IIOP object reference, you use a URI of the form:
corbaloc:iiop:<host>:<port>/<object key>
for example:
corbaloc:iiop:myhost.example.com:1234/MyObjectKey
which specifies an object with key `MyObjectKey' within a process running on myhost.example.com listening on port 1234. Object keys containing non-ASCII characters can use the standard URI % escapes:
corbaloc:iiop:myhost.example.com:1234/My%efObjectKey
denotes an object key with the value 239 (hex ef) in the third octet.

The protocol name `iiop' can be abbreviated to the empty string, so the original URI can be written:
corbaloc::myhost.example.com:1234/MyObjectKey
The IANA has assigned port number 28091 for use by corbaloc, so if the server is listening on that port, you can leave the port number out. The following two URIs refer to the same object:
corbaloc::myhost.example.com:2809/MyObjectKey
corbaloc::myhost.example.com/MyObjectKey
You can specify an object which is available at more than one location by separating the locations with commas:
corbaloc::myhost.example.com,:localhost:1234/MyObjectKey
Note that you must restate the protocol for each address, hence the `:' before `localhost'. It could equally have been written `iiop:localhost'.

You can also specify an IIOP version number:
corbaloc::1.2@myhost.example.com/MyObjectKey
Specifying IIOP versions above 1.0 is slightly risky since higher versions make use of various information stored in IORs that is not present in a corbaloc URI. It is generally best to contact initial corbaloc objects with IIOP 1.0, and rely on higher versions for all other object references.

Alternatively, to use resolve_initial_references(), you use a URI of the form:
corbaloc:rir:/NameService

6.1.2  corbaname

corbaname URIs cause string_to_object() to look-up a name in a CORBA Naming service. They are an extension of the corbaloc syntax:
corbaname:<corbaloc location>/<object key>#<stringified name>
for example:
corbaname::myhost/NameService#project/example/echo.obj
corbaname:rir:/NameService#project/example/echo.obj
The object found with the corbaloc-style portion must be of type CosNaming::NamingContext, or something derived from it. If the object key (or rir name) is `NameService', it can be left out:
corbaname::myhost#project/example/echo.obj
corbaname:rir:#project/example/echo.obj
The stringified name portion can also be left out, in which case the URI denotes the CosNaming::NamingContext which would have been used for a look-up:
corbaname::myhost.example.com
corbaname:rir:
The first of these examples is the easiest way of specifying the location of a naming service.

6.2  Configuring resolve_initial_references

The INS specifies two standard command line arguments which provide a portable way of configuring ORB::resolve_initial_references():

6.2.1  ORBInitRef

-ORBInitRef takes an argument of the form <ObjectId>=<ObjectURI>. So, for example, with command line arguments of:
-ORBInitRef NameService=corbaname::myhost.example.com
resolve_initial_references("NameService") will return a reference to the object with key `NameService' available on myhost.example.com, port 2809. Since IOR-format strings are considered URIs, you can also say things like:
-ORBInitRef NameService=IOR:00ff...

6.2.2  ORBDefaultInitRef

-ORBDefaultInitRef provides a prefix string which is used to resolve otherwise unknown names. When resolve_initial_references() is unable to resolve a name which has been specifically configured (with -ORBInitRef), it constructs a string consisting of the default prefix, a `/' character, and the name requested. The string is then fed to string_to_object(). So, for example, with a command line of:
-ORBDefaultInitRef corbaloc::myhost.example.com
a call to resolve_initial_references("MyService") will return the object reference denoted by `corbaloc::myhost.example.com/MyService'.

Similarly, a corbaname prefix can be used to cause look-ups in the naming service. Note, however, that since a `/' character is always added to the prefix, it is impossible to specify a look-up in the root context of the naming service—you have to use a sub-context, like:
-ORBDefaultInitRef corbaname::myhost.example.com#services

6.3  omniNames

6.3.1  NamingContextExt

omniNames supports the extended CosNaming::NamingContextExt interface:

module CosNaming { 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 n) raises(NotFound, CannotProceed, InvalidName, AlreadyBound); }; };


to_string() and to_name() convert from CosNaming::Name sequences to flattened strings and vice-versa. Note that calling these operations involves remote calls to the naming service, so they are not particularly efficient. You can use the omniORB specific local omniURI::nameToString() and omniURI::stringToName() functions instead.

A CosNaming::Name is stringified by separating name components with `/' characters. The kind and id fields of each component are separated by `.' characters. If the kind field is empty, the representation has no trailing `.'; if the id is empty, the representation starts with a `.' character; if both id and kind are empty, the representation is just a `.'. The backslash `\' is used to escape the meaning of `/', `.' and `\' itself.

to_url() takes a corbaloc style address and key string (but without the corbaloc: part), and a stringified name, and returns a corbaname URI (incorrectly called a URL) string, having properly escaped any invalid characters. The specification does not make it clear whether or not the address string should also be escaped by the operation; omniORB does not escape it. For this reason, it is best to avoid calling to_url() if the address part contains escapable characters. omniORB provides the equivalent local function omniURI::addrAndNameToURI().

resolve_str() is equivalent to calling to_name() followed by the inherited resolve() operation. There are no string-based equivalents of the various bind operations.

6.3.2  Use with corbaname

To make it easy to use omniNames with corbaname URIs, it starts with the default port of 2809, and an object key of `NameService' for the root naming context.

6.4  omniMapper

omniMapper is a simple daemon which listens on port 2809 (or any other port), and redirects IIOP requests for configured object keys to associated persistent object references. It can be used to make a naming service (even an old non-INS aware version of omniNames or other ORB's naming service) appear on port 2809 with the object key `NameService'. The same goes for any other service you may wish to specify, such as an interface repository. omniMapper is started with a command line of:
omniMapper [-port <port>] [-config <config file>] [-v]
The -port option allows you to choose a port other than 2809 to listen on. The -config option specifies a location for the configuration file. The default name is /etc/omniMapper.cfg, or C:\omniMapper.cfg on Windows. omniMapper does not normally print anything; the -v option makes it verbose so it prints configuration information and a record of the redirections it makes, to standard output.

The configuration file is very simple. Each line contains a string to be used as an object key, some white space, and an IOR (or any valid URI) that it will redirect that object key to. Comments should be prefixed with a `#' character. For example:
# Example omniMapper.cfg
NameService         IOR:000f...
InterfaceRepository IOR:0100...
omniMapper can either be run on a single machine, in much the same way as omniNames, or it can be run on every machine, with a common configuration file. That way, each machine's omniORB configuration file could contain the line:
ORBDefaultInitRef corbaloc::localhost

6.5  Creating objects with simple object keys

In normal use, omniORB creates object keys containing various information including POA names and various non-ASCII characters. Since object keys are supposed to be opaque, this is not usually a problem. The INS breaks this opacity and requires servers to create objects with human-friendly keys.

If you wish to make your objects available with human-friendly URIs, there are two options. The first is to use omniMapper as described above, in conjunction with a PERSISTENT POA. The second is to create objects with the required keys yourself. You do this with a special POA with the name `omniINSPOA', acquired from resolve_initial_references(). This POA has the USER_ID and PERSISTENT policies, and the special property that the object keys it creates contain only the object ids given to the POA, and no other data. It is a normal POA in all other respects, so you can activate/deactivate it, create children, and so on, in the usual way.

Children of the omniINSPOA do not inherit its special properties of creating simple object keys. If the omniINSPOA's policies are not suitable for your application, you cannot create a POA with different policies (such as single threading, for example), and still generate simple object keys. Instead, you can activate a servant in the omniINSPOA that uses location forwarding to redirect requests to objects in a different POA.


1
Not 2089 as printed in [OMG00]!

Previous Up Next