27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture)...

64
27 Maart 2006 Integratie van Software S ystemen 1 CORBA (Common Object Request Broker Architecture) René de Vries ([email protected]) Based on slides by M.L. Liu

Transcript of 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture)...

Page 1: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 1

CORBA(Common Object Request Broker Architecture)

René de Vries([email protected])

Based on slides by M.L. Liu

Page 2: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 2

Overview

• Introduction / context

• Genealogical of CORBA

• CORBA architecture

• CORBA related specifications

• Programming with JAVA IDL

• Conclusions

• References

Page 3: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 3

Means to handle distributed application development

• Abstraction (Object Orientation)

• Infrastructure (services and object request broker)

• Divide and Conquer (Corba Component model (CCM))

Solution:CORBA

Page 4: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 4

What is CORBA?• Acronym: Common Object Request Broker;• A middleware• Vendor-independent architecture;• Set of protocol definitions;• Standard architecture;• CORBA enables:

– distributed objects to interoperate in a heterogenous environment (transparancy)

– programming language independence– deployment on different platforms

Page 5: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 5

Who standardized CORBA?

• Developed by Object Management Group (OMG):– 800 members (Philips, HP, Sun) (no M$!)– Industrial consortium since 1989

• Goal:– Promotion of OO SE (UML), common

architectural framework, development of distributed OO SW applications.

Page 6: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 6

Genealogical• Message passing• Client-Server model• Remote Procedure Calls (RPC) 1980• Remote Method invocation (RMI) (Java/Sun)• Object Orientation

– Polymorphism (binding? / No overloading!)– Inheritance (interface level)

• ORB 1990• CORBA (release 1-3)

Page 7: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 7

Message Passing mechanism

 Message passing is the most fundamental paradigm for distributed applications.

• A process sends a message representing a request.

• The message is delivered to a receiver, which processes the request, and sends a message in response.

• In turn, the reply may trigger a further request, which leads to a subsequent reply, and so forth. -

Pro ce s s APro ce s s B

a m es s ag e

M e s s a g e pa s s in g

Page 8: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 8

Client-Server Model• The client-server model assigns asymmetric roles to two

collaborating processes.• The server waits passively for the arrival of requests. The other,

the client, issues specific requests to the server and awaits its response.  

• Examples (including message passing): FTP, HTTP etc.

...

s e rvic e re que s t

a s e rve r pro c e s s

a c l ie nt pro c e s s

a s e rvic e

The C l i e nt-Se r ve r P ar adi g m , c o nc e ptual

Se r ve r ho s t

C l i e nt ho s t

Page 9: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 9

Local Procedure Call and Remote Procedure Call

p r o c 1

e x e c u t i o n f l o w

p r o c 2

h o s t A

A l o c a l p r o c e d u r e c a l l

h o s t Ah o s t B

A r e m o t e p r o c e d u r e c a l l( t h e r e t u r n e x e c u t i o n p a t h i s n o t s h o w n )

p r o c 1p r o c 2

p r o x yp r o x y

1 . p r o c 1 o n h o s t A m a k e s a c a l l t o p r o c 2 o n h o s t B .2 . Th e r u n t i m e s u p p o r t m a p s t h e c a l l t o a c a l l t o t h e p r o x y o n h o s t A .3 . Th e p r o x y m a r s h a l l s t h e d a t a a n d m a k e s a n IP C c a l l t o a p r o x y o n h o s t B .

7 . Th e p r o x y r e c e i ve d t h e r e t u r n va l u e , u n m a r s h a l l s t h e d a t a , a n d f o r w a r d s t h e r e t u r n va l u e t o p r o c 1 , w h i c h r e s u m e s i t s e x e c u t i o n f l o w .

4 . Th e p r o x y o n h o s t Bu n m a r s h a l l s t h e d a t a

r e c e i ve d a n d i s s u e s a c a l l t o p r o c 2 .5 . Th e c o d e i n p r o c 2 i s e x e c u t e d a n d r e t u r n s t o t h e p r o x y o n h o s t B .6 . Th e p r o x y m a r s h a l l s t h e r e t u r n va l u e a n d m a k e s a n IP C c a l l t o t h e p r o x y o n h o s t A .

Page 10: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 10

Remote Procedure Model • Programmer point of view.• Remote Procedure Call (RPC) model interprocess

communications proceed as procedure, or function, calls.

p r o c 1 ( a r g 1 , a r g 2 )

Pro ce s s APro ce s s B

a r e m o t e p r o c e d u r e

retu rn va lu e

e x e c u t i o n f l o w

Page 11: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 11

Remote Procedure Call - 3• RPC allows programmers to build network applications

using a programming construct similar to the local procedure call, providing a convenient abstraction for both interprocess communication and event synchronization.

• Since its introduction in the early 1980s, the Remote Procedure Call model has been widely in use in network applications.

• There are two prevalent APIs for Remote Procedure Calls. – The Open Network Computing Remote Procedure Call,

evolved from the RPC API originated from Sun Microsystems in the early 1980s.

– The Open Group Distributed Computing Environment (DCE) RPC.

• Both APIs provide a tool, rpcgen, for transforming remote procedure calls to local procedure calls to the stub.

 

Page 12: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 12

Functioning of RPC

Client Stub•Bind•Marshal•Serialize•Send

ServerSkeleton•Unmarshal•Deserialize•Receive

Client Code Server Code

Client ProcessServer Process

Dispatcher

TransportModule

TransportModule

Page 13: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 13

Remote Method Invocation (RMI)

• Remote method invocation is the object-oriented equivalent of remote method calls.

• In this model, a process invokes the methods in an object, which may reside in a remote host.

• As with RPC, arguments may be passed with the invocation.

m e th o d1m e th o d2

P r o c e s s 1P r o c e s s 2

a re m o te o bje ct

The R e m o te M e tho d C al l P ar adi g m

re m o te m e th o d in v o ca t io n

Page 14: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 14

Do we need CORBA?

Page 15: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 15

CORBA vs. Java RMI

• CORBA differs from the architecture of Java RMI in one significant aspect: – RMI is a proprietary facility developed

by Sun MicroSystems, Inc., and supports objects written in the Java programming langugage only.

– CORBA is an architecture that was developed by the Object Management Group (OMG), an industrial consortium.

Page 16: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 16

Relating abstractions

network services object request broker

remote procedure call remote method invocation

client-server

message passing

level of abstraction

high

low

Page 17: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 17

CORBA

Architecture

Page 18: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 18

CORBA basic Architecture

o bje ct c lie n tn a m in g s e rv ice

n a m i n gl o o k u p

s tu b

O R B

n e two rk

o pe ra t in gs y s te m

o bje ctim ple m e n ta t io n

s k e le to n

O R B

n e two rk

o pe ra t in gs y s te m

lo g ica l da ta f lo w

ph y s ica l da ta f lo w

Page 19: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 19

CORBA Object References

• A CORBA distributed object is located using an object reference. Since CORBA is language-independent, a CORBA object reference is an abstract entity mapped to a language-specific object reference by an ORB, in a representation chosen by the developer of the ORB.

• For interoperability, OMG specifies a protocol for the abstract CORBA object reference object, known as the Interoperable Object Reference (IOR) protocol.

• Example of the string representation of an IOR [5]: IOR:000000000000000d49444c3a677269643a312e300000000000000001000000000000004c0001000000000015756c7472612e6475626c696e2e696f6e612e696500000963000000283a5c756c7472612e6475626c696e2e696f6e612e69653a677269643a303a3a49523a67726964003a

Page 20: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 20

Interoperable Object Reference (IOR)

An IOR is a string that contains encoding for the following information: – The type of the object. – The host where the object can be found. – The port number of the server for that object. – An object key, a string of bytes identifying the

object.

The object key is used by an object server to locate the object.

 

Page 21: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 21

Object Adapters

In the basic architecture of CORBA, the implementation of a distributed object interfaces with the skeleton to interact with the stub on the object client side. As the architecture evolved, a software component in addition to the skeleton was needed on the server side: an object adapter.

dis tribu te d o bje ctim ple m e n ta t io n

o bje ct a da pte r

O R B

Page 22: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 22

Object Adapter

• An object adapter simplifies the responsibilities of an ORB by assisting an ORB in delivering a client request to an object implementation (binding and polymorfism)

• When an ORB receives a client’s request, it locates the object adapter associated with the object and forwards the request to the adapter.

• The adapter interacts with the object implementation’s skeleton, which performs data marshalling and invoke the appropriate method in the object.

Page 23: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 23

The Portable Object Adapter

• There are different types of CORBA object adapters (BOA is deprecated)

• Portable Object Adapter, or POA, is a particular type of object adapter that allows an object implementation to function with different ORBs, hence the word portable.

• Support functionality:– Binding/mapping - Transparant activation– Persistency support - Object support functions

Page 24: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 24

CORBA IDL• A distributed object’s signature is defined using an interface definition file.• Since CORBA is language independent, the interface is defined using a

universal language with a distinct syntax, known as the CORBA Interface Definition Language (IDL).

• The syntax of CORBA IDL is similar to Java and C++. However, object defined in a CORBA IDL file can be implemented in a large number of diverse programming languages, including C, C++, Java, COBOL, Smalltalk, Ada, Lisp, Python, and IDLScript.

• IDL support inheritance and polymorfism.• For each of these languages, OMG has a standardized mapping from CORBA

IDL to the programming language, so that a compiler can be used to process a CORBA interface to generate the proxy files needed to interface with an object implementation or an object client written in any of the CORBA-compatible languages.

Page 25: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 25

The CORBA Interface file Hello.idl

01. module HelloApp

02. {

03. interface Hello

04. {

05. string sayHello();

06. oneway void shutdown();

07. };

08. };

Page 26: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 26

Cross-language CORBA application

o bje ct c lie n t writ t e n in J a v a

s tu b i n Java ge n e rate d by com pi l i n gth e C O R B A o b j e c t i n t e r f a c e

O R B writ t e n in J a v a

o bje ct im ple m e n ta t io n writ t e nin C + +

s k e le to n in C ++ g e n e r a t e d b yc o m p i l i n g t h e C O R B A o b j e c t

i n t e r f a c e

O R B writ t e n in C + +

ORB Core Feature Matrix

http://www.jetpen.com/~ben/corba/orbmatrix.html

Page 27: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 27

Inter-ORB Protocols

• To allow ORBs to be interoperable, the OMG specified a protocol known as the General Inter-ORB Protocol (GIOP), a specification which “provides a general framework for protocols to be built on top of specific transport layers.”

• A special case of the protocol is the Inter-ORB Protocol (IIOP), which is the GIOP applied to the TCP/IP transport layer.

OC C O

ORB 1 ORB 2

Stub Skel Stub Skel

GIOP

Page 28: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 28

Object Bus

An ORB which adheres to the specifications of the IIOP may interoperate with any other IIOP-compliant ORBs over the Internet. This gives rise to the term “object bus”, where the Internet is seen as a bus that interconnects

CORBA objects

Th e I n te rn e t

C O R B Ao bj e c t

C O R B Ao bj e c t

C O R B Ao bj e c t

O R B O R B O R B. . .

Page 29: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 29

Related Specifications

Page 30: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 30

CORBA Object Services (related specifications)

CORBA specify services commonly needed in distributed applications, some of which are: – Naming Service:– Concurrency Service: – Event Service: for event synchronization;– Logging Service: for event logging;– Scheduling Service: for event scheduling;– Security Service: for security management;– Trading Service: for locating a service by the type (instead of by name);– Time Service: a service for time-related events;– Notification Service: for events notification; – Object Transaction Service: for transactional processing.

Each service is defined in a standard IDL that can be implemented by a developer of the service object, and whose methods can be invoked by a CORBA client.

Page 31: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 31

CORBA Naming Service

• To export a distributed object, a CORBA object server contacts a Naming Service to bind a symbolic name to the object The Naming Service maintains a database of names and the objects associated with them.

• To obtain a reference to the object, an object client requests the Naming Service to look up the object associated with the name (This is known as resolving the object name.)

• The API for the Naming Service is specified in interfaces defined in IDL, and includes methods that allow servers to bind names to objects and clients to resolve those names.

Page 32: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 32

Naming Service(Binding Objects)

• A CORBA distributed object is exported by an object server.

• An object client retrieves a reference to a distributed object from a naming or directory service, to be described, and invokes the methods of the distributed object.

Page 33: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 33

CORBA Naming Service

To be as general as possible, the CORBA object naming scheme is necessary complex. Since the name space is universal, a standard naming hierarchy is defined in a manner similar to the naming hierarchy in a file

directory n a m in g co n te x t 1

n a m in g co n te x t 1 n a m in g co n te x t2

n a m in g co n te x t 1 n a m in g co n te x t 1

o bje ctn a m e 1

o bje ctn a m e n

......

. . .

...

Page 34: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 34

A Naming Context

• A naming context correspond to a folder or directory in a file hierarchy, while object names corresponds to a file.

• The full name of an object, including all the associated naming contexts, is known as a compound name. The first component of a compound name gives the name of a naming context, in which the second component is accessed. This process continues until the last component of the compound name has been reached.

• Naming contexts and name bindings are created using methods provided in the Naming Service interface.

Page 35: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 35

A CORBA object name

The syntax for an object name is as follows: <naming context > …<naming context><object name>

where the sequence of naming contexts leads to the object name.

Page 36: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 36

Example of a naming hierarchy

As shown, an object representing the men’s clothing department is named store.clothing.men, where store and clothing are naming contexts, and men is an object name.

s to r e

c lo th in g Ap p lian c es

w o m en m en

...te lev is io n

...

Page 37: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 37

Interoperable Naming Service

The Interoperable Naming Service (INS) is a URL-based naming system based on the CORBA Naming Service, it allows applications to share a common initial naming context and provide a URL to access a CORBA object.

Page 38: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 38

ORB products

There are a large number of proprietary as well as experimental ORBs available:(See CORBA Product Profiles, http://www.puder.org/corba/matrix/)– Orbix IONA– Borland Visibroker– PrismTech’s OpenFusion– Web Logic Enterprise from BEA – Ada Broker from ENST – Free ORBs (Orbit, OmniORB)

Page 39: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 39

The Java IDL (Java 1.4 version)

Page 40: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 40

Java IDL – Java’s CORBA Facility

• IDL is part of the Java 2 Platform, Standard Edition (J2SE).

• The Java IDL facility includes a CORBA Object Request Broker (ORB), an IDL-to-Java compiler, and a subset of CORBA standard services.

• In addition to the Java IDL, Java provides a number of CORBA-compliant facilities, including RMI over IIOP, which allows a CORBA application to be written using the RMI syntax and semantics.

Page 41: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 41

Key Java IDL Packages • package org.omg.CORBA – contains interfaces and

classes which provides the mapping of the OMG CORBA APIs to the Java programming language

• package org.omg.CosNaming - contains interfaces and classes which provides the naming service for Java IDL

• org.omg.CORBA.ORB - contains interfaces and classes which provides APIs for the Object Request Broker.

Page 42: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 42

Java IDL Tools

Java IDL provides a set of tools needed for developing a CORBA application: – idlj - the IDL-to-Java compiler (called idl2java in Java

1.2 and before)– orbd - a server process which provides Naming

Service and other services – servertool – provides a command-line interface for

application programmers to register/unregister an object, and startup/shutdown a server.

– tnameserv – an olderTransient Java IDL Naming Service whose use is now discouraged.

Page 43: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 43

A Java IDL application example

Page 44: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 44

The CORBA Interface file Hello.idl

01. module HelloApp

02. {

03. interface Hello

04. {

05. string sayHello();

06. oneway void shutdown();

07. };

08. };

Page 45: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 45

Compiling the IDL file (using Java 1.4)

The IDL file should be placed in a directory dedicated to the application. The file is compiled using the compiler idlj using a command as follows:

idlj -fall Hello.idl  The –fall command option is necessary for the compiler to generate all

the files needed.In general, the files can be found in a subdirectory named <some

name>App when an interface file named <some name>.idl is compiled.

If the compilation is successful, the following files can be found in a HelloApp subdirectory:

HelloOperations.java Hello.java HelloHelper.java HelloHolder.java

_HelloStub.java HelloPOA.javaThese files require no modifications.

Page 46: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 46

The *Operations.java file

• There is a file HelloOperations.java• found in HelloApp/ after you compiled using idlj• It is known as a Java operations interface in

general• It is a Java interface file that is equivalent to the

CORBA IDL interface file (Hello.idl)• You should look at this file to make sure that the

method signatures correspond to what you expect.

Page 47: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 47

HelloApp/HelloOperations.java

The file contains the methods specified in the original IDL file: in this case the methods sayHello( ) and shutdown().  

package HelloApp;01. package HelloApp;04. /**05. * HelloApp/HelloOperations.java06. * Generated by the IDL-to-Java compiler (portable),07. * version "3.1" from Hello.idl08. */09.10. public interface HelloOperations11. {12. String sayHello ();13. void shutdown ();14. } // interface HelloOperations

Page 48: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 48

HelloApp/Hello.java

The signature interface file combines the characteristics of the Java operations interface (HelloOperations.java) with the characteristics of the CORBA classes that it extends. 01. package HelloApp;03. /**04. * HelloApp/Hello.java05. * Generated by the IDL-to-Java compiler (portable),06. * version "3.1" from Hello.idl07. */09. public interface Hello extends HelloOperations,10. org.omg.CORBA.Object,11. org.omg.CORBA.portable.IDLEntity12. { …13. } // interface Hello

Page 49: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 49

HelloHelper.java, the Helper class

• The Java class HelloHelper (Figure 10.10) provides auxiliary functionality needed to support a CORBA object in the context of the Java language.

• In particular, a method, narrow,allows a CORBA object reference to be cast to its corresponding type in Java, so that a CORBA object may be operated on using syntax for Java object.

Page 50: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 50

HelloHolder.java, the Holder class

• The Java class called HelloHolder (Figure 10.11) holds (contains) a reference to an object that implements the Hello interface.

• The class is used to handle an out or an inout parameter in IDL in Java syntax ( In IDL, a parameter may be declared to be out if it is an output argument, and inout if the parameter contains an input value as well as carries an output value.)

Page 51: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 51

_HelloStub.java

• The Java class HelloStub (Figure 10.12) is the stub file, the client-side proxy, which interfaces with the client object.

• It extends org.omg.CORBA.portable.ObjectImpl and implements the Hello.java interface.

Page 52: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 52

HelloPOA.java, the server skeleton

• The Java class HelloImplPOA (Figure 10.13) is the skeleton, the server-side proxy, combined with the portable object adapter.

• It extends org.omg.PortableServer.Servant, and implements the InvokeHandler interface and the HelloOperations interface.

Page 53: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 53

The application

Server-side Classes

• On the server side, two classes need to be provided: the servant and the server.

• The servant, HelloImpl, is the implementation of the Hello IDL interface; each Hello object is an instantiation of this class.

Page 54: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 54

The Servant - HelloApp/HelloImpl.java

// The servant -- object implementation -- for the Hello// example. Note that this is a subclass of HelloPOA, // whose source file is generated from the// compilation of Hello.idl using j2idl.06. import HelloApp.*;07. import org.omg.CosNaming.*;08. import java.util.Properties; …15. class HelloImpl extends HelloPOA {16. private ORB orb;18. public void setORB(ORB orb_val) {19. orb = orb_val;20. }22. // implement sayHello() method23. public String sayHello() {24. return "\nHello world !!\n";25. }27. // implement shutdown() method28. public void shutdown() {29. orb.shutdown(false);30. }31. } //end class

Page 55: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 55

The server - HelloApp/HelloServer.java

public class HelloServer { public static void main(String args[]) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get reference to rootpoa & activate the POAManager POA rootpoa =

(POA)orb.resolve_initial_references("RootPOA"); rootpoa.the_POAManager().activate(); // create servant and register it with the ORB HelloImpl helloImpl = new HelloImpl(); helloImpl.setORB(orb); // get object reference from the servant org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl); // and cast the reference to a CORBA reference Hello href = HelloHelper.narrow(ref);

Page 56: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 56

HelloApp/HelloServer.java - continued

// get the root naming context// NameService invokes the transient name serviceorg.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");// Use NamingContextExt, which is part of the// Interoperable Naming Service (INS) specification.NamingContextExt ncRef =NamingContextExtHelper.narrow(objRef);// bind the Object Reference in NamingString name = "Hello";NameComponent path[] = ncRef.to_name( name );ncRef.rebind(path, href);System.out.println("HelloServer ready and waiting ...");// wait for invocations from clients orb.run();

Page 57: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 57

The object client application

• A client program can be a Java application, an applet, or a servlet.

• The client code is responsible for creating and initializing the ORB, looking up the object using the Interoperable Naming Service, invoking the narrow method of the Helper object to cast the object reference to a reference to a Hello object implementation, and invoking remote methods using the reference. The object’s sayHello method is invoked to receive a string, and the object’s shutdown method is invoked to deactivate the service.

Page 58: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 58

// A sample object client application.import HelloApp.*;

import org.omg.CosNaming.*; …public class HelloClient{ static Hello helloImpl; public static void main(String args[]){ try{ ORB orb = ORB.init(args, null); org.omg.CORBA.Object objRef =orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); helloImpl = HelloHelper.narrow(ncRef.resolve_str(“Hello”)); System.out.println(helloImpl.sayHello()); helloImpl.shutdown();

Page 59: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 59

Compiling and Running a Java IDL application

1. Create and compile the Hello.idl file on the server machine:

idlj -fall Hello.idl 2. Copy the directory containing Hello.idl (including the

subdirectory generated by idlj) to the client machine.

3. In the HelloApp directory on the client machine: create HelloClient.java. Compile the *.java files, including the stubs and skeletons (which are in the directory HelloApp):

javac *.java HelloApp/*.java

Page 60: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 60

Compiling and Running a Java IDL application

4. In the HelloApp directory on the server machine: – Create HelloServer.java. Compile the .java files:

javac *.java HelloApp/*.java – On the server machine: Start the Java Object Request Broker

Daemon, orbd, which includes a Naming Service.

To do this on Unix: orbd -ORBInitialPort 1050 -ORBInitialHost

servermachinename& 

To do this on Windows: start orbd -ORBInitialPort 1050 -ORBInitialHost

servermachinename

Page 61: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 61

Compiling and Running a Java IDL application

5. On the server machine, start the Hello server, as follows:

java HelloServer –ORBInitialHost <nameserver host name> -ORBInitialPort 1050 

6. On the client machine, run the Hello application client. From a DOS prompt or shell, type:

java HelloClient -ORBInitialHost nameserverhost -ORBInitialPort 1050all on one line.

Note that nameserverhost is the host on which the IDL name server is running. In this case, it is the server machine.

Page 62: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 62

Compiling and Running a Java IDL application

7. Kill or stop orbd when finished. The name server will continue to wait for invocations until it is explicitly stopped.

8. Stop the object server.

Page 63: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 63

Conclusions

• CORBA enables:– Interoperablility– Platform independence– Object Oriented distributed application

development– Widely supported

• CORBA is not new, just a next step

Page 64: 27 Maart 2006Integratie van Software Systemen1 CORBA (Common Object Request Broker Architecture) René de Vries (rgv@cs.ru.nl) Based on slides by M.L. Liu.

27 Maart 2006 Integratie van Software Systemen 64

References

• OMG (www.omg.org)• Brose, Vogel, Duddy

“Java Programming with CORBA”• Aloso,Casati, Kuno, Machiraju

“Web Services - Concepts, Architectures and Applications”

• Bolton“Pure CORBA”

• Liu“Distributed Computing - principles and applications”