430 likes | 613 Views
CS551 Object Oriented Middleware (II) (Chap. 4 of EDO). Yugi Lee STB #555 (816) 235-5932 yugi@umkc.edu www.sice.umkc.edu/~leeyu. Outline. CORBA CORBA Object Model CORBA Interface Definition Language (IDL) CORBA Architecture COM Common Object Model Microsoft IDL COM Architecture RMI
E N D
CS551 Object Oriented Middleware (II)(Chap. 4 of EDO) Yugi Lee STB #555 (816) 235-5932 yugi@umkc.edu www.sice.umkc.edu/~leeyu 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 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 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 CS551 - Lecture 10
Object Management Architecture Application Objects Domain Interfaces CORBA facilities Object Request Broker CORBAservices CS551 - Lecture 10
Object Model and Interface Definition • Objects • Types • Modules • Attributes • Operations • Requests • Exceptions • Subtypes 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 CS551 - Lecture 10
Organization #name:string Trainer Club uses -name:string -noOfMembers:int -location:Address 1 1..* works for +transfer(p:Player) 1 1..* has coaches 1..* * Team plays in -name:string 1 11..16 +bookGoalies() Running Example +train() Player -name:string -Number:int +book() 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 CS551 - Lecture 10
Constructed types Atomic types Object type CORBA Object Model: Types typedef struct _Address { string street; string postcode; string city; } Address; typedef sequence<Address> AddressList; interface Team { ... }; CS551 - Lecture 10
Modules Soccer::Address People::Address 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; }; CS551 - Lecture 10
Clients cannot change value changeable Attribute type Attribute name CORBA Object Model: Attributes interface 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; ... }; CS551 - Lecture 10
Parameter list Parameter kind Return types Parameter type Parameter name Operation name used in requests CORBA Object Model: Operations interface Team { ... void bookGoalies(in Date d); string print(); }; 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 CS551 - Lecture 10
Exception data Exception name Operations declare exceptions they raise 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); }; CS551 - Lecture 10
Implicit supertype: Object Inherited by Club Supertype 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; }; CS551 - Lecture 10
Object Implementation Client Object Adapter Dynamic Invocation ORB Interface ORB Core CORBA Architecture Implementation Skeletons Client Stubs One standardised interface One interface per object operation One interface per object adapter ORB-dependent interface 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 CS551 - Lecture 10
Object Model and Interface Definition • Interfaces • Implementations and Objects • Classes • Attributes • Operations • Requests • HRESULTS • Inheritance 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 CS551 - Lecture 10
UUID Root Interface Interfaces Interface Inheritance COM Interfaces [object, uuid(1CF2B120-547D-101B-8E65-08002B2BD118)] interface IOrganization : IUnknown { ... }; [object, uuid(1CF2B120-547D-101B-8E65-08002B2BD116)] interface IClub : IOrganization { ... }; 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 }; 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 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 CS551 - Lecture 10
COM Objects, Interfaces and Classes Interface implements Implementation uuid : GUID 1..* 1..* 1 1 1..* 1..* instantiates 0..* 0..* Object location : int 0..* 0..* creates&locates implements Class ClassObject instantiates clsid : GUID CS551 - Lecture 10 1 1 1 1
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); }; CS551 - Lecture 10
Parameter kind Parameter list Parameter, e.g. Interface pointer Operation name 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); }; Return value indicating success/failure CS551 - Lecture 10
Severity Code Facility Code Information Code Reserved 31 30-29 15-0 28-16 COM: HRESULTS • HRESULTS are 32-bit integers • Structured into four fields 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! CS551 - Lecture 10
Three Implementations of Requests CS551 - Lecture 10
Server COM Class Client Application Implementation Layer Object COM Object COM Presentation Interface Interface Library Library Proxy stub Layer proxy stub SCM SCM Session Layer Registry Registry OXID Object Microsoft RPCs OXID OXID Resolver Resolver COM Architecture 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 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 CS551 - Lecture 10
Java Object Model • Interfaces and Remote Objects • Classes • Attributes • Operations • Exceptions • Inheritance 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 CS551 - Lecture 10
Declare it as remote Package name Interface name Remote operations 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; }; CS551 - Lecture 10
Attribute get operations Attributes • 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; ... }; CS551 - Lecture 10
Club can return an address object Club makes name() remotely accessible 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; }; CS551 - Lecture 10
returns a copy of the address! 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; ... }; CS551 - Lecture 10
Type-specific Exception Operation declares that it may raise it 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; ... }; CS551 - Lecture 10
JAVA (RMI) Architecture Client Server Registry Activation Stub Skeleton Interfaces Interfaces RMI Runtime ( rmid ,rmiregistry ) CS551 - Lecture 10
Activation in Java Java VM Stub Java VM 2 1 2: create object Faulting in VM Reference Live Activa- 3: pass ref tion ID object ref AG AG 1 2 Activator 1: activate Activation Descriptors: ActGroup ClassName URL Init AG Team www.bvb.de/… 1 AG Player www.bvb.de/… 2 AG Player www.bvb.de/… 2 4: update AG Player www.bvb.de/… 2 live ref Client Host Host www.bvb.de 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 CS551 - Lecture 10