Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM and Java/RMI Dr. Michael R. Lyu Computer Science &

Similar presentations


Presentation on theme: "© Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM and Java/RMI Dr. Michael R. Lyu Computer Science &"— Presentation transcript:

1 © Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM and Java/RMI Dr. Michael R. Lyu Computer Science & Engineering Department The Chinese University

2 © Chinese University, CSE Dept. Distributed Systems / 5 - 2 Outline CORBA –CORBA Object Model –CORBA Interface Definition Language –CORBA Architecture COM –Common Object Model –Microsoft IDL –COM Architecture RMI –Java (RMI) Object Model –Interface Definition in Java –RMI Architecture

3 © Chinese University, CSE Dept. Distributed Systems / 5 - 3 CORBA

4 © Chinese University, CSE Dept. Distributed Systems / 5 - 4 1.1 Who is the OMG? Non-profit organisation with HQ 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 –ODMG-93 –UML

5 © Chinese University, CSE Dept. Distributed Systems / 5 - 5 1.1 Goal of CORBA 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

6 © Chinese University, CSE Dept. Distributed Systems / 5 - 6 Application Objects Application Objects CORBA facilities CORBA facilities CORBAservices Domain Interfaces Domain Interfaces Object Request Broker 1.1 Object Management Architecture

7 © Chinese University, CSE Dept. Distributed Systems / 5 - 7 1.1 Object Model and Interface Definition Objects Types Modules Attributes Operations Requests Exceptions Subtypes

8 © Chinese University, CSE Dept. Distributed Systems / 5 - 8 1.2 OMG Interface Definition Language Language for expressing all concepts of the CORBA object model OMG/IDL is –programming-language independent –orientated towards C++ –not computationally complete Different programming language bindings are available Explanation of Model and Language by Example

9 © Chinese University, CSE Dept. Distributed Systems / 5 - 9 1.2 Running Example Team -name:string +bookGoalies() coaches 1..* Player -name:string -Number:int +book() +transfer(p:Player) Club -noOfMembers:int -location:Address Trainer -name:string Organization #name:string works for 11..* uses plays in 111..16 has 1 * +train()

10 © Chinese University, CSE Dept. Distributed Systems / 5 - 10 1.3 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

11 © Chinese University, CSE Dept. Distributed Systems / 5 - 11 1.3 CORBA Object Model: Types typedef struct _Address { string street; string postcode; string city; } Address; typedef sequence AddressList; interface Team {... }; Atomic types Atomic types Object type Object type Constructed types Constructed types

12 © Chinese University, CSE Dept. Distributed Systems / 5 - 12 1.3 CORBA Object Model: Modules module 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; }; module 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; }; Modules Soccer::Address People::Address

13 © Chinese University, CSE Dept. Distributed Systems / 5 - 13 1.3 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;... }; 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 type Attribute name changeable Clients cannot change value Clients cannot change value

14 © Chinese University, CSE Dept. Distributed Systems / 5 - 14 1.3 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 Operation name used in requests Return types

15 © Chinese University, CSE Dept. Distributed Systems / 5 - 15 1.3 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

16 © Chinese University, CSE Dept. Distributed Systems / 5 - 16 1.3 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 PlayerBooked{sequence free;}; interface Team {... void bookGoalies(in Date d) raises(PlayerBooked); }; Exception data Operations declare exceptions they raise Operations declare exceptions they raise Exception name

17 © Chinese University, CSE Dept. Distributed Systems / 5 - 17 1.3 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; }; 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 Implicit supertype: Object

18 © Chinese University, CSE Dept. Distributed Systems / 5 - 18 One standardised interface One interface per object operation ORB-dependent interface One interface per object adapter Dynamic Invocation Dynamic Invocation Client Stubs Client Stubs ORB Interface ORB Interface Implementation Skeletons Implementation Skeletons Client Object Implementation ORB Core Object Adapter Object Adapter 1.4 Architecture

19 © Chinese University, CSE Dept. Distributed Systems / 5 - 19 COM

20 © Chinese University, CSE Dept. Distributed Systems / 5 - 20 2.1 Goals of COM Provide a component object model that facilitates binary encapsulation and binary compatibility –Binary encapsulation: Clients do not have to be re- compiled if server objects change –Binary compatibility: Client and server objects can be developed with different development environments and in different languages COM is proprietary de-facto standard

21 © Chinese University, CSE Dept. Distributed Systems / 5 - 21 2.1 Object Model and Interface Definition Interfaces Implementations and Objects Classes Attributes Operations Requests HRESULTS Inheritance

22 © Chinese University, CSE Dept. Distributed Systems / 5 - 22 2.2 Microsoft IDL (MIDL) Language for expressing all COM concepts MIDL is –programming-language independent –evolved from OSF/RPC IDL –not computationally complete Different programming language bindings are available Explanation of Model and Language by same example

23 © Chinese University, CSE Dept. Distributed Systems / 5 - 23 2.3 COM Interfaces [object, uuid(1CF2B120-547D-101B-8E65-08002B2BD118)] interface IOrganization : IUnknown {... }; [object, uuid(1CF2B120-547D-101B-8E65-08002B2BD116)] interface IClub : IOrganization {... }; UUID Interfaces Interface Inheritance Root Interface

24 © Chinese University, CSE Dept. Distributed Systems / 5 - 24 2.3 COM Interface Implementations in C++ #include "Soccer.h" class TrainerPlayer : public Itrainer, public IPlayer { private: char* name; // name is the same in Itrainer & IPlayer short Number; //for IPlayer protected: virtual ˜TrainerPlayer(void); public: TrainerPlayer(void); IMPLEMENT_UNKNOWN(TrainerPlayer) BEGIN_INTERFACE_TABLE(TrainerPlayer) IMPLEMENTS_INTERFACE(ITrainer) IMPLEMENTS_INTERFACE(IPlayer) END_INTERFACE_TABLE(TrainerPlayer) void train(); // Itrainer method void book(); // IPlayer method };

25 © Chinese University, CSE Dept. Distributed Systems / 5 - 25 2.3 COM: Objects Instances of COM Implementations References to COM objects are called interface pointers Interface pointers refer to main memory locations References support location transparency The references are persistent COM allows logical identifiers to clash with each other, as the physical identifiers are uniquely generated

26 © Chinese University, CSE Dept. Distributed Systems / 5 - 26 2.3 COM Classes Named implementations Have one or several interfaces Are the principal mechanism to create COM objects Can return interface pointers to specific COM objects

27 © Chinese University, CSE Dept. Distributed Systems / 5 - 27 implements 1..* Interface uuid : GUID implements instantiates 0..* 1 1 Implementation 1..* instantiates 1 1 1 1 Class clsid : GUID 1..* 0..* Object location : int 0..* 1 1 creates&locates ClassObject 1 1 1 1 0..* 2.3 COM Objects, Interfaces and Classes

28 © Chinese University, CSE Dept. Distributed Systems / 5 - 28 2.4 COM: Attributes COM does support attributes Attributes must be represented as set and get operations by the designer COM has a keyword to designate this Example: interface IOrganization : IUnknown { [propget] HRESULT Name([out] BSTR val); }; interface IOrganization : IUnknown { [propget] HRESULT Name([out] BSTR val); };

29 © Chinese University, CSE Dept. Distributed Systems / 5 - 29 2.4 COM: Operations interface IClub : IOrganization { [propget] HRESULT NoOfMembers([out] short *val); [propget] HRESULT Address([out] ADDRESS *val); [propget] HRESULT Teams([in] long cMax, [out] long *pcAct, [out,size_is(cMax),length_is(*pcAct)] ITeam *val); [propput] HRESULT Teams([in] long cElems, [in,size_is(cElems)] ITeam *val); [propget] HRESULT Trainers([out] ITrainer *val[3]); [propput] HRESULT Trainers([in] ITrainer *val[3]); HRESULT transfer([in] IPlayer *p); }; interface IClub : IOrganization { [propget] HRESULT NoOfMembers([out] short *val); [propget] HRESULT Address([out] ADDRESS *val); [propget] HRESULT Teams([in] long cMax, [out] long *pcAct, [out,size_is(cMax),length_is(*pcAct)] ITeam *val); [propput] HRESULT Teams([in] long cElems, [in,size_is(cElems)] ITeam *val); [propget] HRESULT Trainers([out] ITrainer *val[3]); [propput] HRESULT Trainers([in] ITrainer *val[3]); HRESULT transfer([in] IPlayer *p); }; Operation name Parameter list Parameter kind Return value indicating success/failure Return value indicating success/failure Parameter, e.g. Interface pointer Parameter, e.g. Interface pointer

30 © Chinese University, CSE Dept. Distributed Systems / 5 - 30 31 30-29 28-16 15-0 2.4 COM: HRESULTS HRESULTS are 32-bit integers Structured into four fields Severity Code Severity Code Reserved Facility Code Facility Code Information Code Information Code

31 © Chinese University, CSE Dept. Distributed Systems / 5 - 31 2.4 COM Operation Invocations Invocation is defined by client objects Invocation determines –Interface pointer of server object –Name of invoked operation –Actual parameters Invocation is executed synchronously Invocation can be defined –statically –dynamically Clients have to interpret HRESULTS!

32 © Chinese University, CSE Dept. Distributed Systems / 5 - 32 2.4 Three Implementations of Requests Inter-process call with light-weight RPC Method call Client Object Local Object in In-Process DLL Local Object in EXE Server Object on Remote Host Remote callwith real RPC

33 © Chinese University, CSE Dept. Distributed Systems / 5 - 33 2.5 Architecture Object Proxy COM Library Interface proxy Client Object stub COM Library Interface stub SCM Registry SCM Registry OXID Resolver OXID Resolver Microsoft RPCs OXID Object Application Layer Presentation Layer Session Layer Server Implementation COM Class

34 © Chinese University, CSE Dept. Distributed Systems / 5 - 34 Java/RMI

35 © Chinese University, CSE Dept. Distributed Systems / 5 - 35 3.1 Goals of RMI In Java 1.0 object communication confined to objects in one Virtual Machine Remote Method Invocation (RMI) supports communication between different VMs, potentially across the network Provide tight integration with Java Minimize changes to Java language/VM Work in homogeneous environment

36 © Chinese University, CSE Dept. Distributed Systems / 5 - 36 3.2 Java Object Model Interfaces and Remote Objects Classes Attributes Operations Exceptions Inheritance

37 © Chinese University, CSE Dept. Distributed Systems / 5 - 37 3.3 Java Interfaces and Remote Objects Java already includes the concept of interfaces RMI does not have a separate interface definition language Pre-defined interface Remote Remote interfaces extend Remote Remote classes implement remote interfaces Remote objects are instances of remote classes

38 © Chinese University, CSE Dept. Distributed Systems / 5 - 38 3.3 Java Remote Interface Example package soccer; Import java.rmi.*; interface Team extends Remote { public: String name() throws RemoteException; Trainer[] coached_by() throws RemoteException; Club belongs_to() throws RemoteException; Players[] players() throws RemoteException; void bookGoalies(Date d) throws RemoteException; void print() throws RemoteException; }; package soccer; Import java.rmi.*; interface Team extends Remote { public: String name() throws RemoteException; Trainer[] coached_by() throws RemoteException; Club belongs_to() throws RemoteException; Players[] players() throws RemoteException; void bookGoalies(Date d) throws RemoteException; void print() throws RemoteException; }; Remote operations Interface name Declare it as remote Package name

39 © Chinese University, CSE Dept. Distributed Systems / 5 - 39 3.4 Attributes RMI does not define attributes Attributes must be represented as set and get operations by the designer Example: interface Club extends Organization, Remote { public: int noOfMembers() throws RemoteException; Address location() throws RemoteException; Team[] teams() throws RemoteException; Trainer[] trainers() throws RemoteException;... }; interface Club extends Organization, Remote { public: int noOfMembers() throws RemoteException; Address location() throws RemoteException; Team[] teams() throws RemoteException; Trainer[] trainers() throws RemoteException;... }; Attribute get operations

40 © Chinese University, CSE Dept. Distributed Systems / 5 - 40 3.4 Combining Classes and Remote Interfaces interface Organization { public: String name() throws RemoteException; }; class Address { public: String street; String postcode; String city; }; interface Club extends Organization, Remote { public: int noOfMembers() throws RemoteException; Address location() throws RemoteException; Team[] teams() throws RemoteException; Trainer[] trainers() throws RemoteException; void transfer(Player p) throws RemoteException; }; interface Organization { public: String name() throws RemoteException; }; class Address { public: String street; String postcode; String city; }; interface Club extends Organization, Remote { public: int noOfMembers() throws RemoteException; Address location() throws RemoteException; Team[] teams() throws RemoteException; Trainer[] trainers() throws RemoteException; void transfer(Player p) throws RemoteException; }; Club makes name() remotely accessible Club makes name() remotely accessible Club can return an address object

41 © Chinese University, CSE Dept. Distributed Systems / 5 - 41 3.4 Parameter Passing Atomic types are passed by value Remote objects are passed by reference Non-Remote objects are passed by value class Address { public: String street; String postcode; String city; }; interface Club extends Organization, Remote { public: Address location() throws RemoteException;... }; class Address { public: String street; String postcode; String city; }; interface Club extends Organization, Remote { public: Address location() throws RemoteException;... }; Parameter-passing of a non-remote object: returns a copy of the Address! (call by value) Parameter-passing of a non-remote object: returns a copy of the Address! (call by value)

42 © Chinese University, CSE Dept. Distributed Systems / 5 - 42 3.4 Exception Pre-Defined Exception RemoteException Type-Specific Exceptions Example: class PlayerBooked extends Exception {}; interface Team extends Remote { public:... void bookGoalies(Date d) throws RemoteException, PlayerBooked;... }; class PlayerBooked extends Exception {}; interface Team extends Remote { public:... void bookGoalies(Date d) throws RemoteException, PlayerBooked;... }; Type-specific Exception Operation declares that it may raise it

43 © Chinese University, CSE Dept. Distributed Systems / 5 - 43 3.5 Architecture Server Client Stub Registry Interfaces Skeleton Activation Interfaces RMI Runtime ( rmic, rmiregistry ) )

44 © Chinese University, CSE Dept. Distributed Systems / 5 - 44 3.5 Activation in Java Client Host Stub Faulting Reference Live ref Hostwww.bvb.de Activa- tion ID Activator Activation Descriptors: ActGroup ClassName URL Init AG 1 Teamwww.bvb.de/… AG 2 Playerwww.bvb.de/… AG 2 Playerwww.bvb.de/… AG 2 Playerwww.bvb.de/… Java VM 1 2 AG 1 2 1: activate 2: create object in VM 3: pass object ref 4: update live ref

45 © Chinese University, CSE Dept. Distributed Systems / 5 - 45 4. Key Points CORBA, COM and RMI –enable objects to request operation execution from server objects on remote hosts –identify server objects by object references –distinguish between interface and implementation –treat attributes as operations –provide mechanisms to deal with failures –have statically typed object models –compile stubs from their IDLs –support on-demand activation

46 © Chinese University, CSE Dept. Distributed Systems / 5 - 46 5. Summary CORBA COM Java/RMI Key points Appendix (.NET)

47 © Chinese University, CSE Dept. Distributed Systems / 5 - 47 A.1XML Web Service and.NET XML Web Service is a new solution towards distributed component interoperability. –SOAP –WSDL –UDDI The Microsoft.NET framework is a new platform environment integrated with Windows OS. This is Microsoft’s platform for enabling XML Web Services.

48 © Chinese University, CSE Dept. Distributed Systems / 5 - 48 A.2SOAP Simple Object Access Protocol Web services communicate using W3C standard SOAP messages. SOAP formalize the use of XML as a way to pass data (therefore can be Objects) from one process to another. SOAP can be encapsulated in HTTP <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> Bill Bob Tony

49 © Chinese University, CSE Dept. Distributed Systems / 5 - 49 A.3WSDL Web Services Description Language (WSDL often pronounced whiz-dull) is also a W3C standard. WSDL is an XML file for describing the web services provided. C# Implementation Example: public class MathService : WebService { [WebMethod] public float Add(float a, float b) { return a + b; }

50 © Chinese University, CSE Dept. Distributed Systems / 5 - 50 WSDL <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://tempuri.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://tempuri.org/" xmlns="http://schemas.xmlsoap.org/wsdl/">...

51 © Chinese University, CSE Dept. Distributed Systems / 5 - 51 A.4UDDI Universal Discovery Description and Integration UDDI is the name service for web services. A UDDI directory entry is an XML file that describe the organization offering the service. It provides searching capabilities on web services based on geographical locations and business types.


Download ppt "© Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM and Java/RMI Dr. Michael R. Lyu Computer Science &"

Similar presentations


Ads by Google