Teach Yourself CORBA In 14 Days

February 27, 2008 at 1:11 pm (CORBA, Unit 4, Unit 5) (, )

click here to get

e-book for CORBA

Permalink Leave a Comment

Building a CORBA Application

February 27, 2008 at 12:50 pm (CORBA, Unit 4) ()

  • The outline of the process is
    1. Define the server’s interfaces using IDL
    2. Choose an implementation approach for the server’s interfaces
    3. Use the IDL compiler to generate client stubs and server skeletons for the server interfaces.
    4. Implement the server interfaces.
    5. Compile the server application
    6. Run the server application

Building a CORBA Server

  • Since a server can be tested without a client, the first step is to implement the server.
  • The server interfaces define the capabilities that will be made available by the server and how these capabilities are accessed.
  • Implement those interfaces and finally compile and run the server.

a) Defining the Server Interfaces (Stock Market Server Example)

§ A Service is desired that, when given a stock symbol, will return the value of that stock at that particular time.

§ As an added convenience, the service will also return a list of all known stock symbols upon the request.

§ So, the StockServer interface could be defined to provide two services: (1) getStockValue() (2) getStockSymbols()

§ getStockValue() should take a StockSymbol as a parameter and return a floating-point result.

§ getStockSymbol() need not take any arguments and should return a list of StockSymbol objects.

StockMarket.idl

module StockMarket {

typedef string StockSymbol;

typedef sequence <StockSymbol> StockSymbolList;

interface StockServer {

float getStockValue (in StockSymbol symbol);

StockSymbolList getStockSymbols();

};

};

§ Group the related interfaces and types into IDL modules.

§ IDL offers two constructs to represent lists. (1) the sequence (2) the array.

§ Here, the size of the list is unknown, so the sequence is used.

§ However a method cannot return a sequence directly. So

typedef sequence <StockSymbol> StockSymbolList; is used.

b) Choosing an implementation approach

§ CORBA supports two mechanisms for implementation of IDL interfaces

i. Inheritance mechanism – in which a class implements an interface by inheriting from that interface class.

ii. Delegation mechanism – in which the methods of the interface class call the methods of the implementing class.

mechanism.jpg

§ Implementation by inheritance consists of a base class that defines the interfaces of a particular object and a separate class, inheriting from this base class, which provides the actual implementations of these interfaces.

§ Implementation by delegation consists of a class that defines the interfaces for an object and then delegates their implementations to another class or classes.

§ The primary differences between the inheritance and delegation approaches is that in delegation, the implementation classes need not derive from any class in particular.

§ A tie class, or simply a tie, is the class to which implementations are delegated in the delegation approach. Thus, the approach is often referred to as the tie mechanism or tying.

§ Most IDL compilers accept command-line arguments to determine which implementation approach to generate code for.

b) How to choose an implementation approach

§ If an application makes use of legacy code to implement an interface, it might not be practical to change the classes in that legacy code to inherit from a class generated by the IDL compiler.

§ Therefore, for such an application it would make more sense to use the delegation approach; existing classes can readily be transformed into the classes.

Using the IDL Compiler

  • The command to invoke the IDL compiler, included with Sun’s Java IDL product is,

idltojava –fno-cpp –fclient –fserver StockMarket.idl

-fno-cpp : switch instructs the IDL compiler to not invoke the C preprocessor before compiling the file.

-fclient and –fserver : switches instruct the IDL compiler to generate client stubs and server skeletons, respectively.

  • Client Stubs and Server Skeletons

ü When the IDL compiler is invoked, it generates code that conforms to the language mapping used by that particular product.

ü The IDL compiler will generate a number of files – some of them helper classes, some them client stub classes, and some of them server skeleton classes.

ü The stubs do nothing more than tell the client’s ORB to marshal and unmarshal outgoing and incoming parameters.

ü The skeletons pass incoming parameters to the implementation code and passing outgoing parameters back to the client.

ü The names of the files generated by the IDL compiler are dependent on the language mapping used and sometimes on command-line arguments passed to the IDL compiler.

ü The contents of these files will remain the same, for the most part, regardless of the IDL compiler used.

 

Permalink Leave a Comment

IDL Datatypes – Part 2

February 26, 2008 at 3:38 pm (CORBA, Unit 4) (, )

The Interface Type

  • The Interface describes the services provided by a CORBA object.
  • These services appear in the form of operations (or methods), resembling methods in Object Oriented Languages.
  • The difference is that IDL is used only to specify the interfaces of these methods, whereas the language like Java and C++ are used to specify interfaces and (usually) provide implementations for those interfaces methods.
  •  The IDL interface type is very much like the Java interface type because neither provides an implementation for the methods defined.
  • However, the major difference is  that IDL interfaces can contain attributes, whereas Java interfaces don’t.
  • An IDL interface definition can thus be compared to a C++ header file containing a class definition. Also a C++ class whose methods are all pure virtual can be considered analogous to the IDL interface.
  • All methods defined within an IDL interface are public they can be called by any other object having a reference to the interface’s implementation object.
  • IDL interfaces usually describe remote objects. So it provides some additional modifiers to further describe the interface and its members.

 

Methods and Parameters

  • Methods defines the functionality of the objects.
  • Although the object’s implementation determines how the object behaves, the interface’s method definitions determine what behavior the object implementing that interface provides
  • These method definitions are often called method signatures or just signatures.
  • IDL methods can use any IDL data types as input and output parameters – primitive types, structs, sequences and even interfaces.
  • The general syntax,

[oneway] return_type methodName(param1_dir param1_type param1_name, param2_dir param2_type param2_name, …);

  • The param dir modifier specifies the direction of each parameter (in, out, inout)
  • A method signature, often simple called a signature, describes what a method does, what parameters (and their types) the method takes as input, and what parameters it returns as O/P.

 

in, out and inout parameters

  • in parameter servers as input to the method
  • out parameter is an output from the method
  • inout parameter serves as an input to and an output from the method.
  • In remote method terms, any in  and inout parameters are marshaled across the network to the remote object.
  • After the method executes, any out and inout parameters along with the method’s return value are marshaled back to the calling object.

 

oneway methods

  • When an object calls a method on a remote object, that calling object waits (this is called blocking) for the method to execute and return.
  • When the remote object finishes processing the method invocation, (called a request) it returns to the calling object then continue its processing.
  • In general blocking refers to any point at which a process or thread is waiting for a particular resource or another process/thread.
  • Within the context of CORBA, if a client invokes a remote method and must wait for the result to be returned, the client is said to ‘block’.

oneway.jpg

  • A request is simply another name for a RMI. This term is commonly used when referring to the operation of a distributed system.
  • In the CORBA’s Dynamic Invocation Interface (DII), the remote method can be invoked through a request object.
  • When a method is declared oneway, it means that the object calling that method will not block. Rather, the object will call the remote method and then immediately continue processing, while the remote object executes the remote method.
  • The advantage of this approach is that the calling object can continue working rather than wait for the remote object to complete the request.

oneway-2.jpg

  • The disadvantage is that the method invocation returns before the method execution is completed, so the method cannot return a value.
  • Therefore, for an oneway method, the return value must be declared as void, and all parameters must be declared as in.
  • Another disadvantage is, a oneway method cannot raise any exception. Also, the calling object has no way of knowing whether the method executed successfully; the CORBA infrastructure makes a best-effort attempt to execute the method, but success is not guaranteed.
  • Therefore, the oneway methods are most useful for situations in which one object wants to inform another object of a particular status but
    • Does not consider the message to be essential
    • Does not expect a response
  • Multithreading can be used to overcome this blocking problem by creating a separate thread to invoke the remote method.
  • While that thread is blocked, waiting for the result to be returned, other threads can continue working.

Permalink Leave a Comment

IDL – Constructed Types (User-defined datatypes)

February 24, 2008 at 6:03 pm (CORBA, Unit 4) (, )

  • Combine other types to enable the creation of user-defined data types.

a) enumerated type

  • The enumerated type, enum allows the creation of types that can hold one of a set of predefined value specified by the enum.
  • Although the identifiers in the enumeration comprise an ordered list, IDL does not specify the ordinal numbering for the identifiers.
  • This is similar to enum in C and C++

Ex:

            enum DaysOfWeek

            {

                        Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

            };

b) structure type

  • Contains any no. of member values of disparate types
  • Structures are useful in IDL because, unlike CORBA objects, structures are passed by value rather than by reference.
  • In other words, when a struct is passed to a remote object, a copy of that struct’s value is created and marshaled to the remote object.

Ex:

            struct DateStruct

            {

                        short year,

                        short month,

                        short day,

                        short hour,

                        short minute,

                        short second,

                        short microsecond

            };

c) union type

  • Represents values of different types.
  • Resembles a cross between a C/C++ union and a case statement.

Ex:

            union MultipleType switch(long)

            {

                        case 1:

                                    short myShortType;

                        case 2:

                                    double myDoubleType;

                        case 3:

                        default:

                                    string myStringType;

            };

  • Here, the parameter is called as discriminator.
  • A discriminator used in an IDL union is a parameter that determines the value used by the union. The constant values in the case statements must match the discriminator’s type.

 

Permalink Leave a Comment

IDL Data Types – Part 1

February 24, 2008 at 9:19 am (CORBA, Unit 4) (, )

Primitive Types

IDL features a variety of primitive types. These types store simple values such as integral numbers, floating point numbers, character strings, and so on.

a) void

  • This is analogous to the void type in C, C++ and Java
  • This is useful for methods that don’t return any value.

 

b) boolean

  • Stores a boolean value either 0 (false) or 1(true)
  • Depending on the programming language used, the IDL boolean type can map to an integral type (short int in C/C++) or to the language’s native Boolean type (as in Java)

boolean aBoolean;

 

c) char and wchar

  • This is analogous to char type in C/C++ and Java. And directly maps.
  • Stores a single character value
  • The char data type is an 8-bit quantity

char aChar;

  • In version 2.1, wchar or wide character type is an 16-bit quantity

 

Floating Point Types

a) float

  • The IDL float type represents an IEEE single-precision floating point value
  • Analogous to C, C++, and Java

float aFloat;

 

b) double and long double

  • Represents an IEEE double-precision floating point value
  • Corresponds to the double type in leading languages

double aDouble;

  • The long double type, introduced in CORBA 2.1, represents IEEE double-extended floating point value, having an exponent of at least 15 bits and a signed fraction of at least 64 bits.

 

Integer Types

  • Unlike most familiar programming languages, IDL doesn’t define a plain int type only short and long integer types.

 

a) long and long long

  • The IDL long type represents a 32-bit signed quantity, like C/C++’s int and Java’s int

Ex: long aLong;

  • In CORBA 2.1 the long type was added, which is a 64-bit signed quantity

 

b) unsigned long and unsigned long long

  • The unsigned long type in IDL is an unsigned version of the long type

Ex: unsigned long anUnsignedLong;

  • CORBA 2.1 added the unsigned long long type, which is a 64-bit unsigned quantity.

 

c) short

  • Represents a 16-bit signed quantity, as in C, C++, and Java
  • It’s range -215 … 215-1.

Ex: short aShort;

 

d) unsigned short

  • Unsigned version of short
  • Range   – 0…216-1

Ex: unsigned short aUnsignedShort;

 

e) octet

  • It is an 8-bit quantity that is not translated in any way during transmission.
  • The similar type is available in Java as byte.

Ex: octet aOctet;

 

f) string

  • Represents a collection of characters. Similar to C++’s Cstring and Java’s String class.
  • In ‘C’ character arrays are used as string.
  • IDL supports fixed-length and variable-length strings.

Ex: string aFixedLength[20];

       string aVariantLength;

 

The const modifier

  • const values are useful for values that should not change.
  • The scope of the const value is interface or module.

Ex: const float pi = 3.14;

Permalink Leave a Comment

CORBA History

February 24, 2008 at 9:04 am (CORBA) ()

OMG (Object Management Group)

  • Established in 1989 with 8 members
  • whose charter is to “provide a common architectural framework for object-oriented applications based on widely available interface specifications.”
  • Object Management Architecture is a set of standards deliver the common architectural framework on which applications are built.
  • CORBA’s role in OMA is to  implement the ORB functions.

CORBA 1.0

  • Was introduced and adopted in December 1990.
  • It was followed in early 1991 by CORBA 1.1, which defined the Interface Definition Language (IDL) as well as API for applications to communicate with an ORB.

CORBA 2.0 and IIOP

  • CORBA 1.x was an important first step is providing distributed object interoperability, but wasn’t a complete specification.
  • Although it provided standards for IDL and for accessing an ORB through an application, its chief limitation was that it did not specify a standard protocol through which ORBs could communicate with each other.
  • As a result, a CORBA ORB from one vendor could not communicate with an ORB from another vendor, a restriction that severely limited interoperability among distributed objects.
  • CORBA 2.0 is adopted in December 1994.
  • The primary accomplishment was to define a standard protocol by which ORB from various CORBA vendors could communicate.
  • This protocol, known as the IIOP is required to be implemented by all vendors who want to call their products CORBA 2.0 compliant.
  • IIOP ensures true interoperability among products from numerous vendors, thus enabling CORBA applications to be more vendor-independent.

Permalink Leave a Comment

Exploring CORBA Alternatives

February 24, 2008 at 8:45 am (CORBA, Unit 4) ()

  1. Socket Programming
    • Socket is a channel through applications can connect with each other and communicate
    • The most straight forward way to communicate between application components
    • The API for socket programming is rather low-level.
    • However, because the API is low-level, socket programming is not well suited to handling complex data types, especially when application components reside on different types machines (or) are implemented in different programming languages.
  2. Remote Procedure Call (RPC):
    • Provides a function-oriented interface to socket-level communications
    • Using RPC, rather than directly manipulating the data that flows to and from a socket, the developer defines a function and generates codes that makes that function look like a normal functions to the caller.
    • Because RPC provides a function-oriented interface, it is often much easier to use than raw socket programming.
  3. DCE
    • Set of Standards by the OSF, includes a standard for RPC.
    • It was never gained wide acceptance and exists today as little more than an historical curiosity.
  4. DCOM
    • It is a relatively robust object model, that enjoys particular good support on Microsoft O/S.
    • However, being a Microsoft technology, the availability of DOM is sparse outside the realm of Windows O/S.
    • CORBA-DCOM bridges enable CORBA objects to communicate with DCOM objects vice versa.
  5. RMI
    • Advantage – it supports the passing of objects by value, a feature not (currently) supported by CORBA.
    • Disadvantage – it is a java-only solution, that is RMI servers and clients must be written in JAVA.

Permalink Leave a Comment

Why CORBA?

February 23, 2008 at 3:33 am (CORBA, Unit 4) ()

  • CORBA Provides a Standard mechanism for defining the interfaces between components as well as some tools to facilitate the implementation of those interfaces using the developer’s choice of languages.
  • Two features that CORBA provides are:
    • Platform Independence
    • Language Independence
  • Platform Independence means that CORBA objects can be used on any platform for which there is a CORBA ORB implementation.
  • Language Independence means that CORBA objects and clients can be implemented in just about any programming language.

Permalink Leave a Comment

Interface Definition Language (IDL)

February 23, 2008 at 3:25 am (CORBA, Unit 4) (, )

IDL Ground Rules

a) Case Sensitivity

  • Identifiers are case sensitive.
  • The names of identifiers in the same scope cannot differ in case only. Ex. in the myObject interface, IDL would not allow an operation named anOperation and another operation named anOPERATION to be simultaneously.

 

b) IDL Definition Syntax

  • All definitions in IDL are terminated by a semicolon (;), much as they are in C, C++, and Java
  • Definitions that enclose other definitions do so with braces. (modules & interfaces)
  • When a closing brace also appears at the end of a definition, it is also followed by a semicolon it represents a module.

 

c) IDL Comments

  • Both C-Style and C++-Style comments are allowed

// C++ comment allowed

/* C – Style Comment allowed */

 

d) Use of the C Preprocessor

  • IDL assumes the existence of a C preprocessor to process constructs such as macro definitions and conditional compilation.

Ex: #ifdef….#endif, #include etc.

e) The Module

  • The module construct is used to group together IDL definitions that share a common purpose.
  • A module declaration specifies the module name and encloses its members in braces.

Ex:

module Bank {

interface Customer {

};

interface Account {

};

};

  • The grouping together of similar interfaces, constant values, and the like is commonly referred to as partitioning and is a typical step in the system design process.
  • Partitions are also often referred to as modules or as packages.

 

f) Coupling and Cohesion

  • Loose coupling means that components in separate modules are not tightly integrated with each other; an application using components in one module generally need not know about components in another module. When there is little or no dependency between components, they are said to be loosely coupled.
  • Tight cohesion means that interfaces within the module are tightly integrated with each other.
  • Loose coupling of components reduces the possibility that changes to one component will require changes to another.

Permalink Leave a Comment

EJB Specification 2.1

February 22, 2008 at 5:01 am (EJB Specification) (, )

Click to view

EJB Specification 2.1

Permalink Leave a Comment

Next page »