OOPortal OOPortal

Java Programming  «Prev  Next»
Lesson 2 Corba Modules
Objective Describe the mapping of an IDL module in Java.

Corba IDL Mapping Module in Java

Modules in IDL
  1. define the scoping of all other elements
  2. define the structure of all the other elements defined in that IDL.

All elements should be contained within a module, for organizational purposes as well as to prevent name clashes. The purpose of a module is exactly the same as that of a package in Java, therefore a module in IDL maps directly into a Java package.

Modules in IDL

Classes generated for elements defined within a module are placed within that Java package, and likewise into a directory for that package. Modules within modules become subpackages. So the IDL code shown below:

module MyTopMod {
    module ModTwo {
       module ModThree {
   } ;
       module ModFour {
    module ModFive {

would be mapped by the IDL compiler into a package directory structure like this:
MyTopMod -+
          +--ModTwo -+
          |          +--ModThree
          |          +--ModFour

Alternate Package Hierarchies

Many IDL compilers will allow you to specify a base package name that is prepended to all packages generated for modules. This allows individual companies to generate classes in line with "Java standards for package naming".

Java naming standards for Packages:

This convention for package names holds that all packages produced should start with the domain name reversed.
For example, if the producing company is xenotrope.com, all packages would start with com.xenotrope.
If the producing company is the computer science department at Yale University, all packages would start with edu.yale.cs.
These package names are generated for use with a particular implementation.
This base package does not have to be consistent across different system parts (although it is easier) even if they are communicating with the same IDL interfaces. The runtime creation of 1) stubs and 2) helper instances when dealing with a remote reference is based on the IDL interface repository ID for the IDL interface, not the Java classes of the remote implementation. The ORB core will find the classes with which the specific application was compiled.
In the next lesson, you will learn how to describe the mapping of an IDL interface to Java interfaces and classes.