idlj(1) idlj(1)
NAME
idlj - IDL-to-Java compiler
SYNOPSIS
idlj [ options ] idl-file
DESCRIPTION
The IDL-to-Java Compiler generates the Java bindings for a given IDL
file. For binding details, see the OMG IDL to Java Language Mapping
Specification
In the synopsis, idl-file is the name of a file containing Interface
Definition Language (IDL) definitions. The options may appear in any
order, but must precede the idl-file.
EMITING CLIENT AND SERVER BINDINGS
To generate Java bindings for an IDL file named y.idl:
example% idlj y.idl
This generates the client-side bindings and is equivalent to:
example% idlj -fclient y.idl
The client-side bindings do not include the server-side skeleton. If
you want to generate the server-side bindings for the interfaces:
example% idlj -fserver y.idl
Server-side bindings include the client-side bindings plus the skele-
ton, all of which are POA (that is, Inheritance Model) classes. If you
want to generate both client and server-side bindings, use one of the
following (equivalent) commands:
example% idlj -fclient -fserver y.idl
example% idlj -fall y.idl
There are two possible server-side models: the Inheritance Model and
the Tie Model.
Inheritance Model
A new feature in 1.4: The default server-side model is the Portable
Servant Inheritance odel. Given an interface y defined in y.idl, the
file yPOA.java is generated. You must provide the implementation for
y and it must inherit from yPOA.
yPOA.java is a stream-based skeleton that extends org.omg.Portable-
Server.Servant and implements the InvokeHandler interface and the oper-
ations interface associated with the IDL interface that the skeleton
implements.
The PortableServer module for the Portable Object Adapter (POA) defines
the native Servant type. In the Java programming language, the Servant
type is mapped to the Java org.omg.PortableServer.Servant class. It
serves as the base class for all POA servant implementations and pro-
vides a number of methods that may be invoked by the application pro-
grammer, as well as methods which are invoked by the POA itself and may
be overridden by the user to control aspects of servant behavior.
Another option for the Inheritance Model is to use the -oldImplBase
flag in order to generate server-side bindings that are compatible with
older version of the Java programming language (prior to J2SE 1.4). To
generate server-side bindings that are backwards compatible:
example% idlj -fclient -fserver -oldImplBase y.idl
example% idlj -fall -oldImplBase y.idl
Given an interface y defined in y.idl, the file yImplBase.java is
generated. You must provide the implementation for y and it must
inherit from yImplBase.
Tie Model
The other server-side model is called the Tie Model. This is a delega-
tion model. Because it is not possible to generate ties and skeletons
at the same time, they must be generated separately. The following com-
mands generate the bindings for the Tie Model:
example% idlj -fall y.idl
example% idlj -fallTIE y.idl
For the interface y, the second command generates yPOATie.java. The
constructor to yPOATie takes a delegate. You must provide the imple-
mentation for delegate, but it does not have to inherit from any other
class, only the interface yOperations. But to use it with the ORB, you
must wrap your implementation within yPOATie. For instance:
MyImpl myImpl = new MyImpl ();
MyPOATie tie = new MyPOATie (myImpl);
orb.connect (tie);
You might want to use the Tie Model instead of the typical Inheritance
Model if your implementation must inherit from some other implementa-
tion. Java allows any number of interface inheritance, but there is
only one slot for class inheritance. If you use the Inheritance Model,
that slot is used up. By using the Tie Model, that slot is freed up for
your own use. The drawback is that it introduces a level of indirec-
tion, that is, one extra method call occurs when invoking a method.
To generate server-side, Tie Model bindings that are compatible with
older version of the IDL--to-Java language mapping in versions of J2SE
before 1.4:
example% idlj -oldImplBase -fall y.idl
example% idlj -oldImplBase -fallTIE y.idl
For the interface y, this will generate yTie.java. The constructor
to yTie takes an impl. You must provide the implementation for impl,
but it does not have to inherit from any other class, only the inter-
face HelloOperations. But to use it with the ORB, you must wrap your
implementation within yTie. For instance:
MyImpl myImpl = new MyImpl ();
MyPOATie tie = new MyPOATie (myImpl);
orb.connect (tie);
SPECIFYING ALTERNATE LOCATIONS FOR EMITED FILES
If you want to direct the emitted files to a directory other than the
current directory, invoke the compiler as:
example% idlj -td /altdir y.idl
For the interface y, the bindings will be emitted to /altdir/y.java,
and so forth, instead of ./y.java.
SPECIFYING ALTERNATE LOCATIONS FOR INCLUDE FILES
If y.idl included another idl file, yOther.idl, the compiler assumes
that yOther.idl resides in the local directory. If it resides in
/includes, for example, then you would invoke the compiler with the
following command:
example% idlj -i /includes y.idl
If y.idl also included Another.idl that resided in /moreIncludes, for
example, then you would invoke the compiler with the following command:
example% idlj -i /includes -i /moreIncludes y.idl
Since this form of include can become irritatingly long, another means
of indicating to the compiler where to search for included files is
provided. This technique is similar to the idea of an environment vari-
able. Create a file named idl.config in a directory that is listed in
your CLASPATH. Inside of idl.config, provide a line with the following
form:
includes=/includes:/moreIncludes
The compiler will find this file and read in the includes list. Notice
that in this example the separator character between the two directo-
ries is a colon (:). This separator character is platform dependent. On
NT it is a semicolon, on Mac OS X it is a colon, and so forth. For more
information on includes, read the CLASPATH (Solaris), CLASPATH
(Linux), CLASPATH (Windows) documentation.
EMITING BINDINGS FOR INCLUDE FILES
By default, only those interfaces, structs, and so on, that are defined
in the idl file on the command line have Java bindings generated for
them. The types defined in included files are not generated. For exam-
ple, assume the following two idl files:
My.idl
#include
interface My
{
};
MyOther.idl
interface MyOther
{
};
The following command will only generate the java bindings for y:
example% idlj y.idl
To generate all of the types in y.idl and all of the types in the
files that y.idl includes (in this example, yOther.idl), use the fol-
lowing command:
example% idlj -emitAll y.idl
There is a caveat to the default rule. ##include statements which appear
at global scope are treated as described. These ##include statements can
be thought of as import statements. ##include statements which appear
within some enclosing scope are treated as true ##include statements.
This means that the code within the included file is treated as if it
appeared in the original file and, therefore, Java bindings are emitted
for it. Here is an example:
My.idl
#include
interface My
{
#include
};
MyOther.idl
interface MyOther
{
};
Embedded.idl
enum E {one, two, three};
Running the following command:
example% idlj y.idl
will generate the following list of Java files:
./MyHolder.java
./MyHelper.java
./MyStub.java
./MyPackage
./MyPackage/EHolder.java
./MyPackage/EHelper.java
./MyPackage/E.java
./My.java
Notice that yOther.java was not generated because it is defined in an
import-like ##include. But E.java was generated because it was defined
in a true ##include. Also notice that since Embedded.idl was included
within the scope of the interface y, it appears within the scope of y
(that is, in yPackage).
If the -emitAll flag had been used in the previous example, then all
types in all included files would be emitted.
INSERTING PACKAGE PREFIXES
Suppose that you work for a company named ABC that has constructed the
following IDL file:
Widgets.idl
module Widgets
{
interface W1 {...};
interface W2 {...};
};
Running this file through the IDL-to-Java compiler will place the Java
bindings for W1 and W2 within the package Widgets. But there is an
industry convention that states that a company's packages should reside
within a package named com.company name. The Widgets package is not
good enough. To follow convention, it should be com.abc.Widgets. To
place this package prefix onto the Widgets module, execute the follow-
ing:
example% idlj -pkgPrefix Widgets com.abc Widgets.idl
If you have an IDL file which includes Widgets.idl the -pkgPrefix flag
must appear in that command also. If it does not, then your IDL file
will be looking for a Widgets package rather than a com.abc.Widgets
package. If you have a number of these packages that require prefixes,
it might be easier to place them into the idl.config file described
above. Each package prefix line should be of the form:
PkgPrefix.=
So the line for the above example would be:
PkgPrefix.Widgets=com.abc
The use of this option does not affect the Repository ID.
DEFINING SYMBOLS BEFORE COMPILATION
You may need to define a symbol for compilation that is not defined
within the IDL file, perhaps to include debugging code in the bindings.
The command:
example% idlj -d MYDEF y.idl
is the equivalent of putting the line ##define MYDEF inside y.idl.
PRESERVING PRE-EXISTING BINDINGS
If the Java binding files already exist, the -keep flag will keep the
compiler from overwriting them. The default is to generate all files
without considering if they already exist. If you've customized those
files (which you should not do unless you are very comfortable with
their contents), then the -keep option is very useful. The command:
example% idlj -keep y.idl
emits all client-side bindings that do not already exist.
VIEWING PROGRES OF COMPILATION
The IDL-to-Java compiler will generate status messages as it progresses
through its phases of execution. Use the -v option to activate this
"verbose" mode:
example% idlj -v y.idl
By default, the compiler does not operate in verbose mode.
DISPLAYING VERSION INFORMATION
To display the build version of the IDL-to-Java compiler, specify the
-version option on the command line:
example% idlj -version
OPTIONS
The following options are supported:
-d symbol
This is equivalent to the following line in an IDL file:
#define symbol
-emitAll
Emits all types, including those found in ##include files.
-fside Defines what bindings to emit. side is one of client, server,
serverTIE, all, or allTIE. The -fserverTIE and -fallTIE options
cause delegate model skeletons to be emitted. Assumes -fclient
if the flag is not specified.
-i include-path
By default, the current directory is scanned for included files.
This option adds another directory.
-keep If a file to be generated already exists, does not overwrite it.
By default it is overwritten.
-noWarn
Suppresses warning messages.
-oldImplBase
Generates skeletons compatible with old (pre-1.4) JDK ORBs. By
default, the POA Inheritance Model server-side bindings are gen-
erated. This option provides backward-compatibility with older
versions of the Java programming language by generating
server-side bindings that are ImplBase Inheritance Model
classes.
-pkgPrefix type prefix
Wherever type is encountered at file scope, prefixes the gener-
ated Java package name with prefix for all files generated for
that type. The type is the simple name of either a top-level
module, or an IDL type defined outside of any module.
-pkgTranslate type package
Whenever the module name type is encountered in an identifier,
this option replaces it in the identifier with package for all
files in the generated Java package. Notice that -pkgPrefix
changes are made first. type is the simple name of either a
top-level module, or an IDL type defined outside of any module,
and must match the full package name exactly.
If more than one translation matches an identifier, the longest
match is chosen. For example, if the arguments include:
example% -pkgTranslate foo bar -pkgTranslate foo.baz buzz.fizz
The following translations would occur:
foo => bar
foo.boo => bar.boo
foo.baz => buzz.fizz
foo.baz.bar => buzz.fizz.bar
The following package names cannot be translated:
]o org
]o org.omg or any subpackages of org.omg
Any attempt to translate these packages will result in uncompil-
able code, and the use of these packages as the first argument
after -pkgTranslate will be treated as an error.
-skeletonName xxx%yyy
Uses xxx%yyy as the pattern for naming the skeleton. The
defaults are:
]o %%POA for the POA base class (-fserver or -fall).
]o %%ImplBase for the oldImplBase class (-oldImplBase and either
-fserver or -fall).
-td dir
Uses dir for the output directory instead of the current direc-
tory.
-tieName xxx%yyy
Uses xxx%yyy as the pattern for naming the tie. The defaults
are:
]o %%POATie for the POA tie base class (-fserver or -fallTie).
]o %%Tie for the oldImplBase class (-oldImplBase and either
-fserverTie or -fallTie).
-nowarn, -verbose
Verbose mode.
-version
Displays version information and terminates.
ENVIRONMENT VARIABLES
CLASPATH
Used to provide the system with a path to user-defined classes.
Directories are separated by colons. For example:
.::/Users/vlh/classes::/Users/Shared/classes
RESTRICTIONS
]o Escaped identifiers in the global scope may not have the same
spelling as IDL primitive types, Object or ValueBase. This is because
the symbol table is pre-loaded with these identifiers. Allowing them
to be redefined would overwrite their original definitions. (Possible
permanent restriction).
]o The fixed IDL type is not supported.
SEE ALSO
OMG IDL to Java Language Mapping Specification
BUGS
No import is generated for global identifiers. If you invoke on an
unexported local impl, you do get an exception, but it seems to be due
to a Null Ptr Exception in the ServerDelegate DSI code.
23 Apr 2001 idlj(1)
|