O'Reilly logo

Java Enterprise in a Nutshell, Third Edition by William Crawford, Jim Farley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Module Declarations

A module is a name-scoping construct in IDL. It’s similar to packages in Java or LISP or to namespaces in C++. A module is declared with the module keyword, followed by an identifier for the module and then the body of the module, enclosed in braces:

// IDL
module identifier { ... };

Modules can contain IDL interface definitions, constants, or user-defined types, such as typedefs, structs, unions, and enumerations.

Mapping Modules to Java

Modules in IDL are mapped to packages in Java, and nested modules are mapped to subpackages, with the innermost module being mapped to the rightmost subpackage. If we have the following interfaces and modules defined in IDL:

// IDL
module util{
     interface MatrixOps { ... };
 
     module dbase {
          interface Query { ... };
     };
};

the generated Java code includes an interface named MatrixOps, starting with this package statement:

// Java
package util;

and another interface named Query, with this package statement:

// Java
package util.dbase;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required