Title: CS551 Object Oriented Middleware (II) (Chap. 4 of EDO)
1CS551 Object Oriented Middleware (II) (Chap. 4
of EDO)
- Yugi Lee
- STB 555
- (816) 235-5932
- yugi_at_cstp.umkc.edu
- www.cstp.umkc.edu/yugi
2Outline
- 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
3Who is the 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
4Goal 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
5Object Management Architecture
Application Objects
CORBA facilities
Domain Interfaces
Object Request Broker
CORBAservices
6Object Model and Interface Definition
- Objects
- Types
- Modules
- Attributes
- Operations
- Requests
- Exceptions
- Subtypes
7OMG 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
8Running Example
train()
Player
-namestring -Numberint
book()
9CORBA 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
10CORBA Object Model Types
typedef struct _Address string street string
postcode string city Address typedef
sequenceltAddressgt AddressList interface Team
...
11CORBA 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
12CORBA Object Model Attributes
interface Player typedef sequenceltPlayergt
PlayerList interface Trainer typedef
sequenceltTrainergt TrainerList interface Team
readonly attribute string name attribute
TrainerList coached_by attribute Club
belongs_to attribute PlayerList players
...
13CORBA Object Model Operations
interface Team ... void bookGoalies(in
Date d) string print()
14CORBA 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
15CORBA Object Model Exceptions
- Generic Exceptions (e.g. network down, invalid
object reference, out of memory) - Type-specific Exceptions
exception PlayerBookedsequenceltDategt free
interface Team ... void bookGoalies(in Date
d) raises(PlayerBooked)
16CORBA 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
17CORBA Architecture
Implementation Skeletons
Client Stubs
One standardised interface
One interface per object operation
One interface per object adapter
ORB-dependent interface
18Goals 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
19Object Model and Interface Definition
- Interfaces
- Implementations and Objects
- Classes
- Attributes
- Operations
- Requests
- HRESULTS
- Inheritance
20Microsoft 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
21COM Interfaces
object, uuid(1CF2B120-547D-101B-8E65-08002B2BD1
18) interface IOrganization IUnknown
... object, uuid(1CF2B120-547D-101B-8E65-080
02B2BD116) interface IClub IOrganization
...
22COM 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
23COM 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
24COM Classes
- Named implementations
- Have one or several interfaces
- Are the principal mechanism to create COM objects
- Can return interface pointers to specific COM
objects
25COM Objects, Interfaces and Classes
Interface
implements
Implementation
uuid GUID
1..
1..
1
1
1..
1..
instantiates
0..
0..
Object
location int
0..
0..
createslocates
implements
Class
ClassObject
instantiates
clsid GUID
1
1
1
1
26COM 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)
27COM 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
val3) propput HRESULT Trainers(in
ITrainer val3) HRESULT
transfer(in IPlayer p)
Return value indicating success/failure
28COM HRESULTS
- HRESULTS are 32-bit integers
- Structured into four fields
29COM 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!
30Three Implementations of Requests
31COM Architecture
32COM 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
33Goals 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
34Java Object Model
- Interfaces and Remote Objects
- Classes
- Attributes
- Operations
- Exceptions
- Inheritance
35Java 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
36Java 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
37Attributes
- 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 ...
38Combining 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
39Parameter 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 ...
40Exception
- Pre-Defined Exception RemoteException
- Type-Specific Exceptions
- Example
class PlayerBooked extends Exception
interface Team extends Remote public
... void bookGoalies(Date d) throws
RemoteException, PlayerBooked ...
41JAVA (RMI) Architecture
Server
Client
Registry
Activation
Stub
Skeleton
Interfaces
Interfaces
RMI Runtime (
rmid
,rmiregistry
)
42Activation 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
43Key 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