Java Reference
In-Depth Information
Notice the use of a semicolon terminating every method definition, similar to a
Java interface file, but also after every closing brace, unlike Java. Leaving out
the terminating semicolon generates an error from the IDL compiler and is a
common mistake. The IDL compiler honors // as well as / ... / comments.
The compiler provided with Java 2 SDK even retains javadoc-style comments
and forwards them to the generated Java source code where appropriate.
When this IDL file is processed by the IDL-to-Java compiler, several support
files are generated in packages named to match the module names. These sup-
port files are definitely important, but their contents are rarely of interest. These
files simply provide most of the underlying plumbing needed to implement the
CORBA programming paradigm. Because the files themselves are normally of
little use, and to avoid cluttering up our implementation directories, it is conve-
nient to instruct the IDL compiler to direct the generated files into some directory
tree other than our source tree.
Because CORBA is language and platform independent, it must support lan-
guages and platforms that are not case sensitive. Therefore, the IDL file is not
case-sensitive. One must be careful to avoid names that differ only in case; else
name conflicts will occur. For case-sensitive languages such as Java, the IDL com-
piler is permitted to retain case-sensitive names in the support files that it creates.
Then the implementer can retain case-sensitive names for convenience in the
implementation files. Even so, the requirement to maintain identifier uniqueness
without regard to case must still be met.
In the IDL file above, we created an interface named Cor19Example . That
interface includes two methods that are similar to the methods defined in the
RMI interface from Chapter 18. (In CORBA terminology, the “methods” are
actually referred to as “operations,” which is a relatively language-neutral term.
However, Java programmers will almost always think of them as methods instead
of operations.) We also included one new operation, demo() , that we describe
shortly.
The IDL file also defines a data structure (CORBA keyword struct ) called
CustomData . Structures have no direct analog in Java since everything in Java is
either a primitive or an object, and all objects inherit from java.lang.Object
and thus have behavior (methods) associated with them. Structures in CORBA
are pure data containers with no behavior. Like structures in other languages, they
are used to group together related values. If one is to pass structured data between
CORBA clients and servers, those data structures must be defined somewhere,
and where they are defined is in the IDL file using the struct keyword as shown.
A feature of IDL that may be unfamiliar is that each of the method parameters
must be identified as an input only, output only, or input/output parameter. The
keyword in identifies input-only parameters. They are forced to be read-only
parameters in the implementation files. No changes to their values are commu-
nicated back to the calling program, no matter what the server-side code does
with them. Output only parameters are identified with the keyword out , and
Search WWH ::




Custom Search