As I mentioned before, IDL is used only to declare modules, interfaces, and their methods. Interfaces declared in IDL are mapped into classes or interfaces in Java. A semicolon is also required after the close of an interface definition. Java programmers should note the semicolons following the closing braces on the module definitions, which are required in IDL but not in Java. If you want to reference the NeatExample interface in other IDL files, use the syntax jen::corba::NeatExample, which may look familiar to readers who have done C++ programming. Suppose that you want all your classes to be contained in a module called corba, which is part of a larger module called jen (an acronym for the title of this book). Everything defined within the scope of this module (interfaces, constants, other modules) falls within the module and is referenced in other IDL modules using the syntax modulename ::x. Modules are declared in IDL using the module keyword, followed by a name for the module and an opening brace that starts the module scope. In Java, you can define a class only within a single package in a single Java file. Modules, which are similar to Java packages, can be nested within other modules in the same IDL file, and interfaces in multiple distinct modules can be defined in the same IDL file. Java allows multiple inner classes within a single public class definition and multiple nonpublic classes per file, but only a single public class can be defined in a given Java file. In Java, all primitive data types are passed by value, and all object data types are passed by reference.Īn IDL file can include multiple public interfaces. Method parameters in IDL include modifiers that specify whether they are input, output, or input/output variables. IDL, like C++, includes non-class data structure definitions, like structs, unions, and enumerations.
Method implementations are created in the implementation language you choose (in this case Java), after you've used an IDL compiler to convert your IDL interface to your target language. In IDL, you declare only the names and types for interfaces, data members, methods, method parameters, etc. The major differences between IDL and Java are: Interfaces in IDL are declared much like classes in C++ and, thus, classes or interfaces in Java. The syntax of both Java and IDL were modeled to some extent on C++, so there are a lot of similarities between the two in terms of syntax.
A full reference on IDL syntax is provided in Chapter 10, "IDL Reference", if you need more details. This section provides a quick overview of writing a CORBA interface in IDL. Writing a server-side implementation of the Java interface in Java
Generating a Java base interface, plus a Java stub and skeleton class, using an IDL-to-Java compiler Writing an interface in the CORBA Interface Definition Language In order to distribute a Java object over the network usingĬORBA, you have to define your own CORBA-enabled interface and it Let's walk through the creation of CORBA objects using Java Now that you understand the various parts of the CORBA architecture,