You are previewing Applying COM+.
O'Reilly logo
Applying COM+

Book Description

COM+ is Microsoft¿s new version of its COM object-oriented programming framework. Built into Windows 2000, this is an extremely powerful and complex technology that consolidates the features of a number of existing Microsoft tools: OLE, ActiveX, DCOM, Microsoft Message Queue, and Microsoft Transaction Server. By pulling all of these disparate services into one unified technology, COM+ hold the promise of greater efficiency and more diverse capabilities for developers who are creating applications - either enterprise or commercial software -- to run on a Windows 2000 system. The demand for reliable and real-world application-based information on COM+ is huge, and so far greatly exceeds the availability of such documentation. This book will provide a coherent, unified view of the COM+ architecture.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewers
  4. Acknowledgments
  5. Tell Us What You Think
  6. Introduction
    1. Who Will Benefit From This Book?
    2. Who Is This Book Not For?
    3. Organization of This Book
  7. I. COM Basics
    1. 1. COM+: An Evolution
      1. COM+ and the Declarative Model
        1. The Difference Between COM and COM+
        2. Fundamental Principles of COM and COM+
        3. The Theoretical Reason for Interfaces
        4. The Practical Reason for Interfaces
      2. RPC: The Origin of COM Interfaces?
        1. Interface Definition Language
          1. Compiling the IDL File
        2. What Does COM Have to Do with RPC?
          1. From Traditional RPC to COM and COM+
      3. IDL: the Beginning or the End?
        1. COM Objects in Visual C++
          1. The coclass
          2. Implementing the coclass in in C++
        2. Visual Basic
        3. Finding Registered Type Libraries
          1. The The Library Block
          2. Interface Block, Revisited
          3. Inheriting from IDispatch
          4. Method Declarations
      4. Summary
    2. 2. COM Fundamentals
      1. The Role of IUnknown
        1. Release()
          1. Implementing Release()
        2. AddRef()
          1. Guidelines for Reference Counts and Object Lifetime
        3. QueryInterface()
          1. Using QueryInterface()
      2. Where Does COM Live?
        1. Dynamic Link Libraries (DLLs)
          1. Type Libraries and Resources
          2. The Registry and Self-Registration
        2. A COM+ Variation—Surrogate Processes
      3. Summary
    3. 3. COM Internals
      1. Virtual Function Tables (vtables), Abstract Base Classes, and Polymorphism
        1. Interfaces as Abstract Base Classes
        2. Polymorphism in Practice
          1. Writing COM Objects in C++
        3. Internal Structure of a Vtable
          1. The ICalc and IFinancial Vtables and Their Relation to COMCalc
          2. C++ Clients
          3. Problems with the Fundamental Tenet of COM
        4. Putting It All Together (RPC, DLL, Type Libraries, vtables)
      2. COMCalc C++ Example
        1. Specifying GUIDs in Code
        2. Inheriting from IUnknown
        3. STDMETHOD, STDMETHODIMP, and Method Implementation
        4. Multiple Inheritance
        5. Implementation of QueryInterface()
        6. Class Factories
        7. Class Factories, IClassFactory, and Other Interfaces
        8. IClassFactory's CreateInstance() Method
        9. Global Scope for Class Factories
        10. The Win32 CoGetClassObject() Method
      3. Summary
  8. II. COM+ Components and Services
    1. 4. Threading and Apartment Models
      1. Threads and Processes
        1. Race Conditions and Threading Issues
      2. Apartments
        1. Message Queues as Synchronization Aides
        2. Threads and Objects
          1. Serialization Through Message Queues
          2. Enter The Apartment
            1. Single-Threaded Apartments (STA)
            2. Multi-Threaded Apartments (MTA)
            3. Protecting the STA with Message Queues
      3. Marshaling Interfaces
        1. Global Interface Table (GIT) Marshaling
        2. Moving Interfaces Between Processes
        3. Marshaling Interfaces the Hard Way
      4. Declaring Apartments
        1. The Free-Threaded Marshaler (FTM)
        2. The Thread Neutral Apartment (TNA)
      5. Summary
    2. 5. Method Invocation and Marshaling
      1. Type Library Marshaling
      2. Late Binding
        1. The Architecture of Late Binding
        2. Invoke Arguments and Marshaling
          1. The Variant
            1. What Can a Variant Hold?
          2. Invoking a Method on IDispatch
        3. Late Binding, Type Libraries, and the Tale of IDispatch
          1. Object Definition Language (ODL) Files
          2. Dispinterfaces
          3. Dual Interfaces
      3. Late Binding, Marshaling, and the oleautomation Tag
        1. J++ and Dual Interfaces
        2. Supporting Dual or Custom Interfaces in J++
        3. Examining the Wrapper
      4. Summary
      5. References
    3. 6. The COM+ Catalog
      1. From INI Files to the Registry to the Catalog
        1. Configured Components and COM+ Applications
      2. General COM+ Applications
        1. Installing or Creating a New Application
        2. Application Identity
        3. Importing versus Installing Components
      3. Automating Configuration
        1. The COM+ Administration Objects Properties
        2. Introducing the COM+ Administration Objects
        3. Using the Administrative Objects
      4. A Quick Tour: Pre-Installed COM+ Applications
        1. COM+ QC Dead Letter Queue Listener
        2. COM+ Utilities
        3. IIS In-Process Applications and IIS Out-Of-Process Pooled Applications
        4. IIS Utilities
        5. System Application
        6. Visual Studio APE Package
      5. CRCs: A Snooper's Best Friend
      6. Summary
    4. 7. Contexts
      1. Introducing IObjectContext
      2. COM and MTS Integration
        1. COM and MTS Merge
      3. Context: Two Different Definitions
        1. Context: The Concept
      4. COM Context Implementation
        1. Interception
        2. Contexts, Apartments and the Free Threaded Marshaler
      5. Understanding and Using the Context Interfaces
        1. IObjectContextInfo
        2. ISecurityCallContext
        3. IGetContextProperties
      6. Summary
    5. 8. Transactions
      1. ROLLBACK and COMMIT
      2. Classical Transactions and Traditional Databases
        1. Atomicity
        2. Consistency
        3. Isolation
        4. Durability
      3. A Transaction Scenario
        1. The BEGIN TRANSACTION and COMMIT TRANSACTION Commands
        2. Distributed Transactions
      4. The DTC
        1. Escrow and the Two-Phase Commit
        2. The Two-Phased Commit Protocol
        3. System Failure and Reconciliation
      5. Microsoft's DTC: The Reality
        1. Using Raw DTC to Coordinate Transactions Across Multiple Databases
        2. Differences in Transaction Enlistment
          1. Transaction Enlistment by Pooled Objects
        3. Summary of Distributed Transactions and the DTC
      6. COM+ Transactions
        1. COM+ Transaction Declarative Settings
        2. RDs: A First Look
        3. COM+ Transaction Behavior: Voting
          1. Base Clients, Voting, and the TransactionContext Object
          2. The Methods of IObjectContext
            1. CreateInstance: A Legacy Method
            2. Basic Voting and Associated Methods
            3. Basic Informational Methods
        4. Finer Granularity Control with IContextState
      7. Transactions, ASP Pages, and IIS
      8. Summary
    6. 9. Compensating Resource Managers
      1. The Resource Manager
      2. Components of the CRM
        1. Worker
          1. The CRMClerk
        2. Compensator
          1. Phase I: Prepare
            1. Step 1: General Prepare
            2. Step 2: Prepare to Make Changes for Each Log Entry
            3. Step 3: Finalize Changes
          2. Phase II: Commit
            1. Step 1: Prepare to Commit
            2. Step 2: Make Changes for Each Log Entry
            3. Step 3: Commit Changes
      3. Aborting Transactions
        1. Step 1: Prepare to Abort
        2. Step 2: Undo Each Log Entry
        3. Step 3: Finalizing Abortion
      4. Handling Recovery
      5. When In Doubt
      6. The Complete Compensator
      7. CRMs and Isolation
      8. Summary
    7. 10. Queued Components
      1. The Mystery of the Hanging News Feeder
      2. Introducing Microsoft Message Queue
        1. MSMQ as Middleware
        2. MSMQ Sender Implementation
          1. Creating and Opening a Queue
          2. Sending the Message
        3. MSMQ Receiver Implementation
          1. Receiving a Message
          2. Closing and Deleting a Queue
      3. From MSMQ to COM+ Queued Components
        1. Asynchronous Methods Calls with Queued Components
        2. The Queued Components Abstraction: Introducing the Player, Listener, and Recorder
          1. Creating a Queued Object Using a Moniker
          2. The Recorder
          3. The Player
          4. Writing Queueable Objects
          5. Queueable Settings for the Application
        3. QC Internals
          1. Disabling Security
          2. Viewing Method Calls as Messages
          3. Playing the Messages
        4. Transactional and Non-Transactional Queues
        5. The Different Queue Types: Private and Public
        6. Interoperability Between MSMQ and QC
          1. Manually Reading the Message
        7. Persistence: Passing Objects Through Messages
        8. Notification and Callbacks
          1. Exception Classes
          2. Callbacks and Events
        9. Some Subtle Requirements for QC: Parallel Application Configurations Required for Sender and Receiver
      4. Asynchronous COM
        1. Asynchronous COM Implementation
        2. Asynchronous COM Drawbacks
      5. Summary
    8. 11. Events
      1. Traditional COM Events
        1. The Doubtful Future of Connection Points
      2. The COM+ Event Model: Publisher and Subscriber
        1. The Event Class
          1. Creating an Event Class
          2. Writing and Installing an Event Class
        2. Subscriptions
        3. Firing Synchronous and Asynchronous Events
          1. Queued Event Classes versus Queued Subscribers
      3. Event Filtering
        1. Publisher Filters
          1. Associating Publisher Filters with Event Classes
            1. COM+ Administration Objects
            2. Explicit Association of Publisher Filters by Clients
        2. Implementing Publisher Filters
          1. Initialize
          2. PrepareToFire
        3. Publisher Strategies
          1. Publisher Properties
          2. Evaluating Method Arguments
      4. Summary
    9. 12. Security
      1. Declarative Security
        1. Entering Users in a Role
        2. Granting Permissions to a Role
        3. Configuring and Programming Security
      2. Programming Security
        1. ISecurityCallContext
        2. Application Identity
      3. Security Boundaries
        1. Impersonation
        2. Delegation
        3. Cloaking
        4. Authentication
        5. Configuring Impersonation, Delegation, and Authentication
      4. Lower Level Security
        1. The CoInitializeSecurity Function
        2. The CoSetProxyBlanket() Function
      5. Lower Level Security, Roles and Cloaking: Bringing It All Together
      6. Summary
  9. III. Appendixes
    1. A. ADO and OLE-DB
      1. ODBC versus OLE-DB
      2. Using ADO in COM+
      3. ADO Examples
    2. B. COM+ Synchronization Through Activities
      1. Configuration
      2. Activities and Transactions
    3. C. Object Pooling
    4. D. Passing Block Data, SAFEARRAYs
    5. E. Queue Moniker Parameters
      1. Parameters That Affect the Destination Queue
        1. FormatName
        2. PathName
          1. ComputerName and QueueName
      2. Parameters That Affect the MSMQ Message
        1. AppSpecific
        2. AuthLevel
        3. Delivery
        4. EncryptAlgorithm
        5. HashAlgorithm
        6. Journal
        7. Label
        8. MaxTimeToReachQueue
        9. MaxTimeToReceive
        10. Priority
        11. PrivLevel
        12. Trace
    6. F. Application Proxies
      1. Installing Application Proxies on NT 4