CORBA Celsina Bignoli [email protected]. Enterprise Computing Corporation have similar computing...

29
CORBA Celsina Bignoli [email protected]

Transcript of CORBA Celsina Bignoli [email protected]. Enterprise Computing Corporation have similar computing...

Page 1: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

CORBA

Celsina [email protected]

Page 2: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Enterprise Computing

• Corporation have similar computing environments:– mixed set of HW platforms– a mixed set of SW components– programmers with very different skill sets– need to maintain legacy code– desire to avoid vendor lock-in

Page 3: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

What is CORBA

• CORBA (Common Object Request Broker Architecture)

• cross-platform, cross-language, vendor-independent specification for object-based distributed computing

• Introduced by the Object Management Group (OMG) in 1989

Page 4: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

OMG

• The OMG is a consortium that comprises over 700 companies and organizations– almost all the major vendors and developers

of distributed object technology• platforms• databases• software tools

– corporate application developers

Page 5: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

CORBA

• CORBA can be thought as a language-independent version of RMI– similar lifecycle including definition of

interfaces, generation of stubs and skeletons

• glues together application written in different languages on different platforms– interfaces must be specified in a language-

independent format

Page 6: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

CORBA Architecture

ServerClient

Stub Skeleton

Network

Invokes methodsimplemented by the server

Marshalls invocation and sends data to skeleton

Un-marshalls data andinvokes method on server

Page 7: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

CORBA Components

• Interface Definition Language (IDL)

• Wire Protocol (IIOP)

• Language Mappings

Page 8: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

CORBA Architecture

ServerClient

Stub Skeleton

IIOP

Invokes methodsgenerated from IDL(implemented by the server)

Marshalls invocation and sends data to skeletonAutomatically generated from IDL

Un-marshalls data and invokes method on serverAutomatically generated from IDL

ORB ORB

Page 9: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

ORB

• The ORB is the distributed service that implements the request to the remote object. – It locates the remote object on the network– communicates the request to the object– waits for the results and when available communicates those

results back to the client.

• The ORB implements location transparency. – Exactly the same request mechanism is used by the client and

the CORBA object regardless of where the object is located.

• The ORB implements programming language independence for the request. – The client issuing the request can be written in a different

programming language from the implementation of the CORBA object

Page 10: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

ORB Description

Java 2 ORB comes with Sun's Java 2 SDK

VisisBroker for Java A popular Java ORB from Inprise Corporation. VisiBroker is also embedded in other products

OrbixWeb A popular Java ORB from Iona Technologies

WebSphere A popular application server with an ORB from IBM

Netscape Communicator has a version of VisiBroker embedded

in it Shareware ORBs Available from various websites

CORBA Products

Page 11: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Interface Definition Language (IDL)

• Used to specify an object interface, i.e. the contract between code using the object and the code implementing the object

• indicates the operations the object supports, but not how they are implemented – the implementation of a CORBA object is provided in

a standard programming language, such as the Java or C++

• clients only depend on the interface • IDL interfaces are programming language

neutral

Page 12: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Interface Definition Language(2)

• OMG IDL allows you to define the following :– Modularized object interfaces – Operations and attributes that an object

supports – Exceptions raised by an operation – Data types of an operation return value, its

parameters, and an object's attributes

Page 13: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

IDL Data Types

• Basic data types (long, short, string, float...)

• Constructed data types (struct, union, enum, sequence)

• Typed object references

• The any type, a dynamically typed value

Page 14: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Bindings

• IDL defines language bindings for many different programming languages– OMG has standardized on language bindings for: C, C++, Java,

Ada, COBOL, Smalltalk, Objective C, and Lisp

• Developers can choose the appropriate programming language for the object implementation and a possibly different programming language for the client.

• IDL declarations are compiled with an IDL compiler and converted to their associated representations in the target programming languages according to the standard language binding

Page 15: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

IDL Java C++

module package namespace

interface interface abstract class

operation method member function

attribute pair of methods pair of methods

exception exception exception

IDL to Java Bindings

Page 16: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

IDL Type Java Type

boolean boolean

char char

octet byte

short short

long int

long long long

float float

double double

string String

IDL to Java Data Type Mappings

Page 17: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

HelloWorld Example

Object ReferencesayHello Hello World!

Hello Client

Hello Servant sayHello

Hello Server

Stub

ORB

TCP/IP (network)

Skeleton

ORB

IIOP

Page 18: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Defining the Remote Interface

• create a file Hello.idl with the following content:

module HelloApp

{

interface Hello

{

string sayHello();

oneway void shutdown();

};

};

Page 19: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Mapping Hello.idl to Java

idlj -fall Hello.idl

• The tool idlj reads OMG IDL files and creates the required Java files.

• The idlj compiler defaults to generating only the client-side bindings. If you need both client-side bindings and server-side skeletons you must use the -fall option

• A directory called HelloApp has been created containing a number of files

Page 20: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Generated Files

• Hello.java – This interface contains the Java version of our IDL interface. – The Hello.java interface extends org.omg.CORBA.Object,

providing standard CORBA object functionality.

• HelloPOA.java – This abstract class is the stream-based server skeleton– provides basic CORBA functionality for the server– The server class, HelloServant, extends HelloPOA.

• _HelloStub.java – This class is the client stub, providing CORBA functionality for

the client.– Implements the Hello.java interface.

Page 21: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Generated Files

• HelloOperations.java – contains the methods sayHello() and shutdown(). – The IDL-to-Java mapping puts all of the operations defined on

the IDL interface into this file, which is shared by both the stubs and skeletons

• HelloHelper.java – This class provides auxiliary functionality.– responsible for reading and writing the data types to CORBA

streams

• HelloHolder.java

Page 22: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Developing the Server

• Create the servant class HelloImpl– implements of the Hello IDL interface; each Hello

instance is implemented by a HelloImpl instance• contains one method for each IDL operation, in this example,

the sayHello() and shutdown() methods

– it’s a subclass of HelloPOA, which is generated by the idlj compiler from the example IDL.

• Servant methods are just like ordinary Java methods; the extra code to deal with the ORB, with marshaling arguments and results, and so on, is provided by the skeleton

Page 23: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Portable Object Adapter (POA)

• Abstract layer between the wire and the skeleton

• responsible for– pull data from the wire– de-marshalling data– forward requests to skeletons

Page 24: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Naming Services

• The two options for Naming Services shipped with J2SE 1.5 are:

• orbd, which includes both a Transient Naming Service and a Persistent Naming Service.

• tnameserv - a Transient Naming Service.

The example uses orbd.

Page 25: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Developing the Client

• needs to look up the server

• obtain a reference of the object on which it makes remote method calls

• unaware the object is – remotely located

– written in a different language

– serviced by a different vendor ORB

Page 26: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

CORBA vs. RMI

• both frameworks for building distributed systems

• similar architectural principles

• CORBA supports components written in different programming languages

• RMI assumes client/server written in Java

• RMI easier to learn and use– code is smaller and simpler

– serialization makes it easier to maintain an application

• CORBA unlike RMI has no notion of distributed garbage collection

Page 27: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

Choosing CORBA vs. RMI

• Depends on how you can answer some questions– will the application need to communicate with

components that are NOT written in Java?

– would the extra CORBA infrastructure be useful?

– Will all future code that needs to communicate with the application always be written in Java?

Page 28: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

RMI/IIOP

• JRMP the native protocol of RMI is replaced with IIOP, the CORBA protocol

Page 29: CORBA Celsina Bignoli bignolic@smccd.net. Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.

RMI/IIOP Applications

• Steps1. Remote interface like in RMI

• extends Remote

• methods throw RemoteException

2. Server extends PortableRemoteObject instead of UnicatsRemoteObject

3. stubs and scheleton are generated using rmic with the –iiop flag

4. CORBA naming service used instead of RMI registry

5. IDL can be generated from Step 1 and used to develop non-Java components