Download presentation
Presentation is loading. Please wait.
Published byMargaretMargaret Mason Modified over 9 years ago
1
Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction
2
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
3
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)
4
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
5
Slide 5 The Specifications CORBA is a collection of specifications http://www.omg.org/technology/documents/corba_spec_catal og.htmhttp://www.omg.org/technology/documents/corba_spec_catal og.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
6
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)
7
Slide 7 Application Objects CORBA Facilities CORBA Services (mandatory) Domain Interfaces Object Management Architecture (OMA) Object Request Broker
8
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
9
Slide 9 One standardised interface One interface per object operation ORB-dependent interface One interface per object adapter Dynamic Invocation Client Stubs ORB Interface Implementation Skeletons Client Object Implementation ORB Core Object Adapter CORBA Architecture 2
10
Slide 10 CORBA 2.0 Applications GIOP ESIOP IIOPDOETalk........ DCE-CIOP........ Mandatory: provides "out of the box" interoperability Interoperability Protocols Environment Specific.. IIOP: Internet Inter-ORB Protocol is the primary CORBA transport protocol
11
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
12
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
13
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
14
Slide 14 Heterogeneous OO Network CORBA C++ Client App.3 CORBA C# Client App.2 CORBA Java Client App.1 TCP/IP Network CORBA Cobol Database Server DB “Object Wrapping of non OO application” Different ORB’s from different vendors, on different operating systems – and written in different languages = Heterogenity
15
Slide 15 PL 6 2 5 1 4 3 6 2 5 1 4 3 IDL CORBA IDL & Mappings Avoid multiple mappings
16
Slide 16 IDL Common Object Model Smalltalk Cobol Java Ada-95 C++ C C CORBA Programming Language Bindings.NET Janeva / Middcor (C#) /.NET REMoting
17
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
18
Slide 18 Example UML to IDL mapping Player -name:string -Number:int +book() Team -name:string +bookGoalies() plays in 111..16 +transfer(p:Player) Club -noOfMembers:int -location:Address has 1 * uses Organization #name:string coaches 1..* Trainer -name:string 11..* +train() works for
19
Slide 19 Constructed types CORBA Object Model: Types typedef struct Address { string street; string postcode; string city; }; typedef sequence AddressList; interface Team {... }; Atomic types Object type
20
Slide 20 CORBA Object Model: Modules module Soccer { typedef struct Address { string street; string postcode; string city; }; module People { typedef struct Address { string flat_number; string street; string postcode; string city; string country; }; Modules = namespaces Soccer::Address People::Address
21
Slide 21 CORBA Object Model: Attributes interface Player; typedef sequence PlayerList; interface Trainer; typedef sequence TrainerList; interface Team { readonly attribute string name; attribute TrainerList coached_by; attribute Club belongs_to; attribute PlayerList players;... }; Attribute typeAttribute name changeable Clients cannot change value
22
Slide 22 CORBA Object Model: Operations interface Team {... void bookGoalies(in Date d); string print(); }; Parameter list Parameter kind Parameter type Parameter name Operation name used in requests Return types
23
Slide 23 CORBA Object Model: Exceptions Generic Exceptions (e.g. network down, invalid object reference, out of memory) Type-specific Exceptions exception PlayerBooked{sequence free;}; interface Team { void bookGoalies(in Date d) raises(PlayerBooked); }; Exception data Operations declare exceptions they raise Exception name
24
Slide 24 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
25
Slide 25 Legal Values in CORBA (Types)
26
Slide 26 Interface Definition Design Server Stub Generation Client Stub Generation Server Coding Client Coding Server Registration Development Steps – CORBA vs RMI & SOAP SOAP: WSDL Java2WSDL WSDL2JAVA AXIS SOAP RMI: rmic RMI: JAVA J2SE JDK Start with Server Interface Coding: JAVA Start with Server Interface Coding: JAVA rmiregistry CORBA CORBA: IDL ORB RMI: JAVA interface C++, Java …
27
Slide 27 C++ Compiler, Linker Server Client.cc Server.cc C++ Compiler, Linker Client Team.idl included in generates reads 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
28
Slide 28 Who’s doing what? Some code will get generated by the IDL compiler Some code we will need to implement ourselves Staring with the IDL file
29
Slide 29 IDL Interface of Hello Servant module HelloApp interface Hello { string sayHello(); };
30
Slide 30 IDL Compiler Example Java Hello.idl file Java IDL Compiler - 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
31
Slide 31 Extract from _HelloStub.java What are we looking at?
32
Slide 32 Extract from HelloHelper.java
33
Slide 33 Extract from HelloPOA
34
Slide 34 // 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) HelloServant The server object (Part 1) The CORBA operation implemented By extending from HelloPOA we may communicate with ORB Implemented manually
35
Slide 35 //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 ORB Start the orb server process The POA produces the reference 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 rootPOA
36
Slide 36 // 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);} } HelloClientSOR The Client program Init ORB Narrow the call (CORBA type cast + IDL type check) Object reference Read from file Object reference Read from file Call via Proxy Implemented manually
37
Slide 37 What is this object.ref file? IOR: Interoperable Object Reference Includes info on: Repository ID (standard), Endpoint Info (standard) - including IP and port number, Object Key (proprietary) Can be written into a file Not really nice with a file-based reference – or what? May employ a naming service instead This we shall look at later File-based may be necessary due to firewall problems Possible to use a HTTP or FTP server for distributing the references IOR:000000000000001749444c3 a48656c6c6f4170702f48656c6c6 f3a312e30000000000001000000 000000006c000102000000000e 3139322e3136382e312e313030 0011b600000021afabcb0000000 020a80a2503000000010000000 00000000000000004000000000 a0000000000000100000001000 00020000000000001000100000 00205010001000100200001010 90000000100010100
38
Slide 38 #include int run(CORBA::ORB_ptr); int main(int argc, char* argv[]) {int status = EXIT_SUCCESS; CORBA::ORB_var orb; try { orb = CORBA::ORB_init(argc, argv); status = run(orb); } catch (const CORBA::Exception&) { status = EXIT_FAILURE; } if(!CORBA::is_nil(orb)) { try { orb -> destroy(); } catch(const CORBA::Exception&) {status = EXIT_FAILURE; } } return status; } HelloCorba C++ Client Part 1 Init ORB Destroy ORB Call run method (see next slide) Implemented manually
39
Slide 39 … int run(CORBA::ORB_ptr orb) { const char* refFile = "object.ref"; ifstream in(refFile); char s[2048]; in >> s; CORBA::Object_var obj = orb -> string_to_object(s); HelloApp::Hello_var hello = HelloApp::Hello::_narrow(obj); cout sayHello() << endl; return 0; } HelloCorba C++ Client Part 2 Narrow the call (CORBA type cast) to the Hello_var smartpointer (helper + memory management) Narrow the call (CORBA type cast) to the Hello_var smartpointer (helper + memory management) Object reference Read from file Object reference Read from file Call method via Proxy and print result HelloApp::Hello_var smartpointer type Generated by IDL compiler + Hello
40
Slide 40 Alignment med læringsmål Når kurset er færdigt forventes den studerende at kunne: redegøre for de grundlæggende principper og teknikker omkring interproceskommunikation over såvel lokalnetværk som Internettet redegøre for teknikker for distribuerede objektorienterede løsninger, herunder serialisering, marshalling, stub/skeleton, proxy, brug af forskellige Interface Definition Language sprog som udviklingskontrakt redegøre for principperne omkring transparens og heterogenitet (platforms og programmeringssprogs uafhængighed) redegøre for anvendelsen af Java RMI, XML/SOAP (Webservices), herunder forskelle/ligheder, fordele/ulemper teknologierne imellem. Samt på overordnet niveau have kendskab til forskelle og ligheder med CORBA og.NET Remoting teknologierne anvende socket programmering til at lave et mindre distribueret system baseret på objektorienterede principper anvende objektorienterede teknikker og arkitekturer til at designe og programmere netværksforbindelser ved brug af middleware, og bevise dette ved at konstruere og dokumentere to distribuerede systemer der gør brug af ovenstående teknologier Hvornår vælge hvilken teknolog, der skal vælges Forstå at CORBA er binært, bruger IDL, IIOP, er heterogent har en ”pæn” objekt struktur. Også bruger stubs. Kunne genkende på koden at det er CORBA. Men ikke forstå koden i detaljer
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.