200 likes | 295 Views
Microsoft’s Distributed Component Object Model (DCOM). A semi-technical overview. Jim Ries JimR@acm.org Updated 10/5/1999. Genealogy. DCOM comes from COM and OSF (now Open Group ) DCE DCE Remote Procedure Calls (RPC) Interface Definition Language (IDL) Component Object Model (COM)
E N D
Microsoft’s Distributed Component Object Model (DCOM) A semi-technical overview Jim Ries JimR@acm.org Updated 10/5/1999
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
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/
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
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.
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”)
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.
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.
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.)
Coding Tools • C - Raw • C++ - Raw • C++ - ATL • C++ - MFC • Visual Basic • J++ (pseudo Java) • Binary standard ==> any language COULD produce COM components.
Platforms • Win32 • Windows 95 (DCOM as separate download; included in OSR2) • Windows NT 4.0 • Windows 98 • Windows 2000 • Unix platforms (with some help)
Nuts and Bolts • CoInitialize() • CoCreateInstance() • IUnknown • QueryInterface() • AddRef() • Release() • CoUninitialize()
Demonstration - IDL [ object, uuid(75D873CD-7B63-11D3-9D43-00C0F031CDDE), helpstring("IServer Interface"), pointer_default(unique) ] interface IServer : IUnknown { HRESULT Hello([in, string] char * pszMessage); };
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); }
Demonstration - Client Code if (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); }
Distributed Scenario • From “DCOM Architecture” a Microsoft white paper.
Demonstration • Run DCOM “Hello world” demo here.
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.
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