19
Microsoft’s Distributed Component Object Model (DCOM) Jim Ries [email protected] Updated 10/5/1999 A semi-technical overview

Microsoft’s Distributed Component Object Model (DCOM) Jim Ries [email protected] Updated 10/5/1999 A semi-technical overview

Embed Size (px)

Citation preview

Page 1: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Microsoft’s Distributed Component Object Model (DCOM)

Jim Ries

[email protected]

Updated 10/5/1999

A semi-technical overview

Page 2: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Genealogy DCOM comes from COM and OSF

(now Open Group) DCE DCE

Remote Procedure Calls (RPC) Interface Definition Language (IDL)

Component Object Model (COM) ORPC

OMG CORBA - a parallel standard Different RPC Different IDL COM proxy == CORBA stub COM stub == CORBA skeleton

Page 3: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Microsoft proprietary, but . . . Open Group’s COMSource:

http://www.opengroup.org/comsource/

Software AG’s EntireX: http://www.softwareag.com/entirex/default.htm

The Active Group: http://www.activex.org/

Page 4: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

COM Goals Encapsulation (separate

implementation from interface) Versioning Execution context independence Language independence Object Creation / Lifetime Control Standard error code (HRESULT) Solve object discovery problem Scripting The Holy Grail of Reuse

Page 5: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Alphabet soup:COM/OLE/ActiveX

COM is a binary standard and a style for creating objects.

OLE is (was) a set of COM interfaces for embedding documents (originally “Object Linking and Embedding”).

ActiveX is a marketing buzz-word meaning COM and/or OLE, but usually applied to Internet-oriented components.

Page 6: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Later and later binding “Editor inheritance” binds at

compile time. Link libraries (.LIB) bind to

“components” at link time. Dynamic link libraries (.DLL) bind

at run time, but need a header at compile time, and path at runtime.

COM components bind at runtime and may need neither a header, nor a path! (though typelib contains header-like “meta-data”)

Page 7: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Interfaces COM enforces the concept of

interfaces being separate from implementation.

Interface == Abstract Base Class Objects support multiple interfaces

through multiple inheritance. Interfaces NEVER change! A “control” is just a COM component

with the right interfaces.

Page 8: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

GUID’s (or UUID’s)

Globally Unique Identifiers (Universally Unique Identifiers)

Needed to avoid name collisions A class is associated with a GUID

(CLSID). An interface is associated with a

GUID (IID). The Windows Registry: a

hierarchical database.

Page 9: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Execution Context In proc - DLL’s (no marshalling) Out of proc - EXE’s (LRPC) Remote - EXE’s using DCOM

RPC DCE “compatible” (see

“Interconnecting Personal Computers with the Distributed Computing Environment” by Jim Ries, UMC Thesis, 1998.)

Page 10: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Coding Tools C - Raw C++ - Raw C++ - ATL C++ - MFC Visual Basic J++ (pseudo Java) Binary standard ==> any language

COULD produce COM components.

Page 11: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Platforms Win32

Windows 95 (DCOM as separate download; included in OSR2)

Windows NT 4.0 Windows 98 Windows 2000

Unix platforms (with some help)

Page 12: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Nuts and Bolts CoInitialize() CoCreateInstance() IUnknown

QueryInterface() AddRef() Release()

CoUninitialize()

Page 13: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Demonstration - IDL

[

object,

uuid(75D873CD-7B63-11D3-9D43-00C0F031CDDE),

helpstring("IServer Interface"),

pointer_default(unique)

]

interface IServer : IUnknown

{

HRESULT Hello([in, string] char * pszMessage);

};

Page 14: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Demonstration - Server Code// Prototype

class CServer :

public IServer, public CComObjectRoot, public CComCoClass<CServer,&CLSID_Server>

{

// . . . Some code omitted for brevity

// IServer

public:

HRESULT STDMETHODCALLTYPE Hello(unsigned char * pszMessage);

};

// Code

HRESULT STDMETHODCALLTYPE CServer::Hello(unsigned char * pszMessage)

{

char szBuf[256];

wsprintf(szBuf,"%s",pszMessage);

::MessageBox(0,szBuf,"Server",MB_OK);

return(S_OK);

}

Page 15: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Demonstration - Client Codeif (SUCCEEDED(

hr=CoCreateInstance(CLSID_Server,NULL,

CLSCTX_LOCAL_SERVER,

IID_IServer,(void **)&pServer)))

{

if (SUCCEEDED(hr=pServer->Hello((unsigned char *)"Hello from the client")))

MessageBox("Client: Server printed the message");

else

{

wsprintf(szBuffer,"Hello() method failed: 0x%lX.\n",hr);

MessageBox(szBuffer);

}

pServer->Release();

}

else

{

wsprintf(szBuffer,"Unable to create a server: 0x%lX.\n",hr);

MessageBox(szBuffer);

}

Page 16: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Distributed Scenario

From “DCOM Architecture” a Microsoft white paper.

Client ComponentProxy Object

DCE RPC

Protocol Stack

Stub

DCOM network-protocol

SecurityProvider

DCE RPC

Protocol Stack

SecurityProvider

SCM SCM

OLE32

"CoCreateInstance"

(Remote)Activation

"CoCreateInstance"

Page 17: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Demonstration

Run DCOM “Hello world” demo here.

Page 18: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

Additional Technologies COM+

MTS - Microsoft Transaction Server MSMQ - Microsoft Message Queue Compiler supported IUnknown, etc.

ADS - Active Directory Service As “distributed registry” As namespace abstraction

All Microsoft products are COM based: IIS - Internet Information Server Exchange Internet Explorer Word, Excel, etc.

Page 19: Microsoft’s Distributed Component Object Model (DCOM) Jim Ries JimR@acm.org Updated 10/5/1999 A semi-technical overview

References Microsoft DCOM page IETF DCOM Standard Proposal Inside OLE by Kraig Brockschmidt, Microsoft

Press, 1995. Essential COM by Don Box, Addison Wesley,

1998. Inside COM by Dale Rogerson, Microsoft Press,

1997. Don Box homepage ActiveX COM Control Programming by Sing Li

and Panos Economopoulos, Wrox Press, 1997. COM-CORBA Interoperability by Geraghty, et.

al., Prentice Hall, 1999. Microsoft Developer Network