Introduction : walking towards COM

Download Report

Transcript Introduction : walking towards COM

University of Genoa
Course of Software Engineering II 01-02
Elisabetta Parodi
1
Summary
1/2
• Introduction
– Walking towards COM
• COM
–
–
–
–
–
–
–
–
–
Introducing COM
Terminology
COM Binary Standard
Interface
Component Object Library
COM Server
COM Object
COM Technologies
Example
2
Summary
2/2
• DCOM
–
–
–
–
–
Introducing DCOM
DCOM Architecture
Location Independence
Connection Management
Security
• Global Overview
– Weaknesses of COM/DCOM
– Comparison of DCOM, CORBA, RMI
• References
3
Introduction :
walking towards COM
1/2
Windows purpose : moving integration between
applicative functions to O.S. level
 it needs effective communication mechanisms
between applications
COM
OLE
DDE
clipboard
4
Introduction :
walking towards COM
2/2
DLLs are a good starting point for modularity
problems :
• physical location dependency
• version management
we need a better communication mechanism. An objectbased and synchronous client-server technology facilitates:
• robustness
• API’s homogeneity
• physical location independency
• splitting into components
5
Introducing COM
• COM : Component Object Model (1992)
•
component software architecture that allows
applications and systems to be built from components
supplied by different software vendors
supports : interoperability and reusability
benefits : maintainability and adaptability
however, in order to interact, components must adhere
to a binary structure specified by Microsoft
6
COM Terminology
• Interface
a group of related functions that specifies a
contract
• Class
named, concrete implementation of one or more
interfaces
• Object
an instance of a COM class
• Component
binary unit of code that creates COM objects
7
COM Binary Standard
A standard way to :
• lay out virtual function tables (vtables) in memory
• call functions through the vtables
 any language that can call functions via pointers
(C, C++, Small Talk, Ada, and even Basic) can be used
to write components that can interoperate with
other components written into the same binary
standard
8
Interface
1/3
• collection of functions by which applications interact
with each other and with the system
• strongly typed contract between software
components to provide a small but useful set of
semantically related operations (methods) :
Component Object Design
•
definition of an expected behavior and expected
responsabilities
9
Interface
2/3
remember :
• considered logically immutable
reason : removing the potential for version incompatibility
new functionality : can be exposed through a
different interface
• is not a class
• is not a component object
• denotes behavior only, not state
• component objects can implement multiple interfaces
• is strongly typed
10
Interface
3/3
• identified by an IID
• must derive from Iunknown :
one special interface to implement some
essential functions: all component objects are
required to implement it
three methods :
• QueryInterface allows clients to dynamically
discover whether or not an interface is supported
by a component object; if so, it returns an
interface pointer from a component object
• AddRef
• Release
simple reference
counting methods
11
Component Object Library
A system component that provides the mechanics of
COM:
• provides the ability to make IUnknown calls across
processes
• encapsulates all the “legwork” associated with
launching components and establishing connections
between components
12
Creating a
component object
Application
CLSID
.EXE
Component
Object
Library
CLSID
Registration
DB
DLL
CLSID
13
COM server
In general :
some piece of code that implements some
component object such that the Component
Object Library and its services can run that code
and have it create component objects
Three ways in which a client can access COM objects
provided by a server:
• In-Process Server
• Local Object Proxy
• Remote Object Proxy
14
Client
Process
Cient
Application
Local Server Process
In-Process
Object
Stub
In-Process
Server
RPC
Local
Object
Proxy
COM
Remote
Object
Proxy
COM
Local
Object
Local
Server
Remote Machine
Remote Server Process
RPC
Stub
Remote
Object
COM
Remote
Server
15
COM object
In general :
some function that produces a defined output, given
tah the input meets predefined parameters.
COM encapsulates the function, only giving the client
of an object acces to the object interface(s).
All COM objects :
• are registered with a component database
• have no identity
16
Client
Application
4) Call interface
members
3) Get object
interface pointer
return to client
Object
Server
2) Locate
Implementation
1) Create
Object
COM
What happens when a client wishes to create and use a COM object?
17
When an application uses a COM object:
1) initializes the system : CoInitialize
2) calls CoCreateInstance (exported by COMPOBJ.DLL)
passing the CLSID of the used object;
CoCreateInstance :
 uses the registry to discover which server implements
the desidered class
asks the server to create an instance
 receives from the server a pointer to the IUnknown
interface
3) uses IUnknown.QueryInterface to access the wanted
interface
4) uses Addref and Release to manage the object lifecycle
5) in the end calls CoUninitialize
18
COM Technologies
Interfaces and API functions that expose operating
system services, as well as other mechanisms
necessary for a distributed environment :
•
•
•
•
•
Type Information
Structured Storage and Persistence
Monikers
Uniform Data Transfer
Connectable Objects
19
Example :
AMF Bowling Center System
1/6
In 1998 AMF Bowling rearchitected their international
bowling center operations software using ActiveX
controls and COM components.
We’ll see :
the container supporting the AMF BOSS System,
version 1.0
20
Example :
AMF Bowling Center System 2/6
The AMF
container
21
Example :
AMF Bowling Center System 3/6
Building blocks :
• Microsoft ActiveX controls
 implement user interface for each primary
functional area
• Component Object Model objects
 used by the controls to perform processing
22
Example :
AMF Bowling Center System 4/6
The container :
• needs to know enough about any ActiveX control
• offers its services via interfaces
• communicates with each control by using an agreed upon
COM interface
• manages all ActiveX controls and their relationships
• supports add-in COM objects
23
Example :
AMF Bowling Center System 5/6
• Architectural requirements :
• ability for customers to upgrade their
system
• isolated development of new modules
•
Solution :
COM deployed in a traditional client/server
environment
24
Example :
AMF Bowling Center System 6/6
CContainer
Handles
Messages for
CDynDlgbar
Manages
Creates/Destroys
Creates/Destroys
CCentralManageActiveXControls
uses
CCentralManageDlgbars
Creates/Destroys
uses
IManageDlgbars
uses
IManageActiveXControls
25
Introducing DCOM
An extension to COM that allows network-based
component interaction
COM : processes can run on the same machine but in
different address spaces
DCOM extension : allows processes to be spread across a
network
DCOM (1995) is a seamless evolution of COM
 you can take advantage of your existing investment in
COM-based applications, components, tools and knowledge
26
DCOM Architecture
Component
COM
Object
Security
DCE RPC
Provider
Protocol Stack
Component
COM
Object
Security
Provider
DCE RPC
Protocol Stack
DCOM networkprotocol
DCOM sits right in the middle of the components fo
your application; it provides the invisible glue that
27
ties things together.
Location Independence
Conflicting design constraints…
… with DCOM are easy to work around, because the
details of deployment are not specified in the source
code : DCOM completely hides the location of a
component
in practice, however, applications need to consider the
two primary constraints of a network connection:
• bandwidth
• latency
 preferred transport protocol : UDP
28
Connection Management
DCOM :
• manages connections to components that are
dedicated to a single client, as well as components
that are shared by multiple clients, by mantaining a
reference count on each component
• uses an efficient pinging protocol to detect if clients
are still active
• takes advantage of Windows NT support for
multiprocessing for enhancing applications’
scalability
29
Security by Configuration
4) Fail or allow call
3) Is user
in the list?
2) Authenticate user
1) DCOM obtains
user name
30
Security on the Internet
DCOM uses the security framework provided by
Windows NT , this supports multiple security
providers including :
• Windows NT NTLM authentication protocol
• the Kerberos Version 5 authentication protocol
• distributed password authentication
• secure channel security services
• a DCE-compliant security provider
31
Weaknesses of COM/DCOM
• COM/DCOM is hard to use
• COM is not robust enough for enterprise
deployments
 Microsoft is walking to turn COM and the MTS into
one programming model that will simplify the lives of
developers building distributed, enterprise-wide COM
applications
• COM/DCOM are best supported on Windows 95
and NT platforms
• low cost development tools provide the ability to
build and access COM components for Windows
platforms, for other platforms the prices are
considerably more expensive
32
Comparison of
DCOM, CORBA, RMI
Java RMI comes from JavaSoft
CORBA is a specification resulting from OMG
DCOM comes from Microsoft
Their main goal :
to provide an infrastructure to enable writing
distributed applications with relative ease,
although they do so in different ways
33
Java RMI
•
•
•
•
Very easy to use
Remoteable interfaces have a special exception
Supports object-by-value
Versioning is built into serialization
•
Callbacks are blocked in synchronized methods
•
Not always intuitive
•
Not available to other languages
•
There are limited development tools
•
Performance can be slow as you scale
34
CORBA
1/2
• Architecture for system composition
• Has a standard terminology for concepts
• Declarative interfaces separate the interface
from the implementation
• Provides mappings from IDL to C, C++, SmallTalk
and Java
• Supports :
• evolvable and marshallable data
• design portability
• standard interoperability protocols
• Scalable for large systems
35
CORBA
2/2
• No inheritance for Exceptions
• Objects cannot support two versions of the same
interface
• IDL is not internationalized
• Divergent security mechanisms (Kerberos, SSL)
• Few advanced services
• C++ mapping has complicated memory management
rules
• Limited developer tools (usually just an IDL
compiler)
• Limited concurrency model
36
DCOM
• Lots of tools, books and developers
• Separates interface from implementation
• Good integration of automation objects with
VisualBasic and Java
• Good set of compound document interfaces
• Microsoft depends on it working
• Minimal support on non-Microsoft platforms
• Hard to keep registry consistent
• Reference counting is a problem
• Client has to choose the interaction model
37
So, What Shall I Use?
1/2
• Requirement : no recompilation moving applications
to various platforms
 the Java/CORBA solution may be more appropriate
then COM
• Requirement : interaction with DCOM objects
 pure DCOM solution
38
So, What Shall I Use?
2/2
• Requirement : distributed application written entirely
in Java
 RMI for its ease of programming
• Requirement: plug-in components created by third
parties
 components may be based around a DCOM or
CORBA interface
39
References
1/2
• http://www.microsoft.com/
– Main source : terminology, technical documentation,
example from official Microsoft site
• www. sei.cmu.edu/str/descriptions/com_body.html
– The Software Engineering Institute (SEI) is a federally
funded research and development center sponsored by
the U.S. Department of Defense. I found some
interesting documentation in their Software Technology
Review
• www2.umassd.edu/coursepages/SoftwareArchitect
ure/paul-com/
– University of Massachussets, lessons of the module of
Software Architecture about COM.
40
References
2/2
• http://www.whatis.techtarget.com/
– An IT company which offers targeted industry-specific
search engines that deliver access to relevant
information on the Web. I found here useful explanation
about DDE, OLE, MTS, ActiveX.
• http://www.webopedia.com/
– Online dictionary and search engine for computer and
Internet technology.
• Introduzione a COM – seminario di E. Lodolo
– From a lesson at University of Genoa : introduction about
COM and Windows fundamentals
41
T
H E
THE
E N D
END
42
Clipboard
• The simplest mechanism available to exchange
data between applications running in hte Windows
environment
• A section of computer memory that temporarily
stores data especially to facilitate its movement
or duplication
back
43
DDE : Dynamic Data Exchange
• An asynchronous message-based communication protocol
• An interprocess communication (IPC) system built into the
Macintosh, Windows, and OS/2 operating systems
• Enables two running applications to share the same data
• Example : DDE makes it possible to insert a spreadsheet
chart into a document created with a word processor.
Whenever the spreadsheet data changes, the chart in the
document changes accordingly.
• Still used by many applications
• Supplanted by OLE
 provides greater control over shared data.
back
44
OLE : Object Linking & Embedding
• A compound document standard developed by
Microsoft Corporation
• Enables you to create objects with one application and
then link or embed them in a second application.
Embedded objects retain their original format and
links to the application that created them.
back
45
DLL : Dynamic Link Library
Two kinds of executables in Windows:
• EXE
• DLL
Functions exported from a DLL are linked at runtime,
not during compilation.
We have two linking modalities for a DLL:
• static link : when application is loaded
• dynamic link : at any time by API’s LoadLibrary,
GetProcAddress, FreeLibrary
Advantages: modularity, code sharing,substitutability.
back
46
VMT : Virtual Method Table
1/2
Virtual methods can be redefined in derived classes.
Virtual methods calls are solved at execution time
(late binding)  indirect jump  (small) overhead
In compiled object languages virtual methods are
implemented by VMT : a function pointer table
• one VMT for each class
• instance : data structure holding an object state
 its first field is a pointer to the VMT of the class to
which the object owns
• all instances of the same class point to the same VMT
47
I1 : C1
VMT : Virtual Method Table 2/2
Pointer to VMT
Attribute 1
Attribute 2
Attribute 3
……………………
I2 : C1
VMT of class C1
Pointer to function 1
Pointer to function 2
Pointer to function 3
Pointer to function 4
Pointer to VMT
Attribute 1
Attribute 2
Attribute 3
……………………
back
48
i
m
p
l
e
m
e
n
t
a
t
i
o
n
s
MTS : Microsoft transaction Server
1/2
A container for in-process server side components.
A component-based programming model. An MTS
component is a type of COM component that executes
in the MTS run-time environment.
What does it do?
• Allows you to define and use transactions within
COM objects
• Enforces modelling based on components – just as
COM
49
MTS : Microsoft transaction Server
2/2
• Handles communication between components through DCOM
and HTTP protocols
• Uses roles and packages
• Uses Just In TIME (JIT) Activation
• Surrogate Process
(MTS.EXE)
• Run-time divided into
three parts :
• Microsoft Distributed
Transaction
Coordinator (MS DCT)
• MTS Explorer
back
50
ActiveX
1/2
• Technology developed by Microsoft for sharing
information among different applications
• Outgrowth of OLE and COM
 supports new features that enable it to take
advantage of the Internet
• Not a programming language but a set of rules for how
applications should share information
51
ActiveX
2/2
• ActiveX control
• similar to Java applet but :
– full access to the Windows operating system
– limitated to Windows environments
• can be developed in a variety of languages
back
52