Short Introduction to CORBA

Objects

Abstraction is a useful tool to reduce complexity. As software becomes more complex the ability to work using abstractions becomes more important. One such abstraction is the Abstract Data Type (ADT). An ADT is an encapsulation of a data structure along with the procedures (operations) that manipulate that data. In the example in the Seminar Notes, the "Card" is an abstract data type, that encapsulates together the data (name, image file name, etc.) with the operations (getName, getFileName, etc).

Today, ADT's have evolved into a collection of languages said to be object-oriented. Such languages express ADT's as objects. Thus, an Object is a basic computational unit consisting of a defined behavior and attributes. Requests made on an object are called methods. The visible portion of an Object is called its interface. Objects can be grouped and categorized into classes by their common attributes and behavior.

Distributed objects

A client is an application (process) that requests services from other applications (i.e., server processes). A server is a software module (process) that accepts requests from clients and other servers and returns replies. Distributed objects are often deployed in a client-server configuration. The server-side objects offer services and resources. Client-side objects request services and resources. The requester and the provider may live on separate machines within the network. The interface is very important in distributed objects, because it states what types of requests an object is willing to receive.

Difficulties of distributed programming

The design and implementation of software is a difficult and expensive activity, even where this can be done on a single stable platform using a single operation system and a single programming language. Unfortunately, a considerable amount of the software being written now faces a number of additional complexities: With these complexities, the cost of writing and maintaining software increases - unless we have a framework that addresses these problems.

CORBA (Common Object Request Broker Architecture)

The CORBA standard directly addresses the difficulties that arise from boundaries such as networks, programming languages and operating systems. CORBA can be viewed as an environment to support the development and integration of systems constructed by combining the features of existing systems and subsystems.

An implementation of the standard is known as an Object Request Broker (ORB) - a middleman to allow a client to make requests on objects. An ORB must be capable of making requests across a network, between operating systems, and between programming languages.

The interface to server objects is described in an implementation-neutral interface definition language (IDL) which provides separation of interface and implementation. IDL is not another new programming language, it only provides interface definitions to inform the clients about what exactly an object is offering. IDL compilers translate IDL modules into specific programming language modules. The IDL compiler generates stub code that the client links to, and skeleton code that is used by the server objects. An example written in IDL and the IDL to C++ mapping are given at the end of this appendix.

The architecture of an ORB is described in the figure below:

The basic functionality provided by the ORB consists of passing the requests from clients to the object implementations on which they are invoked. In order to make a request the client can communicate with the ORB Core through the IDL stub or through the Dynamic Invocation Interface (DII). The stub represents the mapping between the language of implementation of the client and the ORB core. Thus the client can be written in any language as long as the implementation of the ORB supports this mapping. The ORB Core then transfers the request to the object implementation which receives the request as an up-call through either an IDL skeleton, or a dynamic skeleton.

The communication between the object implementation and the ORB core is effected by the Object Adapter (OA). It handles services such as generation and interpretation of object references, method invocation, security of interactions, object and implementation activation and deactivation, mapping references corresponding to object implementations and registration of implementations. It is expected that there will be many different special-purpose object adapters to fulfill the needs of specific systems (for example databases).

ORBacus

For this lab we will use a CORBA implementation named ORBacus. The Appendix B gives an example of a "Hello World" client-server application developed using ORBacus.

IDL example and mappings

The following example concerns a store with point-of-sale (POS) terminals. The POS terminal object uses the interface to communicate with its bardcode-reader object, keypad object, and receipt-printer object.
            // Point-of-sale object IDL example 
            module POS { 
               typedef string Barcode;
               interface InputMedia { /* define class */ 
                  typedef string OperatorCmd; 
                  void barcode_input(in Barcode item); 
                  void keypad_input(in OperatorCmd cmd); 
               }; 
       
               interface OutputMedia { 
                  boolean output(in string StringToPrint); 
               }; 
       
               interface POSTerminal { 
                  void end_of_sale(); 
                  void print_POS_sales_summary(); 
               }; 
            };
CORBA IDL is a very close relative of C++. It supports basic and constructed types. Objects are declared as Interfaces (which resemble C++ classes). While not an exact mapping, the following list shows IDL types and their approximate C++ type.

IDL

C++

boolean bool
char signed char
octet 8 bits
enum enum
short short
unsigned short unsigned short
long long
unsigned long unsigned long
float float
double double
any (no native equivalent; similar to a void * accompanied by a type indicator)
object (closest to class)
string class string (bounded and unbounded lengths)
struct struct (like C, rather than a C++ struct)
union union (discriminated union; a type-tagged C struct)
array [ ]
sequence (a parameterized array of bounded or unbounded length)