View
46
Download
0
Category
Tags:
Preview:
DESCRIPTION
Objekt orienteret Netværkskommunikation. CORBA Introduction & CORBA Programming. Outline. CORBA (part one) Introduction Architecture CORBA Object Model CORBA Interface Definition Language - IDL CORBA programming (part two). Who is the OMG?. - PowerPoint PPT Presentation
Citation preview
Objekt orienteret Netværkskommunikation
CORBA Introduction & CORBA Programming
Slide 2 of 39 © Ingeniørhøjskolen i Århus
Outline
• CORBA (part one)– Introduction– Architecture– CORBA Object Model– CORBA Interface Definition Language - IDL
• CORBA programming (part two)
Slide 3 of 39 © Ingeniørhøjskolen i Århus
Who is the OMG?
• Non-profit organization in the US, representatives in United Kingdom, Germany, Japan, India, and Australia
• 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– UML, others
Slide 4 of 39 © Ingeniørhøjskolen i Århus
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
Slide 5 of 39 © Ingeniørhøjskolen i Århus
ApplicationObjects
CORBAFacilities
CORBA Services(mandatory)
DomainInterfaces
Object Management Architecture (OMA)
Object Request Broker
Slide 6 of 39 © Ingeniørhøjskolen i Århus
One standardised interfaceOne interface per object operation
ORB-dependent interfaceOne interface per object adapter
DynamicInvocation
ClientStubs
ORBInterface
Implementation Skeletons
Client Object Implementation
ORB Core
ObjectAdapter
Architecture
Slide 7 of 39 © Ingeniørhøjskolen i Århus
CORBA Clients and Servers
CORBAClientApp.2
CORBAClientApp.1
CORBAClientApp.1
PrimaryCORBAServer
BackupCORBAServer
TCP/IPNetwork
Slide 8 of 39 © Ingeniørhøjskolen i Århus
CORBA 2.0
Applications
GIOP ESIOP
IIOP DOETalk ........ DCE-CIOP ........
Mandatory: provides "out of the box" interoperability
Interoperability Protocols
EnvironmentSpecific ..
Slide 9 of 39 © Ingeniørhøjskolen i Århus
General Inter-ORB Protocol (GIOP)
• Define seven messages:– Request – Reply– Locate Request– Locate Reply– Cancel request– Close Connection– Message Error
Slide 10 of 39 © Ingeniørhøjskolen i Århus
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
Slide 11 of 39 © Ingeniørhøjskolen i Århus
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
Slide 12 of 39 © Ingeniørhøjskolen i Århus
Distributed Climate Control System
TCP/IPNetwork
CORBAC++
ClientApp.1
CORBAJavaClientApp.3
CORBAJava
ClimateControlServer
Thermo-meter
Thermo-stat
CORBAC#
ClientApp.2
Thermo-meter
Slide 13 of 39 © Ingeniørhøjskolen i Århus
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
Slide 14 of 39 © Ingeniørhøjskolen i Århus
PL6
PL2
PL5
PL1
PL4
PL3 PL6
PL2
PL5
PL1
PL4
PL3IDL
Why do we use an IDL?
Slide 15 of 39 © Ingeniørhøjskolen i Århus
IDLCommon
ObjectModel
Smalltalk
Cobol
Java
Ada-95C++
C
CORBA Programming Language Bindings
Slide 16 of 39 © Ingeniørhøjskolen i Århus
Heterogeneous OO Network
CORBAC++
ClientApp.3
CORBAC#
ClientApp.2
CORBAJavaClientApp.1
TCP/IPNetwork
CORBACobol
DatabaseServer
DB
“Object Wrapping
of non-OO-application”
Slide 17 of 39 © Ingeniørhøjskolen i Århus
Purpose of Common Object Model
• Meta-model for middleware’s type system • Defines meaning of e.g.
– object type– operation– attribute– request– exception– subtyping
• Defined general enough for mappings to most programming languages
Slide 18 of 39 © Ingeniørhøjskolen i Århus
Interface Definition Language (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
Slide 19 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Objects
• Each object has one identifier that is unique within an ORB
• Multiple references to objects• References support location transparency• Object references are persistent
Slide 20 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Types
typedef struct _Address { string street; string postcode; string city;} Address;typedef sequence<Address> AddressList;interface Team { ... };
Atomic types
Object type
Constructed types
Slide 21 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Modulesmodule Soccer { typedef struct _Address { string street; string postcode; string city; } Address;};module People { typedef struct _Address { string flat_number; string street; string postcode; string city; string country; } Address;};
ModulesSoccer::Address
People::Address
Slide 22 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Attributesinterface Player;typedef sequence<Player> PlayerList;interface Trainer;typedef sequence<Trainer> TrainerList;
interface Team { readonly attribute string name; attribute TrainerList coached_by; attribute Club belongs_to; attribute PlayerList players; ... };
Attribute type Attribute name
changeable
Clients cannotchange value
Slide 23 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Operations
interface Team { ... void bookGoalies(in Date d); string print(); };
Parameter list
Parameter kind
Parameter typeParameter nameOperation name
used in requests
Return types
Slide 24 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Requests
• Requests are defined by client objects• Request consist of
– Reference of server object– Name of requested operation– Actual request parameters– Context information
• Request is executed synchronously• Requests can be defined
– statically– dynamically
Slide 25 of 39 © Ingeniørhøjskolen i Århus
CORBA Object Model: Exceptions
• Generic Exceptions (e.g. network down, invalid object reference, out of memory)
• Type-specific Exceptions
exception PlayerBooked{sequence<Date> free;}; interface Team { void bookGoalies(in Date d) raises(PlayerBooked); };
Exception data
Operations declareexceptions they raise
Exception name
Slide 26 of 39 © Ingeniørhøjskolen i Århus
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
Slide 27 of 39 © Ingeniørhøjskolen i Århus
Local Proxy to Remote Object call
Client
Objectreference
foo()
Proxy
foo()
Server
Skeletoninstance
Servant
foo()foo()
Slide 28 of 39 © Ingeniørhøjskolen i Århus
General CORBA Application Development Steps
1. Determine your applications objects and define their interfaces in IDL
2. Compile your IDL definitions into Java stubs and skeletons
3. Declare and implement Java servant classes4. Write a server main program5. Compile and link your server implementations
files together with generated stubs and skeletons
6. Write, compile and link your client code together with the generated stubs
Slide 29 of 39 © Ingeniørhøjskolen i Århus
InterfaceDefinition
Design
Server StubGeneration
Client StubGeneration
ServerCoding
ClientCoding
ServerRegistration
Development Steps – CORBA vs RMI & SOAP
SOAP: WSDLJava2WSDL
WSDL2JAVA
AXISSOAP
RMI: rmic
RMI: JAVA
J2SE JDK
Start with Server Interface Coding: JAVA
rmiregistry
CORBA
CORBA: IDL
CORBA: IDL
ORB
RMI: JAVA interface
C++, Java …
C++, Java …
Slide 30 of 39 © Ingeniørhøjskolen i Århus
CORBA Programming:Presentation of a Simple
“Hello World”CORBA Client and Server Application
Slide 31 of 39 © Ingeniørhøjskolen i Århus
“Hello World” CORBA Example
Clientapp.
Serverapp.
Development PC
CORBAJava
Hello WorldClient
CORBAJava
Hello WorldServer
TCP/IPNetwor
k
User activa-
tes client
Server prints“Hello World !“
Slide 32 of 39 © Ingeniørhøjskolen i Århus
IDL Interface of Hello Servant
module HelloApp
interface Hello{ String sayHello();};
Slide 33 of 39 © Ingeniørhøjskolen i Århus
Overview
Slide 34 of 39 © Ingeniørhøjskolen i Århus
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 sayHello() and shutdown(). 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
Slide 35 of 39 © Ingeniørhøjskolen i Århus
// 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 a parameter
HelloServant The server object(Part 1)
The CORBA operation implemented
Slide 36 of 39 © Ingeniørhøjskolen i Århus
//This is the HelloServer - the server running the HelloServant - Servant
//This could have been placed in another file - but was not
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 it with ORB
Activate rootPOA
The POA produces the reference
Narrow the call (CORBA type cast)
Object reference ”stringified” and
Sent to file object.ref
Slide 37 of 39 © Ingeniørhøjskolen i Århus
// 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 ORB
Narrow the call (CORBA type cast)
Object reference Read from file
Call via Proxy
Slide 38 of 39 © Ingeniørhøjskolen i Århus
What is this?
• IOR: Interoperable Object Reference– Includes info on: Repository ID (standard),
Endpoint Info (standard) - including IP and port number, Object Key (proprietary)
• Not really nice with a file-based reference – or what?
• May employ a naming service instead– not part of this course
• File-based may be necessary due to firewall problems
• Possible to use a HTTP or FTP server for distributing the references
IOR:000000000000001749444c3a48656c6c6f4170702f48656c6c6f3a312e30000000000001000000000000006c000102000000000e3139322e3136382e312e3130300011b600000021afabcb0000000020a80a250300000001000000000000000000000004000000000a000000000000010000000100000020000000000001000100000002050100010001002000010
1090000000100010100
Recommended