Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com

The Java name server, tnameserv.exe, has to be up and running, beforehand. Arguments can be omitted, 900 is the default port.

CORBAServer.java contains two classes, CORBAServer and TheServant.

First, we'll look at CORBAServer's main method :

We need a mediator between objects, an Object Request Broker, so we have one made by org.omg.CORBA.ORB.init :

We then create an instance of the other class :

Connect it to the ORB :

At this moment the server's methods can be called, but we prefer that a client can find this server by its name.

To register the server's name, we ask the ORB for its Naming Service :

However, this results in a reference to an org.omg.CORBA.Object and that's not what we need.

We need a reference to an org.omg.CosNaming.NamingContext, so we ask the class NamingContextHelper to help us with it :

(Java casting is not an option)

We proceed by making an org.omg.CosNaming.NameComponent passing the name of the CORBAServant interface.

The rebind method requires an array, though :

And we register with the name server :

Then the server goes waiting for a client .

The CORBAServant interface has been generated, along with a couple of other classes,...

by the tool idlj .

This tool expects a general interface description in Interface Definition Language, IDL.

Looks familiar, doesn't it ?

in long plus means : input parameter by the name of plus, type long.

The client, CORBAClient, starts out largely the same as the server.

It makes an ORB, asks for its naming service, makes a NameComponent array, but then it asks NamingContext ncRef to find our server object :

This is however not the type we want, so we ask for help again . CORBAServantHelper is one of the generated classes.

Now we have a reference to the CORBAServant interface whose methods we can call :

IMPORTANT

=========

This example is all Java, but either the server-side or the client could have been developed using C++, COBOL etc.....

CORBA provides a standard to let different software modules call each other's methods.

Transfer of method name, arguments and return values is done by means of the Internet Inter ORB Protocol, IIOP.

======

NOTES

======

The serving class must extend the generated ..implbase.

======

Different port.

Remote host.

.