Java Reference
In-Depth Information
and can be read but not set by a client. Regular attributes may be set by a client
using the mutator method.
Constants defined within a module but outside an interface in the IDL file
map into a public Java interface (with the same name as the constant) in the
package corresponding to the module in which the constant is defined. Thus our
COR19
-
CONSTANT
,which is in the
cor19
module, maps to a Java interface (in a
file named
COR19
-
CONSTANT.java
)inthe
javatech.cor19
package, while
the
SERVER
-
CONSTANT
, being in the
server
module, maps to a Java interface
in the
javatech.cor19.server
package. These Java interfaces define no
methods, just constant values in a field named
value
.Sothe constant can be
accessed like this:
String a
-
fun
-
chapter = javatech.cor19.COR19
-
CONSTANT.value;
or, using imports,
import javatech.cor19.*;
...
String a
-
fun
-
chapter
=
COR19
-
CONSTANT.value;
Constants defined inside an IDL interface map to public static final fields in the
Java interface that corresponds to the IDL interface.
There are more features to IDL that we do not go into here since our aim is only
to introduce CORBA rather than give an exhaustive tutorial. Some features that
might be of interest include the
oneway
keyword, which defines a non-blocking
method, the
typedef
keyword,
enum
and
union
objects, and the
Any
type.
19.3 Compiling the IDL file
The IDL-to-Java compiler provided with the Java 2 SDK is known as
idlj
.
There exist CORBA implementations for Java other than the free built-in imple-
mentation. Some of these may provide better performance or adherence to newer
versions of the CORBA standard than the built-in CORBA support. Each imple-
mentation must provide its own IDL compiler, and the name and usage of the
compiler is likely to be different from the name and usage of
idlj
.However,
most implementations should produce essentially similar output files, with per-
haps slight naming differences. We deal only with the free Java 2 SDK CORBA
implementation.
When the above IDL file, with its nested module statements, is compiled,
it generates the support classes in the
javatech.cor19.server
package.
The IDL file itself may be kept almost anywhere. We use a directory structure
similar to that used in the RMI example in Chapter 18 with an
src
directory
containing all the implementation files in a package-named directory structure
and a
build/classes
directory containing the compiled class files. With this
structure, it is convenient to keep the IDL file in the
src
directory. The IDL
Search WWH ::
Custom Search