© Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM...

51
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
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    0

Transcript of © Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM...

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

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

Distributed Systems

Topic 5: CORBA, COM and Java/RMI

Dr. Michael R. LyuComputer Science & Engineering Department

The Chinese University

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

© 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

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

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

CORBA

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

© 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

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

© 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

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

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

Application ObjectsApplication Objects

CORBAfacilitiesCORBAfacilities

CORBAservicesCORBAservices

DomainInterfacesDomain

Interfaces

Object Request BrokerObject Request Broker

1.1 Object Management Architecture

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

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

1.1 Object Model and Interface Definition

• Objects

• Types

• Modules

• Attributes

• Operations

• Requests

• Exceptions

• Subtypes

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

© 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

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

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

1.2 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 forworks for

1 1..*usesuses

plays in

1 11..16

has1

*

+train()

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

© 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

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

© 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<Address> AddressList;

interface Team { ... };

Atomic typesAtomic types

Object typeObject type

Constructed typesConstructed types

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

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

ModulesModulesSoccer::AddressSoccer::Address

People::AddressPeople::Address

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

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

1.3 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;

...

};

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 typeAttribute type Attribute nameAttribute name

changeablechangeable

Clients cannotchange valueClients cannotchange value

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

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

1.3 CORBA Object Model: Operations

interface Team {

...

void bookGoalies(in Date d);

string print();

};

Parameter listParameter list

Parameter kindParameter kind

Parameter typeParameter type

Parameter nameParameter nameOperation nameused in requestsOperation nameused in requests

Return typesReturn types

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

© 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

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

© 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<Date> free;}; interface Team { ... void bookGoalies(in Date d) raises(PlayerBooked); };

exception PlayerBooked{sequence<Date> free;}; interface Team { ... void bookGoalies(in Date d) raises(PlayerBooked); };

Exception dataException data

Operations declareexceptions they raiseOperations declareexceptions they raise

Exception nameException name

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

© 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 ClubInherited by Club

SupertypeSupertype

Implicit supertype:ObjectImplicit supertype:Object

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

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

One standardised interface

One interface per object operation

ORB-dependent interfaceOne interface per object adapter

DynamicInvocation DynamicInvocation

ClientStubsClientStubs

ORBInterface ORBInterface

Implementation SkeletonsImplementation Skeletons

ClientClient Object ImplementationObject Implementation

ORB CoreORB Core

ObjectAdapter ObjectAdapter

1.4 Architecture

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

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

COM

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

© 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

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

© 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

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

© 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

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

© 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 {

...

};

UUIDUUID

InterfacesInterfaces

Interface InheritanceInterface Inheritance

Root InterfaceRoot Interface

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

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

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

© 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

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

© 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

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

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

implementsimplements

1..*1..*

1..*1..*

InterfaceInterface

uuid : GUIDuuid : GUID

implementsimplements

instantiatesinstantiates 0..*0..*

11

ImplementationImplementation

1..*1..*

instantiatesinstantiates

1111

ClassClass

clsid : GUIDclsid : GUID

1..*1..*

0..*0..*

ObjectObject

location : intlocation : int

0..*0..*

11

creates&locatescreates&locates

ClassObjectClassObject

1111

0..*0..*

2.3 COM Objects, Interfaces and Classes

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

© 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);};

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

© 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 nameOperation name

Parameter listParameter listParameter kindParameter kind

Return value indicating success/failureReturn value indicating success/failure

Parameter, e.g.Interface pointerParameter, e.g.Interface pointer

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

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

3131 30-2930-29 28-1628-16 15-015-0

2.4 COM: HRESULTS

• HRESULTS are 32-bit integers

• Structured into four fields

SeverityCode

SeverityCode ReservedReserved

FacilityCode

FacilityCode

InformationCode

InformationCode

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

© 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!

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

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

2.4 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 33: © Chinese University, CSE Dept. Distributed Systems / 5 - 1 Distributed Systems Topic 5: CORBA, COM and Java/RMI Dr. Michael R. Lyu Computer Science &

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

2.5 Architecture

ObjectObjectProxyProxy

COMCOMLibraryLibraryInterfaceInterface

proxyproxy

ClientClient

ObjectObjectstubstub

COMCOMLibraryLibraryInterfaceInterface

stubstub

SCMSCM

RegistryRegistry

SCMSCM

RegistryRegistry

OXIDOXIDResolverResolver

OXIDOXIDResolverResolver

Microsoft Microsoft RPCsRPCsOXIDOXIDObjectObject

ApplicationApplicationLayerLayer

PresentationPresentationLayerLayer

SessionSessionLayerLayer

ServerServer

ImplementationImplementation

COM ClassCOM Class

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

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

Java/RMI

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

© 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

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

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

3.2 Java Object Model

• Interfaces and Remote Objects

• Classes

• Attributes

• Operations

• Exceptions

• Inheritance

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

© 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

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

© 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 operationsRemote operations

Interface nameInterface name

Declare it as remoteDeclare it as remote

Package namePackage name

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

© 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

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

© 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 accessibleClub makes name() remotely accessible

Club can return an address objectClub can return an address object

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

© 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 valueclass 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)

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

© 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 ExceptionType-specific Exception

Operation declares that it may raise itOperation declares that it may raise it

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

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

3.5 Architecture

ServerServerClientClient

StubStub RegistryRegistryInterfacesInterfaces

SkeletonSkeleton ActivationActivationInterfacesInterfaces

RMI Runtime (RMI Runtime ( rmicrmic , rmiregistry, rmiregistry ) )

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

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

3.5 Activation in Java

Client Host

StubFaultingReference

Liveref

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 VM 1 Java VM 2

AG1 AG2

1: activate

2: create objectin VM

3: passobject ref

4: updatelive ref

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

© 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

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

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

5. Summary

• CORBA

• COM

• Java/RMI

• Key points

• Appendix (.NET)

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

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

A.1 XML 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.

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

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

A.2 SOAP

• 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:Envelopexmlns:env="http://www.w3.org/2001/12/soap-envelope"> <env:Body> <ns:Order xmlns:ns="urn:cse.cuhk.edu.hk:Students"> <item>Bill</item> <item>Bob</item> <item>Tony</item> </ns:Students> </env:Body></env:Envelope>

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

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

A.3 WSDL

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

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

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

WSDL

<?xml version="1.0" encoding="utf-8" ?> <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/"> <types> <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> <s:element name="Add"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="A" type="s:float" /> <s:element minOccurs="1" maxOccurs="1" name="B" type="s:float" /> </s:sequence> </s:complexType> </s:element> <s:element name="AddResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:float" /> </s:sequence> </s:complexType> </s:element> </types> <message name="AddSoapIn"> <part name="parameters" element="s0:Add" /> </message> <message name="AddSoapOut"> <part name="parameters" element="s0:AddResponse" /> </message> ...

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

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

A.4 UDDI

• 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.