Introduction

Like most developers, I have a full shelf of technical books. In the lower-right corner, however, I keep three or four books on a ledge of their own, at close reach. I think of these few books as my landmark books—the books that brought me to an entirely new level of understanding and capability. These books all share an uncanny capability: At first reading, they introduce and demystify concepts, and then in later readings, they serve as a detailed technical reference providing critical details I simply can't find anywhere else. From the moment I began writing, my mission was to make Applying COM+ that kind of book.

If you are a Visual Basic and/or C++ developer and want to understand how COM+ actually works, as opposed to how it is supposed to work or the documentation claims it works—this is the book for you. You can read this book conceptually and understand the capabilities of COM+; but it is, first and foremost, a detailed declarative book for intermediate to advanced developers who want to fully understand and leverage the capabilities of COM+ in Visual Basic, C++, or both. Traditional COM and related concepts are discussed in the first few chapters; then the book builds on this foundation just as COM+ does—each COM+ service will be explored in detail, with extensive language examples in Visual Basic, C++ and, at times J++. Although many technical books use terms like "Usually" and "For the most part," I put a great deal of effort into making absolute, definitive statements so that explanations and demonstrations are concise and perfectly clear. Such statements require an enormous amount of research and empirical testing to support; but as far as I am concerned, nothing should be left as an exercise for the reader. I have been working extensively with Microsoft technology for 10 years, I have built a successful Wall Street consulting and training firm specializing in COM development, and it is my responsibility to teach you everything I know.

Who Will Benefit From This Book?

Intermediate to advanced C++ and Visual Basic developers will benefit significantly from this book, particularly if they understand COM superficially, but now need a complete understanding of both COM and COM+. Specifically, the book will do the following:

  • Provide a thorough grounding in core COM concepts and then demonstrate how these concepts are used to facilitate each COM+ service.

  • Explain each COM+ service conceptually and then go into detail using what-if scenarios and extensive code examples.

  • Point out "gotchas", where the development reality differs from intuition and documentation, providing workarounds where necessary.

  • Fill in many missing details not found in supporting documentation, other books, and articles.

  • Fill in many details about supporting technologies not usually discussed in detail—Microsoft's Distributed Transaction Coordinator (DTC), Resource Dispensers, and so on.

  • Demonstrate the "how-to" of COM+ with extensive supporting sample code in both VB and C++, and at times, J++.

  • Provide extensive source code demonstrating concepts discussed in the book and advanced techniques that, though not specific to COM+, are generally useful.

Development managers might also find the conceptual explanations in this book helpful in understanding the capabilities of COM+. However, the reader should be comfortable programming in Visual Basic, C++, or both.

Who Is This Book Not For?

This book is not intended for junior developers who are just beginning their development careers and are looking for an especially gentle introduction. Similarly, those desiring a purely theoretical, bird's-eye treatment of COM+ might find this book too detailed.

Organization of This Book

Chapter 1, "COM+: An Evolution," provides a high-level discussion of COM+ services and an introduction to COM+'s underlying technology, COM. The concept of interfaces is introduced, and a comparison is drawn between COM interfaces and Remote Procedure Call (RPC) interfaces. Interface Definition Language (IDL) is discussed as it applies to both RPC and COM.

Chapter 2, "COM Fundamentals," bores into the make-up of COM interfaces, exploring the importance of IUnknown and discussing reference counting, querying objects for additional interfaces, and the relationship between COM objects and Dynamic Link Libraries (DLLs). Necessary registry entries, type libraries, and other implementation details are also introduced and discussed.

Chapter 3, "COM Internals," explores COM as it is fully implemented in C++. Interfaces are shown to take the form of abstract base classes, and multiple inheritance is shown to be a convenient mechanism for implementing COM classes in C++. A complete walk-through of a C++ COM component is included.

COM takes advantage of Win32 threading to provide synchronization and protection between components. Chapter 4, "Threading and Apartment Models," begins with a discussion of threading in general and then offers a detailed explanation of the three apartment models: Single-Threaded Apartment, Multi-Threaded Apartment, and the Thread Neutral Apartment.

COM clients can call methods on objects when they have knowledge of the object's interfaces or methods (via a type library). They can also do so, however, even if they do not know anything about the object. These two techniques are referred to as early and late binding, respectively, and they are the subject of Chapter 5, "Method Invocation and Marshaling."

To take advantage of COM+ services, a component must be configured. Configuration data is stored in the COM+ Catalog, a new repository that ships with Windows 2000 and replaces the Registry in many ways. Chapter 6, "The COM+ Catalog," demonstrates how to configure components and their parent COM+ applications using COM+'s Component Services snap-in. The chapter also demonstrates how configuration can be automated via the COM+ administration objects.

Chapter 7, "Contexts,"explores how contexts are used to identify an object's run-time capabilities and expectations. As contexts originate with Microsoft Transaction Server (MTS), interactions between MTS objects and their contexts are discussed and demonstrated. The concept of context flow—that is, the flowing of context information from creating object to created—is introduced, and the chapter ends by describing the enhanced roles contexts play in COM+.

COM+ enables multiple objects to participate in distributed database transactions that might span multiple machines and relational databases. Chapter 8, "Transactions," discusses how the Resource Dispenser, objects and their contexts, the Distributed Transaction Coordinator (DTC), and the Dispenser Manager work together to make distributed transactions possible. Object statefulness and voting on a transaction's outcome are also explored in detail.

Writing a fully functional Resource Manager capable of transactions is difficult. Chapter 9, "Compensating Resource Managers," explains how to write a Compensating Resource Manager (CRM) which simplifies this task. The interfaces of a CRM are explored in-depth, and CRM behavior in different transactional scenarios is discussed.

Queued Components is the subject of Chapter 10, "Queued Components." Traditional COM method calls are synchronous, but method calls made on Queued Components may be asynchronous. COM+ Queued Components rely on Microsoft Message Queue (MSMQ) for asynchronous functionality, and MSMQ is discussed in detail. A queued application's interaction with transactional and non-transactional queues are discussed as well as the instantiation of Queued Components via the queue moniker.

Client applications can benefit from being able to receive notification events. Chapter 11, "Events," discusses COM+'s publisher-subscriber metaphor and explains how it is implemented via event classes. It includes additional discussion on synchronous and asynchronous events and techniques of using both.

Chapter 12, "Security," discusses COM+ role-based security and demonstrates how valid NT accounts can be associated with one or many COM+ roles. It then explores how these roles can be associated with components, interfaces, and methods, thereby allowing or disallowing access to these resources for particular users. A lower-level discussion of NT/RPC based security involving impersonation, cloaking, and authentication is also included.

The book concludes with six appendixes: Appendix A, "ADO and OLE-DB,"Appendix B, "COM+ Synchronization Through Activities,"Appendix C, "Object Pooling,"Appendix D, "Passing Block Data, SAFEARRAYs,"Appendix E, "Queue Moniker Parameters," and Appendix F, "Application Proxies."

Accompanying source code for ApplyingCom+ can be found at http://www.newriders.com/complus.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.156.236