_bind()
is called with a null host name, OrbixWeb will use the locator to find the target object in the distributed system. This chapter describes the default locator supplied with OrbixWeb and explains how to replace it with a user-defined locator implementation.
lookUp()
, which contacts the local OrbixWeb daemon and requests a list of host names for the specified server name.
_bind()
call also fails and throws an OrbixWeb system exception. The location attempt succeeds when it locates a host at which the server name passed to _bind()
has been registered, but this does not guarantee that the _bind()
itself will succeed. The method _bind()
demands satisfaction of additional criteria, such as successful launching of the server and location of the specified object within the server.For successful operation of the default locator, it is necessary to specify server names and corresponding target hosts in advance. The configuration of the default locator must be carried out with respect to the local OrbixWeb daemon process, which manipulates the locator configuration files. This configuration and some additional details of the default locator functionality are described in Chapter 3, "OrbixWeb Configuration" of the OrbixWeb Reference Guide.
The lookUp() method
The lookUp()
method is a crucial part of the implementation of the OrbixWeb default location mechanism. It is this method which is responsible for nominating a list of candidate host names at which the server should be sought. The signature of lookUp()
(as defined in class IE.Iona.Orbix2.CORBA.locatorClass
) is:
// Java public _sequence_String lookUp(String ServiceName, int MaxHops, Context ctx);The parameters to this method will be described in full later in this chapter.
Unlike the location mechanism in some versions of Orbix, the OrbixWeb default locator does not make use of a publicly accessible default locator object in order to call the method
lookUp()
. Consequently, an OrbixWeb client cannot call the default locator lookUp()
method directly. However, it is possible to implement this functionality and this is discussed in the next subsection.Note that the object
_CORBA.locator
(defined in package IE.Iona.Orbix2
) is only used to allow programmers to override the default lookUp()
implementation and is assigned to null
unless explicitly replaced, as described in section 24.2.
Default lookUp() functionality
Although programmers will not normally have to make explicit use of the lookUp()
method (since it is used implicitly through calls to _bind()
), it may on occasion be useful to do so. A direct call to the lookUp()
method invoked by the OrbixWeb default locator is not possible, but this functionality can be easily imitated.lookUp()
implementation uses the IT_daemon
IDL interface, which is implemented by the OrbixWeb daemon. In order to mimic the behaviour of lookUp()
, it is simply necessary to bind to the local OrbixWeb daemon process and invoke the IT_daemon
::lookUp()
operation. The IDL signature of this operation is:
// IDL boolean lookUp (in string service, out stringSeq hostList, in octet hops, in string tag);The operation invocation can be coded as follows:
// Java // in file Client.java // in class Client IE.Iona.Orbix2.IT_daemonRef dRef; String service; String tag = null; byte hops; _sequence_String hostList = null; // initialise server name service = "MyServer"; // initialise number of locator hops hops = 5; try { // bind to Orbix daemon dRef = IE.Iona.Orbix2.IT_daemon._bind (); // invoke lookUp() operation dRef.lookUp (service, hostList, hops, tag); } catch (SystemException se) { ... } if (hostList.length > 0) { int i; for (i=0; i<hostList.length; i++) System.out.println (hostList.buffer[i]); } else { // server not found in configuration file ... }Each string in the sequence of strings returned by operation
lookUp()
gives the name of a host on which the specified server may be registered. The lookUp()
operation returns an empty sequence if no host names can be found for the specified server. If the call succeeds, then the program can choose any of the returned host names,1 or perhaps iterate over them attempting to bind to the required object at each in turn (receiving an exception on one of the binds indicates an error such as the host not being available).
The
hops
parameter to lookUp()
specifies the maximum number of hops which can be used to fulfil a request, thereby limiting the number of hosts involved in a search. The _bind()
method uses the value _CORBA._LOCATOR_HOPS
(which can be changed by a programmer who wishes to modify how _bind()
uses lookUp()
). Explicit calls to lookUp()
can specify any byte
value, except that the constant value _CORBA._MAX_LOCATOR_HOPS
is used if a greater value is specified.tag
parameter is simply a string used in daemon diagnostic messages and can generally be assigned the value null
.24.2 Writing a New Locator
If the search facility provided by the OrbixWeb default locator is not appropriate, or if it needs to be augmented for a given application, then an alternative locator can be installed by:
locatorClass
.
_CORBA.locator
to point to that instance.
_CORBA.locator
is null
, which indicates that the default locator algorithm should be used where appropriate.The locator
lookUp()
method is passed the name of the server being sought and it should return a list of names of hosts on which that server is registered in the Implementation Repository.Class
locatorClass
is defined as follows:
// Java package IE.Iona.Orbix2.CORBA; public class locatorClass { public _sequence_String lookUp( String ServiceName, int MaxHops, Context ctx); }The parameters of
lookUp()
are as follows:It is often advisable that a locator randomises the sequence before returning it.