About Us
Education and Training
Consulting
Gifts
Contacting Us
Employment
Journal
Journal

Home

The Pantheon Systems Journal

The IDL
by Niranjan Ramakrishnan

In the previous two articles, we looked at the rationale for CORBA, and the idea of stubs and skeletons. In this article we shall examine the CORBA Interface Definition Language (IDL).

The IDL is the standard language in which all CORBA interfaces are written. Before say more about IDL, we must first examine the concept of an interface.

The interface is one of the most significant realizations in programming. It is what enables one to program without knowing how something will be implemented. For example, this is the principle which enables you to buy an electrical gadget without worrying about whether your home is powered by thermal or hydroelectric or nuclear power; the interface, ie., the power outlet - is going to be the same.

To take a practical example. In C++, I can write a stopwatch as follows:

class Stopwatch {
    public:
        virtual void start() = 0;
        virtual void stop() = 0;
        virtual double getSeconds() = 0;
};

Or in Java,

interface Stopwatch {
    public void start();
    public void stop();
    public double getSeconds();
};

In both cases, the specification merely says what can be expected, and not how it is implemented. The implementation is left to the concrete classes.

Now to the IDL. Suppose we wanted a specification that would work both with Java and C++ (and maybe C and Smalltalk and Cobol...).

Then, we would need a neutral language to express the same thing. This is the IDL. It strongly resembles C++, since it was conceived when C++ ruled. Java programmers should not have great difficulty adapting to it, as the syntax is not dissimilar to Java. The same code, expressed in IDL, is as follows:

module Watch {
   interface Stopwatch {
      void start();
      void stop();
      attribute double seconds;
   };
};

Here is a small table showing how keywords used above in IDL translate to C++ and Java.

IDL C++ Java
module namespace package
interface class interface
attribute accessor/mutator accessor/mutator
function pure virtual abstract method

Converting IDL to other languages

Each translation of IDL into other languages is called a mapping. Different ORB vendors provide mappings to one or more languages. This enables CORBA programmers to write code in a common language without worrying about whether it will work in different languages.

To convert a file from IDL to a language, the ORB vendor provides a tool, such as idl2java. Running this on the IDL file produces a large number of java files, including stubs and skeletons to use on the client and server side of the object.

After IDL

After translating the code from the IDL to your favorite programming language, you have to write a concrete server class that implements the interface laid down by the IDL. This class provides implementations for all the interface methods. It may also have to provide data support for any attributes listed in the IDL code. Once this is done, the server is ready to be registered for usage.

In the next article, we shall study the code generated by this simple example and see how to build a client and server.


Top
Journal Archives | Send Feedback

Copyright© Pantheon Systems, Inc., All rights reserved.