Java Reference
In-Depth Information
environment to handle). To specify that a method may cause an exception to be
generated, the keyword
raises
is used. For example:
void myMethod(in dummy) raises (MyException);
(Note that brackets are required around the exception type.)
Obviously,
raises
maps to
throws
in Java.
One fi nal IDL keyword worth mentioning is
typedef
. This allows us to create
new types from existing ones. For example:
typedef sequence<long> IntSeq;
This creates a new type called IntSeq, which is equivalent to a sequence/array of
integers. This new type can then be used in data property declarations. For example:
attribute IntSeq numSeq;
N.B. If a structured type (array, sequence, etc.) is required as a data attribute or
parameter, then we cannot declare it directly as a structured type, but must use
typedef
to create the new type and then use that new type. Thus, a declaration such as
attribute sequence<long> numSeq;
would be rejected.
6.3
The
Java IDL
Process
At the heart of
Java IDL
is a compiler that translates the programmer's IDL into
Java constructs, according to the IDL-to-Java mapping. Prior to J2SE 1.3, this com-
piler was called
idltojava
and was available as a separate download. As of J2SE 1.3,
the compiler is called
idlj
and is part of the core Java download. The stub and skel-
eton fi les (and a number of other fi les) are generated by the
idlj
compiler for each
object type that is specifi ed in the
.idl
fi le. Once these fi les have been generated, the
Java implementation fi les may be written, compiled and linked with the
idlj -
generated
fi les and the ORB library to create an object server, after which client
program(s) may be written to access the service provided.
Although the preceding two sentences summarise the basic procedure, there are
several steps required to set up a CORBA client/server application. These steps are
listed below.
1. Use the
idlj
compiler to compile the above fi le, generating up to six fi les for each
interface defi ned.
2. Implement each interface as a 'servant'.
3. Create the server (incorporating servants).
4. Compile the server and the
idlj
-generated fi les.
5. Create a client.
6. Compile the client.
7. Run the application.
Search WWH ::
Custom Search