DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer...

33
DCOM Technology DCOM Technology

Transcript of DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer...

Page 1: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

DCOM TechnologyDCOM Technology

Page 2: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

What What is DCOM?is DCOM?

DCOM is just COMDCOM is just COM with a longer wirewith a longer wireDCOM extends COM to support DCOM extends COM to support

communication among objects on different communication among objects on different computerscomputers

Page 3: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

CComponent omponent OObject bject MModelodel

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

COM objects can be created with a variety COM objects can be created with a variety of programming languages. Object-of programming languages. Object-oriented languages, such as C++, provide oriented languages, such as C++, provide programming mechanisms that simplify programming mechanisms that simplify the implementation of COM objects. the implementation of COM objects.

Page 4: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Understanding COMUnderstanding COM

not an object-oriented language but a not an object-oriented language but a binary standardbinary standard

COM specifies an object model and COM specifies an object model and programming requirements that enable programming requirements that enable COM objects (also called COM COM objects (also called COM components) to interact with other objectscomponents) to interact with other objects

Page 5: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

COM Design PrinciplesCOM Design Principles

Binary componentsBinary componentsAny programming languageAny programming languageAny location(in-process, cross-process, cross-Any location(in-process, cross-process, cross-

machine)machine)Zero sacrifice in-proc performanceZero sacrifice in-proc performanceSimplest model possibleSimplest model possible

Enable extensibility and adaptabilityEnable extensibility and adaptability

Page 6: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

EncapsulationEncapsulationBlack box - no leakage of implementation Black box - no leakage of implementation

detailsdetailsAll object manipulation through strict All object manipulation through strict

interfacesinterfacesPolymorphismPolymorphism

via multiple via multiple interfacesinterfaces per class per class ““Discoverable”: QueryInterfaceDiscoverable”: QueryInterface

COM Design Principles..COM Design Principles..

COMObject

IUnknown

IRobot

IDispatch

Page 7: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

InterfacesInterfaces

IUnknownIUnknown AddRefAddRef ReleaseRelease QueryInterfaceQueryInterface

IDispatchIDispatch GetIDsOfNamesGetIDsOfNames GetTypeInfoGetTypeInfo GetTypeInfoCountGetTypeInfoCount InvokeInvoke

Custom InterfacesCustom Interfaces

Page 8: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

COM ArchitectureCOM Architecture

Communication details handled by the COM run-time

Page 9: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

DCOM ArchitectureDCOM Architecture

Page 10: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Proxy & StubProxy & Stub

Page 11: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

DCOM Wire ProtocolDCOM Wire Protocol

COMCOMClientClient

Component

CO

M R

unti

me

Server MachineClient Machine

TCP, UDP

SPX,IPX

Net BUI

HTTPCO

M R

unti

me

Proxy

Other Component

Page 12: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

DCOM SecurityDCOM Security

Secure - Security is designed and built in. Not an Secure - Security is designed and built in. Not an option.option.

DCOM uses the extensible security framework DCOM uses the extensible security framework provided by Windows NT. provided by Windows NT.

Security configurableSecurity configurable DCOM stores Access Control Lists for componentsDCOM stores Access Control Lists for components ACLsACLs cancan be configured using the DCOM be configured using the DCOM

configuration tool (DCOMCNFG) or programmatically configuration tool (DCOMCNFG) or programmatically using the Windows NT registry and Win32 security using the Windows NT registry and Win32 security functions. functions.

Page 13: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

COM Security ArchitectureCOM Security Architecture

COMCOMClientClient

Component

CO

M R

unti

me

Server MachineClient Machine

DCE

NT Kerberos

SSL, Certs.

NTLM

CO

M R

unti

me

Proxy

Other Component

Page 14: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Components & ReuseComponents & Reuse

Use existing tools and componentsUse existing tools and componentsReduce development time and costReduce development time and costCOM components easily configured as COM components easily configured as

DCOM componentsDCOM componentsCOM can use many other componentsCOM can use many other componentsCOM components are usable by many COM components are usable by many

technologiestechnologies

Page 15: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Location TransparencyLocation Transparency

COM Object locations are stored in COM Object locations are stored in registryregistry

Applications make calls using the globally Applications make calls using the globally unique CLSID.unique CLSID.

Path to COM server, or remote computer Path to COM server, or remote computer to run DCOM server is not needed by the to run DCOM server is not needed by the application.application.

Page 16: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Language NeutralityLanguage Neutrality

Various languages can be used to Various languages can be used to create components.create components.VB, Delphi for rapid developmentVB, Delphi for rapid developmentVC++, Java for advanced developmentVC++, Java for advanced developmentMicro Focus COBOLMicro Focus COBOL

Even more languages can be used to Even more languages can be used to use COM componentsuse COM componentsAdditionally scripting languages like VB Additionally scripting languages like VB

Script, JScriptScript, JScript

Page 17: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Connection ManagementConnection Management

Low BandwidthLow Bandwidth Header is 28 bytes over DCE-RPCHeader is 28 bytes over DCE-RPC Keep-Alive Messages bundled for all connections Keep-Alive Messages bundled for all connections

between Machinesbetween Machines

COM employs an efficient pinging protocol COM employs an efficient pinging protocol to detect if clients are activeto detect if clients are active

COM uses reference counting mechanism COM uses reference counting mechanism to do garbage collectionto do garbage collection

Page 18: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Efficient and ScalableEfficient and Scalable

Multiplexing - Single Port per-protocol, per server Multiplexing - Single Port per-protocol, per server process, regardless of # of objectsprocess, regardless of # of objects

Scalable - Connection-Less Protocols like UDP PreferredScalable - Connection-Less Protocols like UDP Preferred Established Connection-Oriented (TCP) Sessions Established Connection-Oriented (TCP) Sessions

Reused by same clientReused by same client

ServerServerClientClient

ClientClient

Page 19: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Load BalancingLoad Balancing

DCOM does not transparently provide load DCOM does not transparently provide load balancingbalancing

Makes it easy to implement load balancingMakes it easy to implement load balancingStatic load balancingStatic load balancingDynamic load balancing by means of a Dynamic load balancing by means of a

dedicated referral componentdedicated referral component

Page 20: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Platform NeutralityPlatform Neutrality

DCOM run-time is available for various platformsDCOM run-time is available for various platforms Win32 platforms, Solaris, Win32 platforms, Solaris, DEC UNIX, HPUX, Linux, DEC UNIX, HPUX, Linux,

MVS, VMS, MacMVS, VMS, Mac Cross-Platform Interoperability StandardCross-Platform Interoperability Standard

Per-Platform binary standardPer-Platform binary standard Unlike java, DCOM can utilizeUnlike java, DCOM can utilize powerful platform- powerful platform-

specific services and optimizationsspecific services and optimizations Less abstraction layers prevents additional overheadsLess abstraction layers prevents additional overheads

Page 21: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Creating a simple COM serverCreating a simple COM server

Page 22: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

ATL COM AppWizardATL COM AppWizard

Page 23: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

New ATL ObjectNew ATL Object

Page 24: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

ATL Object AttributesATL Object Attributes

Page 25: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Add New MethodAdd New Method

Page 26: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Interface Definition LanguageInterface Definition Language

......

[[

object,object,

uuid(79522A15-BA3D-46A5-92D6-DA4BE60646F4),uuid(79522A15-BA3D-46A5-92D6-DA4BE60646F4),

dual,dual,

helpstring("ISimple Interface"),helpstring("ISimple Interface"),

pointer_default(unique)pointer_default(unique)

]]

interface ISimple : IDispatchinterface ISimple : IDispatch

{{

[id(1), helpstring("method StringLen")] HRESULT StringLen([in] [id(1), helpstring("method StringLen")] HRESULT StringLen([in] BSTR str, [out,retval] BSTR str, [out,retval] long* long* length);length);

};};

......

Page 27: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Source & Header FileSource & Header File

Source:Source:STDMETHODIMP CSimple::StringLen(BSTR str, long* length)STDMETHODIMP CSimple::StringLen(BSTR str, long* length)

{{

*length = SysStringLen(str);*length = SysStringLen(str);

return S_OK;return S_OK;

}}

Header:Header:......

public:public:

STDMETHOD(StringLen)(/*[in]*/ BSTR str, /*[out,retval]*/ STDMETHOD(StringLen)(/*[in]*/ BSTR str, /*[out,retval]*/ long* length);long* length);

......

Page 28: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Creating a Simple COM ClientCreating a Simple COM Client#include <stdio.h>#include <stdio.h>#import "SimpleCom.exe"#import "SimpleCom.exe"

int main(int argc, char* argv[])int main(int argc, char* argv[]){{

SIMPLECOMLib::ISimplePtr pSimple;SIMPLECOMLib::ISimplePtr pSimple;long len;long len;CoInitialize(NULL);CoInitialize(NULL);pSimple.CreateInstance(__uuidof(SIMPLECOMLib::Simple));pSimple.CreateInstance(__uuidof(SIMPLECOMLib::Simple));len = pSimple->StringLen("sample");len = pSimple->StringLen("sample");printf("Length = %d\n", len);printf("Length = %d\n", len);CoUninitialize();CoUninitialize();return 0;return 0;

}}

Page 29: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Exception HandlingException Handling

trytry

{{

len = pSimple->StringLen("sample");len = pSimple->StringLen("sample");

}}

catch (_com_error &e)catch (_com_error &e)

{{

printf(“%s\n”, e.Description());printf(“%s\n”, e.Description());

}}

Page 30: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Registering COM ObjectsRegistering COM Objects

COM dllCOM dllTo register: regsvr32 mycom.dllTo register: regsvr32 mycom.dllTo un-register: regsvr32 –u mycom.dllTo un-register: regsvr32 –u mycom.dll

COM exeCOM exeTo register: mycom.exe /regserverTo register: mycom.exe /regserverTo un-register: mycom.exe /unregserverTo un-register: mycom.exe /unregserver

Page 31: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Configure as DCOMConfigure as DCOM

Page 32: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

Protocols for DCOMProtocols for DCOM

Page 33: DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.

ReferancesReferances

MSDN Library OnlineMSDN Library OnlineProfessional ATL COM programming , Professional ATL COM programming ,

Richard Grimes, Wrox PublishingRichard Grimes, Wrox Publishing