Interoperability

This examples illustrates how to connect to a remote object without using proprietary extensions.  It has a simple AccountManager interface to open an Account and to query the balance in that account. The server publishes its IOR into the root context of the Naming Server, which is then retrieved by the client.  From this example, you will learn how:

Building this example

Typing make  will cause the Bank.idl to be run through the idl2java compiler. It will also build the following classes for the examples described above:

Running the examples

First, make sure the osagent executable is not running on your system, or to use a different port number in the following examples (change the OSAGENT_PORT environment variable to 0). The examples show you how to connect to objects by using only standard mechanisms.

Starting the NameService

In the following examples we use the properties:
vbroker.agent.enableLocator=false This property tells the ORB to skip looking for an osagent, thus improving startup time when no osagent is listening on the given port.
vbroker.se.default=iiop_tp We set the threading model to ThreadPool.
vbroker.se.iiop_tp.scm.iiop_tp.listener.port=9999 We want the ThreadPool server engine to listen on port 9999.

The Naming Service needs to be activated first. It can be done with the following command:

    prompt> nameserv -VBJprop ORBpropStorage=ns.properties >ns.ior &

This will startup the NameService with the default backing store InMemory and the default name "NameService". The IOR will be captured in the file ns.ior for later use.

Alternatively, you can start any other NameService, e.g. the tnameserv executable that comes with JDK 1.2. Please note that you can use corbaploc and corbaname scheme only with a NameService that fully implements the INS specification (orbos/98-10-11 or newer)!
You would start the jdk 1.2 NameService as follows. It will print out its IOR, which you will have to copy in a file named ns.ior

    prompt> tnameserv -ORBInitialPort 9999 &
 

Starting the Server

Then start the bank server using the command:

Starting a client

The server started so far behave from the client point of view like CORBA objects implemented on top of other vendor's ORB, in particular, we cannot use the XXXHelper.bind() call to locate an object. Instead, we will use resolve_initial_references in conjunction with -DORBInitRef to point the client to the NameService, which contains all other objects.

The first example will specify the location of the NameService by passing in an IOR.

The second example will specify the location of the NameService by pointing to the host and port number, on which the NameService is listening. Please note that the object key "NameService" has to be used regardless of which name we give the NameService instance on the commandline. The third example will specify the location of the NameService by pointing to the host and port number, on which the NameService is listening and a stringified name with which the object is registered. Since the server registered on the root context, this name is only the slash. All previous protocols (IOR, corbaloc, corbaname) are mandatory, according to the INS specification. VisiBroker also implements the optional protocols "file://", "http:", and "ftp:", to obtain an IOR. Their use is presented in the following three examples.

The first example will specify the location of the NameService by pointing to a file containing an IOR.

The second example will specify the location of the NameService by pointing to a file on a webserver containing an IOR. You will have to copy the ns.ior file to a webserver to try this example. The third example will specify the location of the NameService by pointing to a file on a ftp server containing an IOR.  You will have to copy the ns.ior file to the ftp server to try this example.