28
Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Embed Size (px)

Citation preview

Page 1: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 1

Objektorienteret Netværkskommunikation

CORBA Introduction

Page 2: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 2

Outline

• CORBA Introduction & Background• Architecture

• Session & Presentation layer

• GIOP / IIOP / CDR• CORBA Interface Definition Language – IDL

• Language mappings

• CORBA development steps

• Code Examples in Java / C++

• Alignment

Page 3: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 3

Who is the OMG?• OMG: Object Management Group

• http://www.omg.org

• Non-profit organization in the US

• Founded April 1989

• More than 800 members

• Dedicated to creating and popularizing object-oriented industry standards for application integration, e.g.• CORBA 1.0 (1995) –> CORBA 3.0.3 (2006)• UML 1.1 nov. 97. -> 2.1 (2006)

Page 4: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 4

Goal of CORBA• CORBA: Common Object Request Broker Architecture

• Support distributed and heterogeneous object request in a way transparent to users and application programmers

• Facilitate the integration of new components with legacy components

• Open standard that can be used free of charge

• Based on wide industry consensus • But not much Microsoft support

• Problem with CORBA• Considered too complex by many

Page 5: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 5

The Specifications

• CORBA is a collection of specifications• http

://www.omg.org/technology/documents/corba_spec_catalog.htm

• Common Object Request Broker Architecture (CORBA/IIOP) (3.0.3)

• CORBA Component Model (CCM) (3.0)• Light Weight CCM• CORBA/e (replaces Minimum CORBA)• Minimum CORBA (1.0)• Real-Time CORBA (Dynamic Scheduling) (2.0)• Real-Time CORBA (Static Scheduling) (1.1)• Others

Page 6: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 6

Families of specifications:

• CORBAservices Specifications • CORBAfacilities Specifications • OMG Domain Specifications • IDL / Language Mapping Specifications • Many others• Realted to UML

• UML Profile for CORBA (1.0)

Page 7: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 7

ApplicationObjects

CORBAFacilities

CORBA Services(mandatory)

DomainInterfaces

Object Management Architecture (OMA)

Object Request Broker

Page 8: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 8

CORBA Architecture1• Many different vendors and ORB types• Many of which do not interoperate• Must check specification• OrbBacus from IONA produces both C++ and Java• Sun J2SE SDK has only Java-based ORB• C++ ORB from IONA will work with SUN ORB as specified• Many others

• MicoORB, Middcor, TAO, openORB, VisiBroker

Page 9: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 9

One standardised interface

One interface per object operation

ORB-dependent interfaceOne interface per object adapter

DynamicInvocation

ClientStubs

ORBInterface

Implementation Skeletons

Client Object Implementation

ORB Core

ObjectAdapter

CORBA Architecture 2

Page 10: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 10

CORBA 2.0

Applications

GIOP ESIOP

IIOP DOETalk ........ DCE-CIOP ........

Mandatory: provides "out of the box" interoperability

Interoperability Protocols

EnvironmentSpecific ..

IIOP: Internet Inter-ORB Protocol is the primary CORBA transport protocol

Page 11: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 11

General Inter-ORB Protocol

• GIOP: Handles the session & presentation layer

• Defines seven message primitives:• Request, Reply, Locate Request, Locate Reply, Cancel

request, Close Connection, Message Error• Binary formatted• More simple than JRMP for Java RMI

• Internet Inter-ORB Protocol (IIOP)

• Maps GIOP to TCP/IP• Provides operations to open and close TCP/IP connections• Is required from ORBs for CORBA compliance• But intra vendor ORB com is not restricted to this

More on the IIOP in TIOOMI if wanted

Page 12: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 12

Common Data Representation (CDR)

• Defined as part of GIOP• Presentation layer implementation to support

heterogeneity• Mapping of IDL data types to transport byte stream• Encodings of

• primitive types

• constructed types

• interoperable object references

Page 13: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 13

Recap - motivation for an IDL

• IDL: Interface Definition Language • Components of distributed systems are written in

different programming languages• Programming languages may or may not have their

own object model• Object models largely vary• Differences need to be overcome in order to facilitate

integration

Page 14: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 14

Heterogeneous OO Network

CORBAC++

ClientApp.3

CORBAC#

ClientApp.2

CORBAJavaClientApp.1

TCP/IPNetwork

CORBACobol

DatabaseServer

DB

“Object Wrapping

of nonOO application”

Different ORB’s from different vendors, on different operating systems – and written in different languages = Heterogenity

Page 15: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 15

PL6

PL2

PL5

PL1

PL4

PL3 PL6

PL2

PL5

PL1

PL4

PL3IDL

CORBA IDL & Mappings

Avoid multiple mappings

Page 16: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 16

IDLCommon

ObjectModel

SmalltalkSmalltalk

CobolCobol

JavaJava

Ada-95Ada-95C++C++

CC

CORBA Programming Language Bindings

.NET.NETJaneva / Middcor (C#) / .NET REMotingJaneva / Middcor (C#) / .NET REMoting

Page 17: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 17

Interface Definition Language

• Akronym: IDL• Language for expressing all concepts of the

middleware’s object model• Should be

• programming-language independent

• not computationally complete

• Bindings to different programming languages are needed • language bindings are specified by CORBA

Page 18: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 18

CORBA Object Model: Subtypes

interface Organization { readonly attribute string name; };interface Club : Organization { exception NotInClub{}; readonly attribute short noOfMembers; readonly attribute Address location; attribute TeamList teams; attribute TrainerList trainers; void transfer(in Player p) raises NotInClub; };

Inherited by Club

Supertype

Implicit supertype: Object

This has only been a minimal presentation of the IDL

Page 19: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 19

InterfaceDefinition

Design

Server StubGeneration

Client StubGeneration

ServerCoding

ClientCoding

ServerRegistration

Development Steps – CORBA vs RMI & SOAP

SOAP: WSDLSOAP: WSDLJava2WSDLJava2WSDL

WSDL2JAVAWSDL2JAVA

AXISSOAPAXISSOAP

RMI: rmicRMI: rmic

RMI: JAVARMI: JAVA

J2SE JDKJ2SE JDK

Start with Server Interface Coding: JAVA

Start with Server Interface Coding: JAVA

rmiregistryrmiregistry

CORBACORBA

CORBA: IDLCORBA: IDL

CORBA: IDLCORBA: IDL

ORBORB

RMI: JAVA interfaceRMI: JAVA interface

C++, Java …C++, Java …

C++, Java …C++, Java …

Page 20: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 20

C++ Compiler, Linker

Server

Client.ccClient.cc Server.ccServer.cc

C++ Compiler, LinkerC++ Compiler, Linker

Client

Team.idlTeam.idl

included ingeneratesreads

IDL-Compiler

Teamcl.hh

Teamcl.cc Teamsv.cc

Teamsv.hh

CORBA Client and Server Implementation

Next we will look into a simple CORBA programming example

Page 21: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 21

IDL Interface of Hello Servant

module HelloApp

interface Hello{ string sayHello();};

Page 22: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 22

IDL Compiler Example Java

Hello.idlfile

Java IDLCompiler -

IDLJ

Hello.java (Both Client & Server)

contains the Java version of the IDL interface.

HelloOperations.java

contains the methods – here only sayHello(). All the operations in the IDL interface are placed in the operations file.

_HelloStub.java

is the client stub.

HelloPOA.java

is the skeleton class you should extend from. It implements dynamic invocation functions.

HelloHelper.java (Both Client & Server)

provides auxiliary functionality, notably the narrow() method required to cast CORBA object references to their proper types.

HelloHolder.java

Whenever the IDL type is an out or an inout parameter, the Holder class is used.

Generates

Input

What gets generated

by the IDL Compiler

Page 23: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 23

Extract from _HelloStub.java

What are we looking at?

Page 24: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 24

Extract from HelloHelper.java

Page 25: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 25

Extract from HelloPOA

Page 26: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 26

// HelloServer.java, stringified object reference version

// Stefan Wagner, 2003

import org.omg.CosNaming.*;

import org.omg.CosNaming.NamingContextPackage.*;

import org.omg.CORBA.*;

import org.omg.PortableServer.*;

import org.omg.PortableServer.POA;

import HelloApp.*;

//This is the servant - implementing the methods from the IDL

class HelloServant extends HelloPOA

{

private ORB orb;

public HelloServant(ORB orb) {

this.orb = orb;

}

public String sayHello()

{

return "\nHello world !!\n";

}

}

Constructor taking ORB as a parameter (from HelloPOA)Constructor taking ORB as a parameter (from HelloPOA)

HelloServant The server object(Part 1)

The CORBA operation implementedThe CORBA operation implemented

By extending from HelloPOA we may communicate with ORB By extending from HelloPOA we may communicate with ORB

Implemented manually

Page 27: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 27

//This is the HelloServer - the server running the HelloServant - Servant

public class HelloServer {

public static void main(String args[])

{

try{ // create and initialize the ORB

org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

// create servant and register it with the ORB

HelloServant helloRef = new HelloServant(orb);

// get reference to rootpoa and activate the POAManager

POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

rootpoa.the_POAManager().activate();

// get object reference from the servant

org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloRef);

Hello href = HelloHelper.narrow(ref);

// stringify the helloRef and dump it in a file

String oir = orb.object_to_string(href);

java.io.PrintWriter out = new java.io.PrintWriter(new java.io.FileOutputStream("object.ref"));

out.println(oir);

out.close();

// wait for invocations from clients

orb.run();

} catch (Exception e) { System.err.println("ERROR: " + e); e.printStackTrace(System.out); } }

}

HelloServant The server object(Part 2)

Init ORB and register servant with ORBInit ORB and register servant with ORB

Start the orb server processStart the orb server process

The POA produces the referenceThe POA produces the reference

Narrow the call (CORBA type cast + IDL type check)Narrow the call (CORBA type cast + IDL type check)

Object reference ”stringified” and

Sent to file object.ref

Object reference ”stringified” and

Sent to file object.ref

Activate rootPOAActivate rootPOA

Page 28: Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction

Slide 28

// HelloClientSOR.java, stringified object reference version

import java.io.*;

import org.omg.CORBA.*;

import HelloApp.HelloHelper;

import HelloApp.*;

public class HelloClientSOR

{

public static void main(String args[])

{

try {

// create and initialize the ORB

org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

// Get the stringified object reference and destringify it.

java.io.BufferedReader in = new java.io.BufferedReader(new java.io.FileReader("object.ref"));

String ref = in.readLine();

org.omg.CORBA.Object obj = orb.string_to_object(ref) ;

Hello helloRef = HelloHelper.narrow(obj);

// call the Hello server object and print results

String Hello = helloRef.sayHello();

System.out.println(Hello);

} catch (Exception e) { System.out.println("ERROR : " + e) ; e.printStackTrace(System.out); }

}

}

HelloClientSORThe Client program

Init ORBInit ORB

Narrow the call (CORBA type cast + IDL type check)Narrow the call (CORBA type cast + IDL type check)

Object reference Read from file

Object reference Read from file

Call via ProxyCall via Proxy

Implemented manually