Unit Structure
About COM
COM Components
COM Architecture
COM Data types
Introduction to Distributed Objects
Categories of Distributed object architecture
Distributed Object Architecture
Remoting
Architecture Component
About COM…
Is a platform-independent, distributed,
object-oriented system for creating binary
software components that can interact
COM is the dominant component
architecture
Microsoft created the Component Object
About COM…
Provides the communication in a
completely
transparent
fashion:
It
intercepts calls from the client and
forwards them to the component in
another process
COM objects can be created with a
variety of programming languages
COM is implemented in a
COM is not ….
COM is not a computer language
COM does not compete with or replace
DLLs.
COM is not primarily an API or a set of
functions like the Win32 API
COM is also not a C++ class library like the
COM Evolution
1990’s – Microsoft’s OLE
Microsoft created the Component Object Model (COM)
to provide the infrastructure that was needed to realize
its vision for OLE
1996 - Microsoft ActiveX
ActiveX controls enables the developer to build
sophisticated controls based on the Common Object
Model (COM).
End of 1996 - Microsoft DCOM
a set of RPC-based extensions to COM that allow COM
objects to be distributed
Now -
COM architecture is deprecated by Microsoft’s .NetBenefits
Application Customization Component Libraries
Distributed Components
Component A
Component B
Remoting C
Remoting D
Netwo
rk
Component C
COM Components
Consist of executable code distributed either as
Win32 dynamic link libraries (DLLs) or as
executables (EXEs).
Are fully language independent
Any language can be modified to use COM
components, including Smalltalk and Visual Basic
Can be shipped in binary form
COM
The most fundamental question COM
addresses is:
To solve this problem…
It is necessary to find solutions for 4 specific
problems
Basic Interoperability
Versioning
Language Independence
Component Object Model (COM)
The Component Object Model (COM) is a component
software architecture that allows applications and
systems to be built from components supplied by
different software vendors
These services provide distinctly different functionality
Types of Servers
In-Process server
Implemented as a dynamic linking library (DLL)
that executes within the same process space as the
application
Local Server
Executes in a separate process space on the same
computer. Communication between an application
and a local server is accomplished by the COM
runtime system
Remote Server
Executes on a remote computer. DCOM extends
Client Application
In-Process Server (DLL)
Local Server
Remote Server
Computer A Computer B
COM
DCOM
COM Fundamentals
A Binary standard for function calling between
components
A provision for strongly-typed groupings of
functions into interfaces
A Base interface providing
Reference counting to allow components to track
their own lifetime
A mechanism to uniquely identify components and
their interfaces
A "component loader" to set up component
COM defines a standard way to lay out virtual function
tables (vtables) in memory, and a standard way to call
functions through the vtables
Interface
A COM interface is a strongly-typed
contract
between software components to provide a small
but useful set of semantically related operations
(methods)
All of the functionality that a component must
implement to be a drop target is collected into the
IDropTarget
interface
All the drag source functionality is in the
IDragSource
interface.
COM Data types : Base Types
IDL C Visual Basic Java
Boolean unsigned char Unsupported char
Byte unsigned char Unsupported char
Small char Unsupported char
Short Short Integer short
Long long Long int
hyper _int64 Unsupported long
float Float Single float
double Double Double double
Char Unsigned char Unsupported char
Wchar_t Wcgar_t integer short
enum enum enum int
COM Data types : Extended types
IDL
C
Visual Basic Java
VARIANT VARIANT
Variant
ms.com.Variant
BSTR
BSTR
String
Java.lang.String
BOOL
short [-1/0]
Boolean
[True/False]
boolean
Automation Data types
COM IDL Type Description
short 16-bit signed integer long 32-bit signed integer
float 32-bit signed floating point number double 64-bit floating point number
BSTR length-prefixed wide character array
VARIANT_BOOL short integer used to indicate true or false
DATE 64-bit floating point number representing the fractional number of days
A Distributed Object Example
Checking Account class
IAccount
IAccountInit
ICheckingAccount : IAccount
COM Object
COM Client COM Client
Deposit, Withdraw
Withdraw Using Cheque
Both COM and CORBA rely on client-side and server-side mechanisms to
manage issues related to remoting
These mechanisms are referred to as proxies and stubs in COM. In CORBA,
the mechanisms are referred to as stubs and skeletons
In COM, the proxy and stub are packaged in a single DLL. The DLL is
associated with the appropriate interfaces in the windows system registry.
The COM runtime system uses the registry to locate proxy-stub DLLs
associated with an interface when marshaling of the interface is required.
Client Client Stub (COM Proxy) (CORBA Stub) Server Server Stub (COM Stub) (CORBA Skeleton) Communication Bus (DCOM or CORBA)
Remote Method Invocation
A client invokes a remote method
The client stub creates a message containing information needed for the
remote invocation. (The message creation process is referred to as
marshaling.)
The client stub sends the message to the server stub using the
communication bus.
The server stub receives the message and unpacks it. (The unpacking
process is referred to as unmarshalling.)
The server stub calls the appropriate server method based on the
information provided in the received message
The server stub creates a message based on the outputs of the call to the
server method (i.e., the return value and out parameters).
The server stub sends the result message to the client stub using the
communication bus.
The client stub receives the result message, unpacks the message, and
Client
(Visual Basic or C++ Client)
Proxy
(ComServer.dll)
Client
(Visual C++ COM Server
Stub
(ComServer.dll)
COM/DCOM
RPC
COM/DCOM
COM uses LPC’s for communicating between
processes
LPCs are a means of communication between
different processes on the same machine based on
remote procedure call
(RPC)
RPCs allow applications on different machines to
communicate with each other using a variety of
network transport mechanisms.
Distributed COM (DCOM), uses RPCs to
communicate across the network
Client Proxy marshals parameters Component Stub unmarshals parameters P ro ce ss B ou n d ar y EXE EXE DLL DLL
Marshaling & Un-Marshaling
An interface named
IMarshal
has to be
implemented
COM queries your component for
IMarshal
as part
of its creation strategy
It then calls member functions in
IMarshal
to
marshal and unmarshal the parameters before and
after calling functions
COM library implements a standard version of
Client / Server Implementation
Creating the Component
The function CreateInstance created an instance of the component
and returned the IUnknown interface pointer to the client
Exporting a Function from a DLL
The name of the Library functions has to be listed by exporting in
the EXPORTS section of the file
Loading the DLL
The files CREATE.H and CREATE.CPP implement the function
CallCreateInstance
CallCreateInstance takes the name of the DLL as a parameter, loads
Advantages
COM forces the Operating System to act as a central registry for
objects
COM components are never linked to any application
Garbage Collection is one other major advantage to using COM.
When there are no outstanding references to an object, the COM object destroys itself
COM supports Marshalling COM is a binary standard
Disadvantages
Resiliency
COM/ActiveX Registration Isolated Components
AU Distance Education – DMC1754 - Middleware Technologies - Unit V
AU Distance Education – DMC1754 - Middleware Technologies - Unit V
AU Distance Education – DMC1754 - Middleware Technologies - Unit V
COM - Component Object Model
Defines a binary standard for component interoperability Is programming-language-independent
Is provided on multiple platforms
Provides for robust evolution of component-based applications
and systems
Is extensible by developers in a consistent manner
Uses a single programming model for components to communicate
within the same process, and also across process and network boundaries
Allows for shared memory management between components Provides rich error and status reporting
Allows dynamic loading and unloading of components
A software architecture that allows the components made by