1 / 13

COM

COM. C O M. After this presentation, you will: Be Able To: Conceptual understanding of COM How it works, What it’s used for Decode Acronyms (COM, DCOM, MTS) Know where to go, what to do, next Not Be Able To: Start programming COM (find a technical tutorial for that). omponent.

blawrence
Télécharger la présentation

COM

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. COM C O M • After this presentation, you will: • Be Able To: • Conceptual understanding of COM • How it works, What it’s used for • Decode Acronyms • (COM, DCOM, MTS) • Know where to go, what to do, next • Not Be Able To: • Start programming COM (find atechnical tutorial for that) omponent bject odel

  2. COM “Framework for runtime objects” • OOP, plus ways of interacting with the objects at runtime • Need to be able to create, inspect, use, destroy them • In order to use them, must be able to ask them about what they do, ask them to do things Some Cool Features: • Extensible: doesn’t require any more changes to COM itself (i.e., there is no COM 2.0, 3.0,etc) • Versioning: figuring out which version of an object you want (at runtime) • Language independent: Strongly influenced by C++, but usable in C, VB, Java, plus anything else that you want to do the work for (Python?) • Middleware – doesn’t really do any app. level work, but provides the ‘pipes’ for app.s to do work

  3. COM History: • Started with OLE 1.0: Object Linking and Embedding, or “How do I drop an Excel spreadsheet into Word?” • Worked, but badly, OLE didn’t look like COM • OLE 2.0: OLE built over COM, and so version number stops here • ActiveX: COM is cool, but the Internet showed up, MS wrote up a collection of COM stuff specifically oriented at Internet use: how to download, sign, install COM objects. • Thus, COM is the framework/architecture/infrastructure over which OLE (business stuff), and ActiveX (Internet stuff) is built

  4. COM Example of a COM session Server supports the creation of random numbers, Client wants a random number Client 1) Client creates an instance of CRandom (via CoCreateInstance system call) COM 2) COM locates the server, if not already running, COM starts it, asks server to create an instance of CRandom CRandom Server Newly Created object 3) CRandom server creates an instance of CRandom, and hands a pointer back to the client

  5. COM Example of a COM session (con’t) Client 4) Client can interrogate the object about what it can do, then invoke methods on the object. CRandom Server CRandom object 5) Client finishes using the object, then calls the Release method to tell the object that the client is finish. 6) At this point, the object deletes itself, and the server figures out if it can be unloaded. If so, either it or COM unloads it from memory.

  6. COM More Technical Overview: Phases: Location: How to name objects, how does COM know where the servers are to be found? Creation: How does one create individual instances of an object? Communication: How do the objects talk to each other in a standard way? Teardown: How to manage destruction, especially since multiple client may be using the same object simultaneously?

  7. COM Location Phase: • Naming Objects: • Decentralized, guaranteed to be unique names • UUID: Universally Unique IDentifier • GUID: Globally Unique Identifier • Guidgen tool is provided to make these for you. • How does COM Locate stuff? • Registry: • an OS level DB that holds (among other things) locations of code info about the code, etc

  8. COM Creation Phase: Once request to create the object has been given to COM, and it’s figured out where the object server is, it starts the server (if it hasn’t been started yet), and asks it to create another instance of the object via…. Class Factory: Another COM class, except that it has no GUID associated with it (uses the GUID of the object it creates), responsible for creating new objects. Note that this process differs in different languages (e.g., C++ vs. C). Since whoever writes the COM server also writes the Class Factory, this also gives some power in being able to control how objects are created -- could create a single instance & share among the clients, or create lots and lots, etc.

  9. COM Communication Phase: • Interfaces: • All communication between clients and objects are done • through INTERFACES. To the client, calling any method • on any object is exactly the same, except for arguments and • return values. Thus there is a standard way of getting • clients to communicate with objects. • Every interface derives from IUnknown, which contains three • methods: • QueryInterface: Does object support interface X? • AddRef: Tell object that something else is using interface • Release: Tell object that something is finished using interface • Code to marshal arguments between client and object • may be needed (e.g., cross process)

  10. COM Teardown Phase: How does COM know when to deallocate stuff? It doesn’t -- the objects themselves know, by keeping a reference count of clients. Each time a client asks for an interface (or calls AddRef), this count gets bumped up. Each time the client calls the Release() method on an interface, the reference count get decremented. When the reference count is zero, the object can deallocate itself (i.e., delete this; ) Recurrent theme objects keep refcounts to know when to deallocate, object servers keep reference counts on number of outstanding objects to know when they can be shut down Within the IClassFactory interface, the LockServer method keeps a reference count so that the object server WON’T shut down, etc

  11. COM Other Issues: • Containment/Aggregation – inheritance • Threading -- couple of different threading models • IDispatch • Run time use of interfaces & methods • Used by interpreted/macro languages (Java, VB) so • they don’t have to recompile to use a new interface • Uses Type Libraries, which contain descriptions • of methods, the arguments, etc

  12. COM Recent Developments • DCOM • (Distributed COM) • How to instantiate / use components • residing on different computers? Also • needs to worry about security, more • efficient ways of asking about interfaces, • etc • MTS • (MS Transaction Server ) • Runtime environment layered over DCOM • to support scalable , fault tolerant apps • COM+ (not yet released) • Runtime environment, makes it easier to use COM • Beyond that, ???

  13. COM Further References, Resources: • Books • Inside COM • Professional DCOM programming • Essential COM • My Web page • http://www.csuglab.cornell.edu/home/ • mwp3/COM_Tutorial/index.html • MS web site • http://www.microsoft.com/oledev • Mailing lists • http://www.microsoft.com/sitebuilder/resource/mailfaq.asphttp://microsoft.ease.lsoft.com/archives/index.html • Each other in Quintet– ask around!

More Related