Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS551 - Lecture 10 1 CS551 Object Oriented Middleware (II) (Chap. 4 of EDO) Yugi Lee STB #555 (816) 235-5932

Similar presentations


Presentation on theme: "CS551 - Lecture 10 1 CS551 Object Oriented Middleware (II) (Chap. 4 of EDO) Yugi Lee STB #555 (816) 235-5932"— Presentation transcript:

1 CS551 - Lecture 10 1 CS551 Object Oriented Middleware (II) (Chap. 4 of EDO) Yugi Lee STB #555 (816) 235-5932 yugi@umkc.edu www.sice.umkc.edu/~leeyu

2 2 CS551 - Lecture 10 Outline CORBA –CORBA Object Model –CORBA Interface Definition Language (IDL) –CORBA Architecture COM –Common Object Model –Microsoft IDL –COM Architecture RMI –Java (RMI) Object Model –Interface Definition in Java –RMI Architecture CORBA –CORBA Object Model –CORBA Interface Definition Language (IDL) –CORBA Architecture COM –Common Object Model –Microsoft IDL –COM Architecture RMI –Java (RMI) Object Model –Interface Definition in Java –RMI Architecture

3 3 CS551 - Lecture 10 Who is the Object Management Group (OMG)? Non-profit organization 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 Non-profit organization 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

4 4 CS551 - Lecture 10 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 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

5 5 CS551 - Lecture 10 Application Objects Application Objects CORBA facilities CORBA facilities CORBAservices Domain Interfaces Domain Interfaces Object Request Broker Object Management Architecture

6 6 CS551 - Lecture 10 Object Model and Interface Definition Objects Types Modules Attributes Operations Requests Exceptions Subtypes Objects Types Modules Attributes Operations Requests Exceptions Subtypes

7 7 CS551 - Lecture 10 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 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

8 8 CS551 - Lecture 10 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()

9 9 CS551 - Lecture 10 CORBA Object Model: Objects Each object has one identifier that is unique within an ORB (Object Request Broker) Multiple references to objects References support location transparency Object references are persistent Each object has one identifier that is unique within an ORB (Object Request Broker) Multiple references to objects References support location transparency Object references are persistent

10 10 CS551 - Lecture 10 CORBA Object Model: Types typedef struct _Address { string street; string postcode; string city; } Address; typedef sequence AddressList; interface Team {... }; 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

11 11 CS551 - Lecture 10 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

12 12 CS551 - Lecture 10 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

13 13 CS551 - Lecture 10 CORBA Object Model: Operations interface Team {... void bookGoalies(in Date d); string print(); }; 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

14 14 CS551 - Lecture 10 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 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

15 15 CS551 - Lecture 10 CORBA Object Model: Exceptions Generic Exceptions (e.g. network down, invalid object reference, out of memory) Type-specific 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

16 16 CS551 - Lecture 10 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

17 17 CS551 - Lecture 10 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 CORBA Architecture

18 18 CS551 - Lecture 10 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 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

19 19 CS551 - Lecture 10 Object Model and Interface Definition Interfaces Implementations and Objects Classes Attributes Operations Requests HRESULTS Inheritance Interfaces Implementations and Objects Classes Attributes Operations Requests HRESULTS Inheritance

20 20 CS551 - Lecture 10 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 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

21 21 CS551 - Lecture 10 COM Interfaces [object, uuid(1CF2B120-547D-101B-8E65-08002B2BD118)] interface IOrganization : IUnknown {... }; [object, uuid(1CF2B120-547D-101B-8E65-08002B2BD116)] interface IClub : IOrganization {... }; [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

22 22 CS551 - Lecture 10 COM Implementations Implement Interface in Prog. Lang., e.g. C++ #include "Soccer.h" class Player : public IPlayer { private: char* name; short Number; 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 book(); // IPlayer methods }; #include "Soccer.h" class Player : public IPlayer { private: char* name; short Number; 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 book(); // IPlayer methods };

23 23 CS551 - Lecture 10 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 Object references are persistent Instances of COM Implementations References to COM objects are called interface pointers Interface pointers refer to main memory locations References support location transparency Object references are persistent

24 24 CS551 - Lecture 10 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 Named implementations Have one or several interfaces Are the principal mechanism to create COM objects Can return interface pointers to specific COM objects

25 25 CS551 - Lecture 10 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..* COM Objects, Interfaces and Classes

26 26 CS551 - Lecture 10 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: 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); };

27 27 CS551 - Lecture 10 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

28 28 CS551 - Lecture 10 31 30-29 28-16 15-0 COM: HRESULTS HRESULTS are 32-bit integers Structured into four fields HRESULTS are 32-bit integers Structured into four fields Severity Code Severity Code Reserved Facility Code Facility Code Information Code Information Code

29 29 CS551 - Lecture 10 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! 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!

30 30 CS551 - Lecture 10 Three Implementations of Requests

31 31 CS551 - Lecture 10 COM 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

32 32 CS551 - Lecture 10 COM Architecture Application Layer: –Client object: has a pointer to an interface proxy –an implementation of the interface and a COM class (creating new instances of the implementation and locate these instances) Presentation Layer: (un)marshalling –(un)marshalling interface pointers and create an interface proxy for a requested interface (object proxy, object stub) –(un)marshalling and unmarshalling the parameters of all operations contained in the interface (interface proxy, interface stub) Session Layer: –object activation: SCM (Service Control Manager) –the mapping of interface pointers to RPC bindings and references of server objects for remote method invocation, OXID (Object Exporter Identifier) resolver

33 33 CS551 - Lecture 10 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 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

34 34 CS551 - Lecture 10 Java Object Model Interfaces and Remote Objects Classes Attributes Operations Exceptions Inheritance Interfaces and Remote Objects Classes Attributes Operations Exceptions Inheritance

35 35 CS551 - Lecture 10 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 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

36 36 CS551 - Lecture 10 Java Remote Interface Example package soccer; 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; 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

37 37 CS551 - Lecture 10 Attributes RMI does not attributes Attributes must be represented as set and get operations by the designer Example: RMI does not 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

38 38 CS551 - Lecture 10 Combining Classes and Remote Interfaces interface Organization { private: String name() 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 { private: String name() 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

39 39 CS551 - Lecture 10 Parameter Passing Atomic types are passed by value Remote objects are passed by reference Non-Remote objects are passed by value 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;... }; returns a copy of the address!

40 40 CS551 - Lecture 10 Exception Pre-Defined Exception RemoteException Type-Specific Exceptions Example: 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

41 41 CS551 - Lecture 10 JAVA (RMI) Architecture Server Client Stub Registry Interfaces Skeleton Activation Interfaces RMI Runtime ( rmid,rmiregistry ) )

42 42 CS551 - Lecture 10 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

43 43 CS551 - Lecture 10 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 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


Download ppt "CS551 - Lecture 10 1 CS551 Object Oriented Middleware (II) (Chap. 4 of EDO) Yugi Lee STB #555 (816) 235-5932"

Similar presentations


Ads by Google