This is possible because Java IDL is based on the Common Object Request Brokerage Architecture (CORBA), an industry-standard distributed object model. A key feature of CORBA is IDL, a language-neutral Interface Definition Language. Each language that supports CORBA has its own IDL mapping--and as its name implies, Java IDL supports the mapping for Java. To learn more about the IDL-to-Java language mapping, see IDL-to-Java Language Mapping.
To support interaction between objects in separate programs, Java IDL provides an Object Request Broker, or ORB. The ORB is a class library that enables low-level communication between Java IDL applications and other CORBA-compliant applications.
This tutorial teaches the basic tasks needed to build a CORBA distributed application using Java IDL. You will build the classic "Hello World" program as a distributed application. The Hello World program has a single operation that returns a string to be printed.
Any relationship between distributed objects has two sides: the client and the server. The server provides a remote interface, and the client calls a remote interface. These relationships are common to most distributed object standards, including Java Remote Method Invocation (RMI, RMI-IIOP) and CORBA. Note that in this context, the terms client and server define object-level rather than application-level interaction--any application could be a server for some objects and a client of others. In fact, a single object could be the client of an interface provided by a remote object and at the same time implement an interface to be called remotely by other objects.
This figure shows how a one-method distributed object is shared between a CORBA client and server to implement the classic "Hello World" application.A one-method distributed object shared between a CORBA client and server.
On the client side, the application includes a reference for the remote object. The object reference has a stub method, which is a stand-in for the method being called remotely. The stub is actually wired into the ORB, so that calling it invokes the ORB's connection capabilities, which forwards the invocation to the server.
On the server side, the ORB uses skeleton code to translate the remote invocation into a method call on the local object. The skeleton translates the call and any parameters to their implementation-specific format and calls the method being invoked. When the method returns, the skeleton code transforms results or errors, and sends them back to the client via the ORBs.
Between the ORBs, communication proceeds by means of a shared protocol, IIOP--the Internet Inter-ORB Protocol. IIOP, which is based on the standard TCP/IP internet protocol, defines how CORBA-compliant ORBs pass information back and forth. Like CORBA and IDL, the IIOP standard is defined by OMG, the Object Management Group.
Despite its simple design, the Hello World program lets you learn and experiment with all the tasks required to develop almost any CORBA program that uses static invocation. The following steps provide a general guide to designing and developing a distributed object application with Java IDL. Links to the relevant steps of the tutorial will guide you through creating this sample application.
You define the interface for the remote object using the OMG's
Interface Definition Langauge (IDL). You use IDL instead of the
Java language because the
automatically maps from IDL, generating all Java language stub and
skeleton source files, along with the infrastructure code for
connecting to the ORB. Also, by using IDL, you make it possible for
developers to implement clients and servers in any other
Note that if you're implementing a client for an existing CORBA
service, or a server for an existing client, you would get the IDL
interfaces from the implementer--such as a service provider or
vendor. You would then run the
compiler over those interfaces and follow these steps.
Writing the IDL file in this tutorial walks you through defining the remote interface for the simple "Hello World" example.
When you run the
idlj compiler over
your interface definition file, it generates the Java version of
the interface, as well as the class code files for the stubs and
skeletons that enable your applications to hook into the ORB.
Mapping Hello.idl to Java in this tutorial walks you through these steps for the simple "Hello World" example.
Once you run the
idlj compiler, you can use the
skeletons it generates to put together your server application. In
addition to implementing the methods of the remote interface, your
server code includes a mechanism to start the ORB and wait for
invocation from a remote client.
Developing the Hello World Server walks you through writing a simple server for the "Hello World" application.
Similarly, you use the stubs generated by the
idlj compiler as the basis of your client
application. The client code builds on the stubs to start its ORB,
look up the server using the name service provided with Java IDL,
obtain a reference for the remote object, and call its method.
Developing a Client Application walks you through writing a simple client application.
Once you implement a server and a client, you can start the name service, then start the server, then run the client.
Running the Hello World Application walks you through running the server and client program that together make up the "Hello World" application, and the name service that enables them to find one another.
Using Stringified Object References walks you through making an object reference when there is no naming service.
Running the Hello World Application on Two Machines describes one way of distributing the simple application across two machines - a client and a server.
Although concepts are explained as they are introduced in the tutorial, you will find more information in the Concepts section. New terms are linked to their definitions throughout the tutorial.
The Object Management Group no longer maintains this site, but the CORBA for Beginnners page contains links to web pages that provide introductory CORBA information.
|Java IDL Home|
Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved.