Java Reference
In-Depth Information
Simple Example
This fi rst example application simply displays a greeting to any client that uses the
appropriate interface registered with the Java IDL ORB to invoke the associated
method implementation on the server. The steps will be numbered as above…
1. Create the IDL fi le.
The fi le will be called Hello.idl and will hold a module called Simple-
CORBAExample . This module will contain a single interface called Hello that
holds the signature for operation getGreeting . The contents of this fi le are shown
below.
module SimpleCORBAExample
{
interface Hello
{
string getGreeting();
};
};
2. Compile the IDL fi le.
The idlj compiler defaults to generating only the client-side bindings. To vary
this default behaviour, the -f option may be used. This is followed by one of
three possible specifi ers: client , server and all . If client and server are to be run
on the same machine, then all is appropriate and the following command line
should be entered:
idlj -fall Hello.idl
This causes a sub-directory with the same name as the module (i.e., Simple-
CORBAExample ) to be created, holding the six fi les listed below.
￿ Hello.java
Contains the Java version of our IDL interface. It extends interface
HelloOperations [See below], as well as org .omg.CORBA.Object (providing
standard CORBA object functionality) and org.omg.CORBA.portable.IDLEntity .
￿
HelloHelper.java
Provides auxiliary functionality, notably the narrow method required to cast
CORBA object references into Hello references.
￿
HelloHolder.java
Holds a public instance member of type Hello . If there were any out or inout
arguments (which CORBA allows, but which do not map easily onto Java), this
fi le would also provide operations for them.
￿
HelloOperations.java
Contains the Java method signatures for all operations in our IDL fi le. In this
application, it contains the single method getGreeting .
Search WWH ::




Custom Search