Component object model and

13
COMPONENT OBJECT MODEL PRESENTATION BY- CHARMY PANIGRAHI (2k11/SE/022) CHARVI SINGLA (2k11/SE/025) JASMIN JOY (2k11/SE/035) RIKKI MEENA (2k11/SE/059)

Transcript of Component object model and

Page 1: Component object model and

COMPONENT OBJECT

MODELPRESENTATION BY-

CHARMY PANIGRAHI (2k11/SE/022)

CHARVI SINGLA (2k11/SE/025)

JASMIN JOY (2k11/SE/035)

RIKKI MEENA (2k11/SE/059)

Page 2: Component object model and

COM(COMPONENT OBJECT

MODEL)

COM is a platform-independent, distributed, object-oriented system for creating binary software components that can interact.

Object-oriented languages, such as C++, provide programming mechanisms that simplify the implementation of COM objects.

Page 3: Component object model and

COM(COMPONENT OBJECT

MODEL)

COM is not an object-oriented language but a

binary standard.

COM specifies an object model and

programming requirements that enable COM

objects (also called COM components) to

interact with other objects.

Page 4: Component object model and

DESIGN PRINCIPLES

Binary Components

a. Any programming language.

b. Any location (in- process, cross- process,

cross machine).

Zero sacrifice in performance.

Enable extensibility and adaptability.

Page 5: Component object model and

Design Principles

Encapsulation

a. Black box - no leakage of implementation

details.

b. Object manipulation through strict interfaces.

Polymorphism

a. Multiple interfaces per class.

Page 6: Component object model and

Interfaces of COM

IUnknown

AddRef

Release

QueryInterface

IDispatch

GetIDsOfNames

GetTypeInfo

GetTypeInfoCount

Invoke

Custom Interfaces

Page 7: Component object model and

Interfaces of COM

Your application may have as much as classes as you need. It should implement at least the IUnknown interface. AddRef increments the objects usage count, and Release decrements it. Object may unload itself when the reference count reaches to zero. QueryInterface helps you to query any interface using another one. If you create and object and get the IUnknown interface you can easily access other interfaces. Applications usually query objects whether they have a certain interface. For example the COM runtime queries and object of IMarshall to decide whether custom marshalling or universal marshaller. Internet Explorer searches some certain registry keys, and loads the objects under those keys. It then queries the object of IObjectWithSite interface to decide the object will be run as a plugin. The object queries the IUnknown interface of the loader module for IWebBrowser2. When a page is loaded the plugin asks the browser the IUnknown of the document. The IHTMLDocument2 and IHTMLElement interfaces are queried using the IUnknown interface that we have.

Page 8: Component object model and

Interfaces of COM

IDispatch interface has to be implemented if the

object is to be used from scripting languages

through automation. The script languages

accessed the methods in vtable by name using

the methods of IDispatch interface. COM

objects also implement their custom interfaces

for direct access.

Page 9: Component object model and

COM Architecture

Communication details handled by the COM run-time

Page 10: Component object model and

COM Protocol

A client that needs to communicate with a

component in another process has to use

some form of inter-process communication

provided by the operating system. COM

provides this communication in a completely

transparent fashion: it intercepts calls from the

client and forwards them to the component in

another process.

Page 11: Component object model and

COM Protocol

LPC (Local Procedure Call) is used for interprocess

communcation. LPC is a system service in the Win32

subsystem. For example all the Win32 API calls are

done using LPC. An application that calls the

CreateWindow actually packs all of the parameters and

send them to the Win32 subsystem.

COM uses DCE’s (Distributed Computing Environment

specified by Open Software Foundation) RPC (Remote

Procedure Call) protocol. DCE was implemented for

Windows platform by Digital Equipment Corporation.

Page 12: Component object model and

Advantages of COM

Location Transparency - The component’s clients don’t

have to know the location of the components.

Wire Level Standard - The component users don’t have

to know anything about the underlying network

mechanisms, TCP/IP or NETBIOS, to use the

components.

Binary Standard - The users don’t have to know about

the programming languages – C, B, VB, Java, Tea –

used to build the components.

Runtime Polymorphism - At runtime the client detects

the right component it wants and uses its services.

Page 13: Component object model and

Disadvantages Of COM

Security - Only a local server has its address space isolated from that of the client. An in-process server shares the address space and process context of the client and can therefore be less robust in the face of faults or malicious programming.

Granularity. A local server can host multiple instances of its object across many different clients, sharing server state between objects in multiple clients in ways that would be difficult or impossible if implemented as an in-process server, which is simply a DLL loaded into each client.

Compatibility. If you choose to implement an in-process server, you relinquish compatibility with OLE 1, which does not support such servers.

Inability to support links. An in-process server cannot serve as a link source.