Académique Documents
Professionnel Documents
Culture Documents
Introduction to CORBA The Object Management Group (OMG) was formed in 1989. Its aims were:
to make better use of distributed systems to use object-oriented programming to allow objects in different programming languages to communicate with one another
The object request broker (ORB) enables clients to invoke methods in a remote object CORBA is a specification of an architecture supporting this.
CORBA 1 in 1990 and CORBA 2 in 1996.
Introduction to CORBA
The main components of CORBAs RMI framework are: 1. An interface definition language known as IDL. 2. An architecture. 3. The General Inter-ORB protocol (GIOP) defines
an external data representation, called CDR specifies formats for the messages in a request-reply protocol. including messages for enquiring about the location of an object, for cancelling requests and for reporting errors.
1. The Internet Inter-ORB protocol (IIOP) defines a standard form for remote object references.
IIOP is GIOP implemented in TCP/IP
CORBA services - generic services useful in distributed applications e.g. Naming Service, Event Service.
CORBA RMI
CORBA RMI is a multi-language RMI system. The programmer needs to learn the following new concepts:
the object model offered by CORBA; the interface definition language and its mapping onto the implementation language.
interface Shape { long getVersion() ; GraphicalObject getAllState() ; // returns state of the GraphicalObject }; an interface specifies a name and a set of methods
this struct is used as a parameter or result type in methods in the remote interfaces.
sequences and arrays in typedefs typedef sequence <Shape, 100> All; interface ShapeList { interface ShapeList exception FullException{ }; Shape newShape(in GraphicalObject g) raises (FullException); All allShapes(); // returns sequence of remote object references long getVersion() ; Exceptions defined by raises and set the }; parameter of newShape is an in parameter and of type Graphical Object The return value is an Figure 17.1 extra out parameter of type Shape. by throw. They can have arguments.
Note: the method allShapes returns an array of remote object references as follows:
typedef sequence <Shape, 100> All; All allShapes();
Type Object - is a supertype of all IDL interfaces (its values are object references).
The name service is present in all CORBA installations. (Its role is like the Java RMI registry) Its use will be shown in program examples
CORBA client and server example Illustration of CORBA with a Java client and server The interface compiler is called idltojava, when given an IDL interface, it produces:
the equivalent Java interfaces (e.g. ShapeList below) server skeletons for each idl interface (e.g. _ShapeListImplBase) proxy classes or client stubs (e.g. _ShapeListStub) a Java class for each struct e.g. Rectangle, GraphicalObject helper classes (one for each of the types defined in the IDL interface) and holder classes (for out and inout arguments which can not be directly map on to java)
public interface ShapeList extends org.omg.CORBA.Object { Shape newShape(GraphicalObject g) throws ShapeListPackage.FullException; Shape[] allShapes(); Figure int getVersion(); }
The ShapeListServant class of the Java server program for the CORBA interface ShapeList.
import org.omg.CORBA.*; class ShapeListServant extends _ShapeListImplBase { ORB theOrb; private Shape theList[]; a servant class extends the corresponding private int version; skeleton class (e.g. ShapeListImplBase) private static int n=0; public ShapeListServant(ORB orb){ theOrb = orb; CORBA objects are instances of servant classes. // initialize the other instance variables In non-OO languages implementations of CORBA } objects cant be classes. public Shape newShape(GraphicalObject g) throws ShapeListPackage.FullException { version++; Shape s = new ShapeServant( g, version); if(n >=100) throw new ShapeListPackage.FullException(); theList[n++] = s; a servant class implements the methods in the theOrb.connect(s); interface (ShapeList). return s; newShape is a factory method. It creates new } CORBA objects. It uses the connect method to public Shape[] allShapes(){ ... } register it with the ORB. (it has a remote object public int getVersion() { ... } } reference)
A Java server has classes for its IDL interfaces (e.g. Shape and ShapeList). Here is the class ShapeListServant
Figure
Client stubs/proxies Skeletons Dynamic invocation interface is designed to allow clients The CORBAskeleton classes (for OO languages) are generated in the ORB someapplicationsadapter language. without the appropriate core these are in(e.g. client the Object architecture client In browsers), a
client
implementation repository
interface repository
ORB core
Request Reply
or dynamic invocation
Figure
or dynamic skeleton
Object adapter
an object adapter bridges the gap between
CORBA objects with IDL interfaces and the programming language interfaces of the corresponding servant (classes). it does the work of the remote reference and despatcher modules in RPC.
Each object adapter has its own name - specified by the application program or generated automatically. CORBA 2.2 standard for object adapters is called POA.
- not all CORBA objects (e.g. call backs) need be activated on demand - access control information can be stored in an implementation repository
Interface repository
it provides information about registered IDL interfaces
for an interface of a given type it can supply the names of the methods and for each method, the names and types of the arguments and exceptions. a facility for reflection in CORBA. if a client has a remote reference to a CORBA object, it can ask the interface repository about its methods and their parameter types the client can use the dynamic invocation interface to construct an invocation with suitable arguments and send it to the server.
the IDL compiler gives a type identifier to each IDL type a type identifier is included in remote object references this type identifier is called the repository ID
because the interface repository stoes interfaces against their IDs
applications that use static invocation with client proxies and IDL skeletons do not require an interface repository.
Not all ORBs provide an interface repository.
CORBA IDL IDL provides facilities for defining modules, interfaces, types, attributes and method signatures.
examples of all of the above, except modules, is shown in Figure IDL interfaces shape and shape and shapelist.
IDL has the same lexical rules as C++ but has additional keywords to support distribution,
for example interface, any, attribute, in, out, inout, readonly, raises.
It allows standard C++ pre-processing facilities. e.g. typedef for All. The grammar of IDL is a subset of ANSI C++ with additional constructs to support method signatures.
IDL module Whiteboard Modules allow interfaces and IDL type definitions to be grouped. A module defines a naming scope, which prevents names define within a module clashing with names defined outside it.
Figure
module Whiteboard { struct Rectangle{ ...} ; struct GraphicalObject { ...}; interface Shape { ...}; typedef sequence <Shape, 100> All; interface ShapeList { ...}; };
The optional raises expression indicated user define exceptions The optional context expression is used to supplies mapping form string names to string values
Inheritance
IDL interfaces may extend one or more interfaces an extended interface may add new methods, types, constants and exceptions It may redefine types, constants and exceptions but not methods Interface A{}; Interface B: A{}; Interface C{}; Interface Z: B and C{};
Use
Defines a type for a variable-length sequence of elements of a specified IDL type. An upper bound on the length may be specified. Defines a sequences of characters, terminated by the null character. An upper bound on the length may be specified. Defines a type for a multi-dimensional fixed-length sequence of elements of a specified IDL type.
array
Use
Defines a type for a record containing a group of related entities. Structs are passed by value in arguments and results. The enumerated type in IDL maps a type name onto a small set of integer values. The IDL discriminated union allows one of a given set of types to be passed as an argument. The header is parameterized by an enum, which specifies which member is in use.
enumerated union
CORBA 2.0 specifies a format for remote object references that is suitable for use, whether or not the object is activatable. References using this format are called 'interoperable object references'
(IORs).
First field species the type name of the IDL interface of the CORBA object Second field specifies the transport protocol Third field is used by the ORB to identify a CORBA object
IOR format IDL interface type name Protocol and address details interface repository identifier IIOP host domain name port number Object key adapter name object name
Transient IORs are for objects that last as long as the host process they contain the address of the server hosting the CORBA object
The server ORB core receives the request message containing the object adapter name and object name of the target. It uses the object adapter name to locate the object adapter, which uses the object name to locate the servant.
Persistent IORs last between activations they contain the address of the implementation repository the implementation repository receives the request and uses the object adapter name to activate the object, then gives the server address to the client the client sends subsequent invocations to the server