Using CORBA and Java IDL
Using CORBA and Java IDL
• About CORBA
• Αβ ο υ τ ϑαϖ α Ι∆Λ
• ΧΟ Ρ Β Α Χο ν χ ε π τ σ ιν α Νυ τ σ η ε λ λ
• ∆εφ ι ν ι ν γ αν δ Ιµπλ ε µ ε ν τ ι ν γ ΧΟ Ρ Β Α
Οβ ϕ ε χ τ σ
• Χλ ι ε ν τ Ιµπλ ε µ ε ν τ α τ ι ο ν
About CORBA
CORBA (Common Object Request Broker Architecture) is the standard distributed object
architecture developed by the Object Management Group (OMG) consortium. Since 1989
the mission of the OMG has been the specification of an architecture for an open
software bus, or Object Request Broker (ORB), on which object components written by
different vendors can interoperate across networks and operating systems. This standard
allows CORBA objects to invoke one another without knowing where the objects they
access reside or in what language the requested objects are implemented. The OMG-
specified Interface Definition Language (IDL) is used to define the interfaces to CORBA
objects.
CORBA objects differ from typical programming language objects in these ways:
• CORBA objects can be written in any programming language for which there is a
mapping from OMG IDL to that language. (Mappings currently specified include
Java, C++, C, Smalltalk, COBOL, and Ada.)
The Java 2 Platform, Standard Edition, v1.3, provides a CORBA 2.3.1-compliant Object
Request Broker (ORB) and two CORBA programming models that utilize the Java
CORBA ORB and Internet InterORB Protocol (IIOP). The two programming models are
the RMI programming model, or RMI-IIOP, and the IDL programming model, or Java
IDL. For more information on these programming models, read CORBA Technology and
the Java Platform.
About RMI-IIOP
Java RMI-IIOP is an Object Request Broker and a compiler, rmic -iiop, that generates
IIOP stub and tie classes. With RMI-IIOP, developers can write remote interfaces in the
Java programming language and implement them simply using Java technology and the
Java RMI APIs. These interfaces can be implemented in any other language that is
supported by an OMG mapping and a vendor supplied ORB for that language. Similarly,
clients can be written in other languages using IDL derived from the remote Java
technology-based interfaces. Using RMI-IIOP, objects can be passed both by reference
and by value over IIOP.
The concepts introduced in this section are more completely discussed in the
CORBA/IIOP Specification.
The diagram below shows a method request sent from a client to a CORBA object
implementation in a server. A client is any code (perhaps itself a CORBA object) that
invokes a method on a CORBA object. The servant is an instance of the object
implementation - the actual code and data that implements the CORBA object.
FPRIVATE "TYPE=PICT;ALT=[requestpath image]"
The client of a CORBA object has an object reference for the object and the client uses
this object reference to issue method requests. If the server object is remote, the object
reference points to a stub function, which uses the ORB machinery to forward
invocations to the server object. The stub code uses the ORB to identify the machine that
runs the server object and asks that machine's ORB for a connection to the object's server.
When the stub code has the connection, it sends the object reference and parameters to
the skeleton code linked to the destination object's implementation. The skeleton code
transforms the call and parameters into the required implementation-specific format and
calls the object. Any results or exceptions are returned along the same path.
The client has no knowledge of the CORBA object's location, implementation details, nor
which ORB is used to access the object. Different ORBs communicate via the OMG-
specified Internet InterORB Protocol (IIOP).
A client may only invoke methods that are specified in the CORBA object's interface. A
CORBA object's interface is defined using the OMG Interface Definition Language
(IDL). An interface defines an object type and specifies a set of named methods and
parameters, as well as the exception types that these methods may return. An IDL
compiler such as idlj translates the CORBA object definitions into a specific
programming language according to the appropriate OMG language mapping. Thus, the
idlj compiler translates IDL defintions into Java constructs according to the IDL-Java
language mapping.
The stub and skeleton files are generated by the idlj compiler for each object type. Stub
files present the client with access to IDL-defined methods in the client programming
language. The server skeleton files glue the object implementation to the ORB runtime.
The ORB uses the skeletons to dispatch methods to the object implementation instances
(servants).
The goal in CORBA object development is the creation and registration of an object
server, or simply server. A server is a program which contains the implementation of one
or more object types and which has been registered with the ORB. For example, you
might develop a desktop publishing server which implements a "Document" object type,
a "Paragraph" object type, and other related object types.
Client Implementation
Client code is linked with idlj-generated .java files and the ORB library. Examples of
application and applet clients are provided in the Hello World example.
Clients may only create CORBA objects via the published factory interfaces that the
server provides. Likewise, a client may only delete a CORBA object if that object
publishes a destruction method. Since a CORBA object may be shared by many clients
around a network, only the object server is in a position to know when the object has
become garbage.
The client code's only way of issuing method requests on a CORBA object is via the
object's object reference. The object reference is an opaque structure which identifies a
CORBA object's host machine, the port on which the host server is listening for requests,
and a pointer to the specific object in the process. Because Java IDL supports only
transient objects, this object reference becomes invalid if the server process has stopped
and restarted.
Clients typically obtain object references in the following ways:
• from a factory object. For example, the client could invoke a create method on
DocumentFactory object in order to create a new Document. The
DocumentFactory create method would return an object refererence for Document
to the client.
• from the nameservice. For example, the client could obtain an object reference for
the DocumentFactory by issuing a request on the nameservice.
The Java IDL Transient Nameservice is an object server provided with Java IDL. Use
tnameserv at the command line prompt to start the Name Server. This object server
conforms to the standard object implementation and invocation techniques described in
the previous sections of this page.
The Name Server stores object references by name in a tree structure similar to a file
directory. A client may lookup or resolve object references by name. Because the Name
Server is an ordinary Java IDL transient server, the entire directory structure of names is
lost each time tnameserv stops running.