1 / 18

C omponent O bject M odel , DCOM and Software Components

C omponent O bject M odel , DCOM and Software Components. Nat Brown COM Program Management Microsoft Corporation With additions by R. Cook. How to Compose Applications?. From components written in any language From components executing on multiple machines

Download Presentation

C omponent O bject M odel , DCOM and Software Components

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ComponentObjectModel, DCOMandSoftware Components Nat Brown COM Program Management Microsoft Corporation With additions by R. Cook

  2. How to Compose Applications? • From components written in any language • From components executing on multiple machines • Allow an application to delegate UI actions and screen space to components (e.g. embed spreadsheet in a document) • Allow applications to be used as components to build other applications (automation)

  3. What is Automation? • Automation is the ability to control an application from another. • Sometimes referred to as scripting. • For example, script can start Excel, load a spreadsheet, add data, save, quit Excel. • Visual Basic for Applications (VBA) is a scripting language which makes use of automation. • Perl (and PerlScript) makes use of automation.

  4. What is a COM Component? • Supports the IUnknown abstract interface • May support other interfaces • No inheritance or other language dependencies • Every interface has a UNIQUE 128-bit # (uuidgen in Windows and OS/X) • Every copy of an interface is reference-counted, although this does not preclude a high-level implementation of garbage collection

  5. What is a COM Component? • Every class has a UNIQUE 128-bit CLSID • A class (implementation) can support multiple interfaces • A class can have a text name, referred to as a PROGID

  6. What is a COM Component? [C#] namespace EsriSamples { [Guid("97FDB5D7-41D8-4260-BF72-3EB2CDD36747")] [ProgID("ZoomInCmd.ZoomIn")] public class ZoomIn: ICommand { ...

  7. class CMyClass : public Iunknown { //C++ private:    ULONG m_cRef;  // COM reference count public: STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject)  { IUnknown *punk = nullptr;         if (riid == IID_IUnknown)             punk = static_cast<Iunknown *>(this); // TODO: List other implemented interfaces here.         *ppvObject = punk;         if (punk == nullptr) return E_NOINTERFACE;         punk->AddRef();         return S_OK;    } STDMETHODIMP_(ULONG) AddRef() { return ++m_cRef; } STDMETHODIMP_(ULONG) Release() {         ULONG cRef = --m_cRef;         if (cRef == 0) delete this;         return cRef; } };

  8. Interface Definition Language - IDL [ object, uuid(75D873CD-7B63-11D3-9D43-00C0F031CDDE), helpstring("IServer Interface"), pointer_default(unique) ] interface IServer : IUnknown { HRESULT HelloWorld([in, string] char * pszMessage); };

  9. In the same process • Fast, direct function calls Component Client Client Process Server Process • On the same machine • Fast, secure IPC Component COM Client • Across machines • Secure, reliable and flexibleDCE-RPC based DCOM protocol Server Machine Client Machine Component DCE RPC COM COM Client The COM Programming ModelA scalable programming model

  10. TCP, UDP IPX, SPX HTTP Msg-Q DCOM ArchitectureFlexible and extensible Pluggable Transports Client Machine Server Machine D C O M D C O M COM Object Clients

  11. TCP, UDP NT4 Security SSL/ Certificates IPX, SPX NT Kerberos HTTP DCE Security Falcon DCOM ArchitectureFlexible and extensible Pluggable Security Client Machine Server Machine D C O M D C O M COM Object Clients

  12. DCOM ArchitectureEfficient and scalable • Multiplexing - Single Port per-protocol, per server process, regardless of # of objects • Scalable - Connection-Less Protocols like UDP Preferred • Established Connection-Oriented (TCP) Sessions Reused by same client Client Server Client

  13. DCOM ArchitectureEfficient and scalable • Low Bandwidth • Keep-Alive Messages bundled for all connections between Machines Client Machine Server Machine Keep-Alive Traffic for all connections Client #1 Server Logical “Connections” or “Sessions” Client #2

  14. Receiver Class Factory Queue Class Factory DLL Register Connections DLL Register RefCounting Context Security RefCounting Management Configuration Query Interface Thread Pool Query Interface IDispatch Service Logic IDispatch Connection Points Connection Points Synchronization Meta Data Type Info Shared Data Methods Server Methods Component Component Ease-of-Use: First Steps Clients Network Receiver Queue Connections Context Security Management Configuration Thread Pool Service Logic Synchronization Shared Data Server MTS = easier servers Easier components?

  15. Additional Technologies • COM+ • MTS - Microsoft Transaction Server • MSMQ - Microsoft Message Queue • 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.

  16. First Steps Basically there is a general model of use: 1) A typical controller process will request that a COM server generate a COM object. 2) The server is loaded or located, the request is submitted, a response is returned. 3) If request results in a valid COM object then controller process interacts with the object. 4) Destroy COM object.

  17. First Steps Let’s say we need to change the title and subject of a Microsoft Word document 1) Need to somehow run Word 2) Need to load up the document 3) Need to change the title and subject 4) Need to save the document 5) Need to quit Word

  18. First Steps How would we implement such a system? Request a Word application COM object Query the appropriate interface Call a function in the Word application COM object which loads a document. It returns a Word document COM object Modify the Title and Subject properties from the Word document COM object Call into the Word document COM object to save to disk Destroy both the document and application COM objects

More Related