CHAPTER 7 COM and.net

Similar documents
Distributed Technologies - overview & GIPSY Communication Procedure

Outline. COM overview. DCOM overview. Comparison DCOM and Corba

Apartments and COM Threading Models. Jim Fawcett CSE775 - Distributed Objects Spring 2008

COM+ OVERVIEW OF MICROSOFTS COM, DCOM AND COM+ COMPONENT TECHNOLOGIES DCOM - COM+ Peter R. Egli peteregli.net. peteregli.net. 1/20 Rev. 1.

Component models. Page 1

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies

Introduction to.net Framework

Limitations of Object-Based Middleware. Components in CORBA. The CORBA Component Model. CORBA Component

Introduction. ActiveX, OLE, and the Internet

Lecture 16. What is COM? Principles of COM. COM Design Principles. Example (UML Diagram) Microsoft IDL (MIDL) COM/DCOM February 23, 2005

(D)COM Microsoft s response to CORBA. Alessandro RISSO - PS/CO

1.264 Lecture 16. Legacy Middleware

Distributed Objects. Object-Oriented Application Development

New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other

Introduction to.net Framework Week 1. Tahir Nawaz

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

CHAPTER - 4 REMOTE COMMUNICATION

Distributed Middleware. Distributed Objects

Distributed Systems Middleware

Electronic Payment Systems (1) E-cash

CAS 703 Software Design

.Net. Course Content ASP.NET

COM & COM+ (Component Object Model) Bazsó-Dombi András, Group 251.

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Chapter 4 Communication

.NET-6Weeks Project Based Training

C# Syllabus. MS.NET Framework Introduction

Distributed Systems Principles and Paradigms

A Report on RMI and RPC Submitted by Sudharshan Reddy B

Department of Computer Applications

Unit 1: Visual Basic.NET and the.net Framework

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

UNIT V COMPONENT OBJECT MODEL

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Interfacing Ada 95 to Microsoft COM and DCOM Technologies

DOT NET Syllabus (6 Months)

Distributed Systems. The main method of distributed object communication is with remote method invocation

.NET CLR Framework. Unmanaged Hosts - Assembly Access

JAYARAM. COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

CORBA (Common Object Request Broker Architecture)

Communication. Overview

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Software Architecture Patterns

Communication. Distributed Systems Santa Clara University 2016

MTAT Enterprise System Integration. Lecture 2: Middleware & Web Services

RPC. Remote Procedure Calls. Robert Grimm New York University

.Net Interview Questions

DOT NET COURSE BROCHURE

Mohsin Qasim Syed Abbas Ali

HCIM SUMMER WORKSHOP Introduction to C#

Saikat Banerjee Page 1

Lecture 5: Object Interaction: RMI and RPC

Chapter 4 Communication

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

A NET Refresher

C# 6.0 in a nutshell / Joseph Albahari & Ben Albahari. 6th ed. Beijin [etc.], cop Spis treści

Today: Distributed Objects. Distributed Objects

Lecture 06: Distributed Object

Distributed Object-Based Systems The WWW Architecture Web Services Handout 11 Part(a) EECS 591 Farnam Jahanian University of Michigan.

DISTRIBUTED COMPUTER SYSTEMS

Appendix A - Glossary(of OO software term s)

Java J Course Outline

COMERA: COM Extensible Remoting Architecture

EEE-425 Programming Languages (2013) 1

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

Chapter 4 Remote Procedure Calls and Distributed Transactions

CSci Introduction to Distributed Systems. Communication: RPC

Lecture 15: Network File Systems

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR (ODD SEMESTER) QUESTION BANK

Communication and Distributed Processing

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Networks and Operating Systems Chapter 3: Remote Procedure Call (RPC)

Performance comparison of DCOM, CORBA and Web service

Team Developer and.net

Software Paradigms (Lesson 10) Selected Topics in Software Architecture

INTERNAL ASSESSMENT TEST 1 ANSWER KEY

Bringing COM Technology to Alignment Software * Abstract

Chapter 3 Introduction to Distributed Objects

Lecture 8: February 19

Chapter 1:- Introduction to.net. Compiled By:- Ankit Shah Assistant Professor, SVBIT.

Communication and Distributed Processing

COMPONENT BASED TECHNOLOGY (IT-1401)

B.E /B.TECH DEGREE EXAMINATIONS,

Distributed Object-Based. Systems. Chapter 9

.NET XML Web Services

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

UNIT 1 PART A PART B

CSCI-1680 RPC and Data Representation John Jannotti

5 Distributed Objects: The Java Approach

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

.NET. Inf 5040, Outline. Gyrd Brændeland, Sharath Babu Musunoori, Åshild Grønstad Solheim

Introduction to.net. The path. The Distributed Group University of Seville Spain - España. Introduction The elements of.net. Assessments Conclusions

Verteilte Systeme (Distributed Systems)

Top 40.NET Interview Questions & Answers

IBD Intergiciels et Bases de Données

Overview. Communication types and role of Middleware Remote Procedure Call (RPC) Message Oriented Communication Multicasting 2/36

CS551 Object Oriented Middleware (II) Outline. Who is the OMG?

Transcription:

1

CHAPTER 7 COM and.net Evolution of DCOM Introduction to COM COM clients and servers COM IDL & COM Interfaces COM Threading Models. Marshalling, Custom and standard marshalling. Comparison COM and CORBA. Introduction to.net. Overview of.net architecture.net Remoting. 2

Evolution of COM COM is a Component Model Developed by Microsoft namely Component Object Model. To Support distributed application Microsoft uses Microsoft Distributed Component Architecture (MDCA). MDCA used Distributed COM i.e. DCOM 3

Evolution of COM 1)Clipboard -:Initially clipboard was used as fundamental method for sharing data between two applications. 2)Dynamic Data Exchange-:In 1990 DDE was primarily used for dynamically exchanging data between two applications. It was used in office applications. As it build 4 at the top of Message passing architecture of windows, it was slow, hard to program, inflexible. 3)OLE 1.0 -:DDE evolved to OLE 1.0.OLE was capable of maintaining active links between two documents or even embedding one type of document in to another. it uses DDE for interprocess Communication. 4)16 bit OLE -: used in VB2.0 & MSOFFICE 4.0 uses Virtual function table to communicate client & server

Evolution of COM 5)OLE 2.0 -:Introduced in 1993, it s a reimplementation of OLE 1.0 using COM instead of VTBL.COM is a binary standard Specifies how to communicate with Objects, Control Object lifecycle & expose functionality to user 6)OCX -: OCX is a OLE Control used in VB 4.0 uses 5 container to load it. Container & OCX Communicate with each other through interfaces. 7)ActiveX -: it s a Light weighted COM Object. Deals with active content management of web Pages. 8)DCOM -:DCOM uses ms RPC for communication with remote System.DCOM extends COM by marshaling the arguments & return value of method call over the Network.

Evolution of COM 9)COM +-:Introduced to handle functionality of Microsoft Transaction server(mts). 10).NET -: it provides rapid development tools for both windows form & web forms. 11).NET Remoting -:Allows objects to be transparently marshaled by reference or values across machines boundaries. it uses MS API to send message from client process to server process & to receive reply in assistance of OS & network agents. 6

Introduction to COM Traditional Monolithic Applications we distributed as single like.exe they needed to rebuild even if one line of code changed Component oriented Design solved this problem by breaking application down into components that can be distributed in separate binary files like DLL or exe. COM enables developer to package their functions into reusable software Components. It defined Standard architecture & protocol for interacting objects on heterogeneous platforms. It provides Location transparency to objects so that it uses Remote procedure call (RPC) for Remote instance of Object 7

Introduction to COM An application can interact with each other through interfaces.com object must support at least one base interface called IUnknown. The use of interfaces are 1)Fast & Simple object interaction 2)Location transparency 3)Programming language independence 4)It s a true Object Model as it provides Distributed Capablities,Provide Object level Security, encapsulate lifecycle of objects, provide methods for reusability etc. 5)Provide evolution of Application Functionality 8

COM Clients & Server A COM is a body of Source code that implements COM interface. It has Class identifier(clsid) & interface identifier (IID). One or more COM classes are packaged into Server. A COM server can be packaged as DLL or EXE. 1) If it packaged as DLL that is loaded in to client process & accessed by server called in-process server. 2) If it packaged as EXE that is Run on same as a client or remote machine that is accessible through DCOM called Out-of-process Server. 9

COM Clients & Server On the basis of packaging they are of 4 types 1)In-Process Server -: if the component is a local & designed to be an in process server the client instantiate it & Communicate through COM. e.g. ActiveX 2)Out-of-Process Server -: if the component is a local & designed to be a local out-of process server,the client instantiate it & Communicate through COM,Proxies & registry. E.g. Excel 3)Out-of-Process Remote Server -: if the component is Remote but client did not specify Remote System, then client registry contain name of machine on which component is created. They Communicate using DCOM. 4)In-Process Remote Server -: if the Remote component is written to take advantage of MTS,it can run in-process to MTS & uses DCOM to communicate clients. 10

Types of COM Server

DCOM DCOM is also called as COM on Wire supports Remoting objects by using objects remote procedure call (ORPC) protocol This ORPC layer is built on top of DCE s RPC & interact with COM s runtime services To invoke remote function Client make a call to client stub.stub packs the call parameters in to request message to server. At server side wire protocol delivers the message to server stub which then unpack the request message & call actual function on Object. In DCOM Client stub is referred as Proxy & server stub is stub. 12

13 DCOM Architecture

DCOM Architecture The Architecture of DCOM Consist of three layers Top, Middle & Bottom layer. The Top layer is the basic programming Architecture. It describes Clients requests & creation of object instance in the Server transparent to client. In DCOM creation of remote object requires the server name & CLSID.The SCM in COM libraries on client machine connects to the SCM on server machine & requests creation of remote Object. Class factory creates instance of COM Class which having 14 CLSID & SCM return pointer to interface of Object.

DCOM Architecture The Middle layer consist of Remoting Architecture. It takes care of sending data across different address spaces using Marshalling & unmarshalling.marshalling packs the parameter in to standard format at clients address space while Unmarshalling unpacks standard format to appropriate data representation. 15

DCOM Architecture The Bottom layer is a wire protocol Architecture which further extends the Remoting architecture to work across different machines. DCOM wire protocol is based on DCE-RPC Specification it also clear garbage collection of remote object reference when client abnormally terminates. When server is started by Server side SCM (DCOM SCM is a DCOM interface to Service Control manager which allows Controlling of services like Starting/Stopping Services on windows system) its assigned an object exporter identifier(oxid). 16

DCOM Architecture An object reference is created to represent the interface pointer. it contains IID,OXID & address of OXID Resolver. The client side OXID resolver check if it has mapping of OXIS If not then it get registered in RPC binding & return it to object proxy. It enables connection between Object Proxy & Interface proxy. 17

COM INTERFACE & IDL COM provide interface definition language (IDL) which is used to define interfaces. COM IDL is based on DCE IDL. The COM interface can be viewed in two perspective A logical perspective focuses on the interface method & operation they perform. A physical perspective focuses on memory,netword packets & runtime environment. IDL provide Both Network & Location transparency & Programming Language Independence. 18

COM IDL The file that contains interface & type librrary definition is called IDL file & has as.idl extension. It contain one or more interface definitions. It is defined by keyword interface & parsed by Microsoft Interface Definition Language(MIDL) Compiler. IDL has four components Interface name Base interface name Interface body Interface attributes -: Specifies characteristics of interfaces & of data & methods within the interface it enclosed in square brackets. 19

COM INTERFACS COM SUPPORTS THREE STANDARD INTERFACES 1) IUnknown Interface 2) Idispatch Interface 3) IClassFactory Interface 20

1) IUnknown interface All COM objects support an interface called IUknown This interface provides control of objects lifetime through IUknown:AddRef & IUknown:Release methods & ability to retrieve other interfaces implemented by objects through IUknown:QueryInterface method. IUknown:AddRef & IUknown:Release methods & IUknown:Release methods maintain objects reference count. When first object is created then reference count is set to one & Function used in interface must call IUknown:AddRef through the pointer to increment reference Count. Before pointer can be destroyed IUknown:Release method is called. After reference count reaches to 0 the object is destroyed & all interfaces to it become invalid. 21

IUnknown interface The IUknown:QueryInterface method determines whether or not an object supports specific interface. If an object supports an interface,the QueryInterface returns a pointer to that interface. 22

Idispatch Interface IDispatch is a standard interface that expose the functionality of Application programmatically. Idispatch interface exposes object, methods & properties to application that support automation. It has proxy & stub to take care of marshalling & each method in a interface is identified by DISPID. It uses CoCreateInstance function to initialize ActiveX or OLE. Components using Idispatch can be accessed by following method 1)Late binding -: here client fetches DISPID by invoking GetIDsOfNames.its advantage is it do not need type library. but it is less flexible. 23

Idispatch Interface 2) Early Binding -: In this method compiler consult the typelib to obtain DISPID so that the client can make single call using invoke method. 24

IClassFactory Interface A COM class object normally implement IClassFactory interface & thus referred to as class factories. CoCreateInstance() function enable client to instantiate class which calls IClassFactory internally. The IClassFactory interface contains two methods The first method CreateInstance creates uninitialized object of specified CLSID. The second method LockServer,locks the objects server in memory,keeping the component Open in memory & allowing object to be created more quickly. 25

COM Threading Model Initially COM had no support for Multi-threading but when Threading model was included in windows COM extended to include threading. its used to enhance performance of application COM has basically 2 types of threading models 1)Threading Model for User-driven GUI applications it synchronized with message queue. 2)Threading Model for Worker components its needed to improve performance of the system. A thread is a path of execution through process which enables an application to perform functions concurrently. 26

COM Threading Model Microsoft has defined different levels of thread safety using threading model. (i.e. safety of shared data used by 2 processes simultaneously) The basic unit of thread safety in COM is called apartment There are three types of apartments 1) Single-threaded Apartment (STA) 2)Multi-threaded Apartment (MTA) 3)Rental-threaded Apartment (RTA) 27

1) Single-threaded Apartment (STA) It has only one thread executing per apartment Here method call automatically synchronized & dispatched using Microsoft message queuing(msmq). This components are accessible through STA only Call from other client is marshaled by COM to main STA & is received by proxy in one apartment & send to stub in another. To improve system components can be accessed through main STA. 28

2) Multi-threaded Apartment (MTA) It has More than one thread executing per apartment Here method calls are not synchronized automatically Special synchronization mechanism used for this purpose. This components supporting this model call it from any thread If object is present in MTA & client call through STA then marshalling is needed. 29

3) Rental-threaded Apartment (RTA) It allows More than one thread to enter an apartment. When thread enters an apartment it requires an Apartment wise lock that prevent other threads from entering Apartment. Its released when thread exits the Apartment. Its more efficient & flexible than STA because it does not start with single thread. 30

Single threading Model The object receives only client request at a time. As single process can have several threads that are employed to facilitates the concurrent use of COM objects The windows messaging queue is used to synchronize & dispatch COM method calls to objects. Message queue synchronize calls serially. When 2 clients want to access same object they uses following sequence of steps 1)first client creates Objects 2)second client call is queued in MSMQ until first client complete his work 3) Second client will connected to same object when no 31 other client calls are in queue

APARTMENT THREADING MODEL Apartment is a logical container that creates association between Objects & threads. Every object is associated with one & only one Apartment. Its more than just Logical construct, their rues describes behavior of COM System. This model is used in object with visual control, batch processing & object active over long time. This model improves systems performance. Its used for stateful data application 32

FREE THREADING MODEL In this model multiple clients concurrently executes an object method from different threads. In this model interface do not need to marshaled between the apartments. All client threads running STA/MTA can call objects directly instead of going through proxy. Its used for stateless data application 33

NEUTRAL THREADING MODEL It s a variation of FTM Multiple client can call the objects on diffeent threads at the same time. COM ensures that no two calls conflicts. If free objects are present COM allocate them to clients This Model is Available in only COM+ Its used in high load stateless data applications. 34

Marshalling The issue of passing parameters in DCOM is major area of concern. Marshaling is a process of packaging method call & their parameters into a packet & transmitting them over the network. COM Offers three types of Marshalling. 1)Standard Marshalling 2)Custom Marshalling 3)Type Library Marshalling 35

Types Of Marshalling Relation Between Types Of Marshalling 36

Custom Marshalling It s a fundamental Marshalling mechanism in COM & this method allows the client to gain a complete control over marshalling process. As it is difficult to implement & is more generic Standard marshalling mechanism is used In custom marshalling COM has no support for transmission of data between proxy & stub. Marshalling interface is dine by loading the proxy DLL in clients address space however no stub DLL is created. Custom marshalling is used in situations to generate customized proxy to improve speed of transmission, reduce network traffic,improve security. It is used in Image processing applications to improve the speed of multimedia file transmission by compressing code. 37

Custom Marshalling It is also used to communicate between intra-process components. Custom marshalling makes use of Imarshal interface it marshals interface pointer into stream object & back. It has following Functionalities 1) Marshall Interface 2) UnMarshall Interface 3) Release Marshal Data 4) Disconnect Object. 5) Get UnMarshall Class 6) Get Marshall Size Max 38

Standard Marshalling It is used when object does not implement marshalling but generates it using user defined interface for the object. In standard marshalling COM generic proxy & stub communicate using RPCs. These custom interfaces are compiled by MIDL Compiler to generate Standard marshalling code. MIDL generate following files 1)A Header file 2)A file containing definition for IID & CLSID. 3) A file containing Marshalling code 4)A type Library file These files are compiled & linked to produce the stub/proxy DLL to marshal the interface. 39

Standard Marshalling The stub/proxy must be registered & SCM loads the required proxy on the basis of IID returned to the client. The standard marshalling has four interfaces 1) IRpcfactoryBuffer that is used to instantiate IRpcProxyBuffer in the server 2) IRpcProxyBuffer used to connect STUB. 3) IRpcStubBuffer has invoke method to instantiate stub. 4) IRpcChannelBuffer used for communicate between Stub & Proxy. 40

41 Standard Marshalling

Type library Marshalling It uses IDispatch marshaller. COM has efficient as marshalling code generated. It is generic it is not as efficient as marshalling code generated. It took more time for lookup & more time is consumed but its more flexible & easy to use No proxy/stub is needed to build & registered. It is available in windows. Handler Marshalling Its between standard & custom marshalling Its useful for objects that perform work in clients address space, making remote call only when needed. It supports IStdMarshallInfo that retrieve CLSID of handler object to be loaded into clients address space. 42

43.NET Architecture

.NET Architecture The architecture of.net is tired, Modular & hierarchical. Each tier of.net framework is a layer of Abstraction. The.NET languages(most abstracted) are the top tier while CLR(least abstracted) is a bottom tier..net framework is partitioned into separate modules, each having its own responsibility. The Components of.net Framework is described as follows 1) Common Language Runtime (CLR) 44 CLR monitors the execution of.net applications & provides essential services. It manages code at execution time & provide Core services like remote communication, memory management & thread management. CLR is.net equivalent of JVM it s the runtime that converts MSIL code to host machine language code that is executable

.NET Architecture 2) Standard System Services Standard services like ADO.NET & XML are made universally available & standardize across language by bringing them under Control of.net framework 3)User & Program interface It includes windows forms & web forms that provide user interface for windows & web applications. It contain web services which provide a mechanism to communicate over internet using SOAP which is analogous to ORPC in DCOM. 4) The.NET framework class library (FCL) 45 It is a set of managed classes that provide access to system services. it is comprehensive & object oriented collection of reusable types that can be used to develope UI/non UI web applications.

.NET Architecture Remoting,xml,sockets,file i/o,database access comes under FCL. ITS hard to avoid FCL & this improves portability & security of applications. Base Class Library (BCL) is subset of FCL & has core set of classes that serve as API of CLR. 5) Common type systems (CTS) It specifies rules related to data types that languages must follows. as all programs are converted to standard intermediate language (MSIL) their datatypes must be converted to standard datatypes. CLS is a subset of CTS. The.NET types are separated in to value & reference type value are primitive types inherit from system. The lifetime of reference type is controlled by garbage collector. 46

.NET Architecture 6)Common Language Specification It s a set of specifications or guidelines defining a.net language. Shared specifications promote language interoperablity.cls defines common type of managed languages, which is subset of CTS. 47

.NET Remoting.NET Remoting is used instead of DCOM because DCOM relies on ORPC Protocol that does not support object model which prevents interoperability across platform. DCOM communicate using ports that are blocked by firewall.net Remoting eliminate the difficulties of DCOM by supporting transport protocol format & Communication protocol. Web Services Vs.NET Remoting 1)web services can only be accessed through HTTP while.net Remoting can use across any protocol. 2)Web Services works in stateless environment whereas.net Remoting supports state management. 3)Web services relies on SOAP while.net Remoting Relies 48 on CLR Assembler.

.NET Remoting Client object Server object Proxy Remoting System Channel Remoting System 49 Remoting Process

.NET Remoting.NET Remoting allows an application to make an object available across Remoting boundaries. The Steps in.net Remoting Process is as follows 1).NET Remoting makes remote object available to client through activation URL. 2)The client Creates a new instance of server class & uses it like a local object. 3)The Remoting System creates a proxy object that represent the class & return to the client object a reference to the proxy. The proxy does not implement the remote objects functionality but provide interface to it. 4) When client calls a method the remoting infrastructure handles the call, check the type information & send call over 50 the channel to server process.

.NET Remoting 5) A listening channel picks up the request & forward it to server Remoting system, which locate & calls the requested object. The process is reversed as server Remoting system bundles response to message that the server channel send to client channel & Finally client Remoting system return the result of call to client object through proxy. 51

52 COMPARISON BETWEEN CORBA,DCOM & RMI

53