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

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

Embed Size (px)

DESCRIPTION

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

Citation preview

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

CS551 - Lecture 101

CS551 Object Oriented Middleware (II) (Chap. 4 of EDO)

Yugi LeeSTB #555(816) [email protected]/~leeyu

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

2CS551 - 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

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

3CS551 - 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

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

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

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

5CS551 - Lecture 10

Application Objects

CORBAfacilities

CORBAservices

DomainInterfaces

Object Request Broker

Object Management Architecture

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

6CS551 - Lecture 10

Object Model and Interface Definition

• Objects• Types• Modules• Attributes• Operations• Requests• Exceptions• Subtypes

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

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

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

8CS551 - Lecture 10

Running Example

Team-name:string+bookGoalies()

coaches 1..*1..*

Player-name:string-Number:int+book()

+transfer(p:Player)

Club-noOfMembers:int-location:Address

Trainer-name:string

Organization#name:string

works for1 1..*

uses

plays in1 11..16

has1

*

+train()

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

9CS551 - 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

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

10CS551 - Lecture 10

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

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

11CS551 - 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;};

ModulesSoccer::Address

People::Address

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

12CS551 - Lecture 10

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; ... };

Attribute type Attribute name

changeable

Clients cannotchange value

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

13CS551 - Lecture 10

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

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

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

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

15CS551 - Lecture 10

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

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

16CS551 - 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; };

Inherited by Club

Supertype

Implicit supertype:Object

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

17CS551 - Lecture 10

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

CORBA Architecture

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

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

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

19CS551 - Lecture 10

Object Model and Interface Definition

• Interfaces• Implementations and Objects• Classes• Attributes• Operations• Requests• HRESULTS• Inheritance

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

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

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

21CS551 - Lecture 10

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

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

22CS551 - 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};

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

23CS551 - 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

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

24CS551 - 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

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

25CS551 - Lecture 10

implements

1..*

1..*

Interfaceuuid : GUID

implements

instantiates 0..*1

Implementation

1..*

instantiates

11

Classclsid : GUID

1..*

0..*

Objectlocation : int

0..*1

creates&locates

ClassObject

11

0..*

COM Objects, Interfaces and Classes

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

26CS551 - 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:interface IOrganization : IUnknown { [propget] HRESULT Name([out] BSTR val);};

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

27CS551 - 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);};

Operation name

Parameter listParameter kind

Return value indicating success/failure

Parameter, e.g.Interface pointer

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

28CS551 - Lecture 10

31 30-29 28-16 15-0

COM: HRESULTS

• HRESULTS are 32-bit integers• Structured into four fields

SeverityCode Reserved

FacilityCode

InformationCode

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

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

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

30CS551 - Lecture 10

Three Implementations of Requests

Inter-process call withlight-weight RPC

Method call

Client Object

Local Object inIn-Process DLL

Local Objectin EXE Server

Object onRemote Host

Remote call withreal RPC

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

31CS551 - Lecture 10

COM Architecture

ObjectProxy

COMLibraryInterface

proxy

Client

Objectstub

COMLibraryInterface

stub

SCMRegistry

SCMRegistry

OXIDResolver

OXIDResolver

Microsoft RPCsOXIDObject

ApplicationLayer

PresentationLayer

SessionLayer

Server

Implementation

COM Class

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

32CS551 - 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

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

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

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

34CS551 - Lecture 10

Java Object Model

• Interfaces and Remote Objects• Classes• Attributes• Operations• Exceptions• Inheritance

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

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

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

36CS551 - 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;};

Remote operations

Interface nameDeclare it as remote

Package name

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

37CS551 - Lecture 10

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; ...};

Attribute get operations

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

38CS551 - Lecture 10

Combining Classes and Remote Interfacesinterface 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 can return an address object

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

39CS551 - Lecture 10

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; ...};

returns a copy of the address!

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

40CS551 - Lecture 10

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; ...};

Type-specific Exception

Operation declares that it may raise it

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

41CS551 - Lecture 10

JAVA (RMI) Architecture

ServerClient

Stub RegistryInterfaces

Skeleton ActivationInterfaces

RMI Runtime (rmid,rmiregistry)

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

42CS551 - Lecture 10

Activation in Java

Client Host

StubFaultingReferenceLiveref

Host www.bvb.de

Activa-tion ID

ActivatorActivation Descriptors:ActGroup ClassName URL InitAG1 Team www.bvb.de/…AG2 Player www.bvb.de/…AG2 Player www.bvb.de/…AG2 Player www.bvb.de/…

Java VM1 Java VM2

AG1 AG2

1: activate

2: create objectin VM

3: passobject ref

4: updatelive ref

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

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