You are previewing COM+ Programming: A Practical Guide Using Visual C++ and ATL.
O'Reilly logo
COM+ Programming: A Practical Guide Using Visual C++ and ATL

Book Description

  • Maximizing COM/COM+ software reusability and scalability: practical solutions!

  • Developing robust enterprise COM+ applications: Proven guidelines and sample code

  • In-depth coverage: IDL interface design, COM+ synchronization, transactions, queuing, security, events, and more

  • Techniques for administering distributed component environments

  • Maximizing COM/COM+ reuse and scalability: practical, enterprise-class solutions!

    If you're ready to develop COM/COM+ enterprise applications, start with this practical, solutions-focused guide! Using case studies and real-world code examples, Hewlett-Packard COM/COM+ expert Pradeep Tapadiya presents COM and COM+ in detail, from a developer's perspective. You'll master powerful techniques for improving reusability, scalability, and robustness-and discover how to avoid the traps and pitfalls that await the unwary. Tapadiya demonstrates today's best approaches to designing interfaces, building COM servers, dealing with transactions, and more, including:

  • In-depth coverage of interface design with IDL

  • A full chapter on maximizing the scalability of COM/COM+ applications

  • Maximizing security in distributed, component-based environments

  • COM+ synchronization, apartments, activities, and event notification

  • Working with queued components

  • Administering distributed component environments

  • Whether you're new to component development, migrating to COM+ and Windows 2000, or an experienced developer seeking powerful new techniques, you'll find the answers in COM+ Programming: A Practical Guide Using Visual C++ and ATL.

    Table of Contents

    1. Copyright
      1. Dedication
    2. Introduction
      1. About This Book
      2. Choice of Language
      3. Prerequisites
      4. Sample Code
      5. References
      6. Chapter Organization
      7. Companion CD
      8. Acknowledgments
    3. I. The Foundation
      1. 1. The Component Model
        1. Component Reusability
        2. Traditional Software Reusability
        3. Reference Hardware Components
        4. Simulation Program
        5. Role of the Linker and the OS Loader
        6. Dynamic Link Library
        7. Fixing a Defect
        8. Hardware Component Model
        9. Separating Interface from Implementation
        10. Common Aspects of C++ Language
        11. Virtual Methods in C++ and Memory Layout
        12. Interface as an Abstract Base Class
        13. Dynamic Selection of a Component
        14. Extending the Interface Functionality
        15. Managing the Lifetime of an Object
        16. Optimizations
        17. Error Reporting
        18. The Essence of COM
        19. Summary
        20. References
          1. Bibliography
      2. 2. Designing Interfaces
        1. Why a New Language?
          1. Programming Language Independence
          2. Remote Transparency
        2. Interface Definition Language (IDL)
          1. IDL Attributes
        3. IDL Design Goals
          1. Remote Transparency
            1. Method Remoting
          2. Programming Language Independence
          3. Semantic Information
          4. Standardized Calling Conventions
            1. Return Value From a Function
            2. Stack Frame Setup
          5. Memory Management
          6. Identification
            1. Globally Unique Identifiers (GUIDs)
          7. Compiled Type Information
          8. Component Identification
        4. Processing IDL Files
          1. C/C++ Development Files
          2. Type Library Files
          3. Proxy-Stub Files
        5. IDL File Structure
          1. The Preprocessor Section
          2. The Interface Section
          3. The Type Library Section
        6. IDL Syntax
          1. Defining Interface Methods
            1. Directional Attributes
            2. Logical Return Value
            3. Base Data Types
            4. String Parameters
            5. Enumeration Data Type
            6. Structures
            7. Unions
            8. Encapsulated Unions
            9. Arrays
            10. Pointers
            11. Interface Pointers
          2. Defining IDL Interfaces
            1. Interface Attributes
            2. The Root Interface— IUnknown
          3. Defining COM Classes
          4. Defining IDL Libraries
            1. Library Attributes
            2. Removing Redundancy
        7. Automation
          1. Basic Data Types
          2. Strings
          3. Booleans
          4. Variants
          5. Safe Arrays
          6. Automation-Compatible Interfaces
            1. Properties and Methods
            2. Run-time Binding
          7. Collections and Enumerations
            1. Count
            2. Item
            3. Enumeration
        8. Interfaces and Marshaling
        9. Memory Management
        10. Organizing Multiple IDL Files
        11. Putting It All Together
        12. Summary
        13. References
          1. Bibliography
      3. 3. Components
        1. From C++ to COM—A Quick Tour
          1. Implementing Interfaces
            1. Use COM Calling Conventions
            2. Declare IUnknown Methods
          2. Method Implementation
          3. Instantiation Logic
          4. The TV Client
          5. The COM+ Catalog
        2. Revisiting C++ Code
          1. Multiple Classes in a Server
          2. Multiple Instances of a Class
            1. Class Object
            2. Class Factories
            3. Optimizations
          3. Storing Configuration Information
          4. Memory Cleanup
            1. When to Unload a DLL?
            2. Optimizations
            3. Code Cleanup
        3. Implementing COM Objects
          1. Using Multiple Inheritance
          2. Implementing the Root Interface
            1. Reference Counting Rules
            2. Reference Count Implementation
            3. Relationship Between Interfaces
            4. Typical QI Implementation
          3. ATL is Our Friend
            1. Standard Include Files
            2. Registration Logic
            3. Implementation Class Logic
            4. Class Object Support
        4. Tear-Off Interfaces
        5. Reusing Components
          1. Containment
          2. Aggregation
            1. Implementing the Inner Component
            2. Implementing the Outer Component
            3. Aggregation Gotchas
        6. Error Reporting
        7. Summary
        8. References
          1. Bibliography
    4. II. The Extension
      1. 4. Essence of COM+
        1. Enterprise Systems
          1. Security
          2. Scalability
          3. Sharing Resources
          4. Transactions
        2. Three-Tier Architecture
          1. Windows DNA
        3. COM+ = Simplified Development
          1. Administrative Control
          2. Transaction Services
          3. Security Services
          4. Synchronization Services
          5. Queued Components
          6. Event Service
          7. Object Pooling
          8. Just-In-Time (JIT) Activation
          9. Remote Deployment
        4. Summary
        5. References
          1. Bibliography
      2. 5. COM+ Programming Model
        1. Attribute-Based Programming
          1. The COM+ Catalog
          2. Configuring a Component
          3. Component Initialization
          4. Developer-Specified Attributes
            1. Attributes under Windows Registry
        2. COM+ Context
          1. Contexts and Interception
          2. Interception and Performance
        3. Object Context
          1. Default Context
        4. Call Context
        5. Object Activation
          1. In-Process Activation
          2. Out-of-Process Activation (Local Host)
          3. Remote Activation (Distributed Computing)
          4. Executing in a Different Context
            1. Using Activator’s Context
            2. Using a Caller’s Context
        6. Summary
        7. References
          1. Bibliography
      3. 6. Concurrency
        1. Multithread Programming
          1. A Simple Example
          2. Multithreading Issues
            1. Shared Data Conflicts
            2. Thread Affinity
            3. Deadlocks
            4. Incorrect Use of a Synchronization Object
            5. Performance
        2. Apartments
          1. Single-Threaded Apartments (STA)
          2. Multithreaded Apartments (MTA)
          3. Thread-Neutral Apartments (TNA)
        3. Configuration Settings
          1. Activities
        4. Apartments and Standard Marshaling
          1. Dispatching Calls to an STA
          2. Dispatching Calls to an MTA
          3. Dispatching Calls to a TNA
        5. Cross-Context Access
          1. Global Interface Table (GIT)
        6. Developing Thread-Safe COM Code
          1. Shared Data Conflicts
            1. Using a Main STA
            2. Using an STA
            3. Using Activities
            4. Using a TNA or an MTA
            5. Handling Reentrancy
          2. Waiting for an Event
          3. Sharing State Across Multiple Objects
            1. COM Singleton
            2. Shared Property Manager
        7. Summary
        8. References
          1. Bibliography
      4. 7. Security
        1. The COM+ Security Model
          1. Windows NT Security System Basics
          2. Security Issues Under COM
            1. Activation Control
            2. Access Control
            3. Authentication Control
            4. Identity Control
            5. Role-Based Security
          3. Security Service Providers (SSPs)
          4. Security Blankets
        2. Declarative Security
          1. Default Settings
          2. Application-Specific Settings
            1. Identity
            2. Roles
            3. Security Settings
        3. Server-Side Security Programming
        4. Client-Side Security Programming
          1. Impersonation Levels
            1. Anonymous
            2. Identify
            3. Impersonate
            4. Delegation
            5. Cloaking
          2. Identity and Authentication Services
          3. Client Acting as a Server
          4. Adjusting Security for a Proxy
        5. Summary
        6. References
          1. Bibliography
      5. 8. Transactions
        1. The Stock Trader
          1. The Database Layer
            1. Using MSDE
            2. The Accounts Database
            3. The Stocks Database
          2. The Business Logic
            1. The Account Management Component
            2. The Stock Exchange Component
            3. The Trade Management Component
          3. The Simulation
        2. Transaction Theory
        3. COM+ Support for Transactions
          1. Configuring Transactions
          2. Programmatic Voting
        4. The Architecture
          1. Resource Managers
          2. The Distributed Transaction Coordinator
            1. Two-Phase Commit
          3. Automatic Transactions through COM+
            1. Lifetime of a Transaction
          4. Manual Transactions
        5. Compensating Resource Manager
        6. Summary
        7. References
          1. Bibliography
      6. 9. Message Queuing
        1. Message-Based Queuing
          1. The Need for Queuing
          2. Why Use MSMQ?
        2. MSMQ Overview
          1. MSMQ Servers
          2. MSMQ Clients
          3. Queue Types
            1. Application Queues
            2. System Queues
          4. Queue Naming
        3. MSMQ COM Components
          1. Sending and Receiving Messages
          2. Guaranteed Delivery
          3. Responding to a Message
          4. Sending Objects in the Message Body
          5. Transactions
            1. Internal Transaction
            2. External Transactions
        4. Queued Components
          1. A Simple Phone Book Example
          2. Queued Component Architecture
          3. Getting a Response
          4. Transaction Support
            1. Between the client and the recorder
            2. On the server side
            3. Using Non-Transactional Queues
        5. Summary
        6. References
          1. Bibliography
      7. 10. Events
        1. Introduction
        2. Tightly Coupled Events (TCEs)
          1. Connection Points
          2. Receiving Messages with MSMQ Events
        3. Loosely Coupled Events (LCEs)
          1. COM+ Events Architecture
          2. A Simple Event Example
            1. Registering an Event Class
            2. Subscribing for an Event
            3. Firing an Event
          3. Transient Subscriptions
          4. Events and Queued Components
          5. Events and Filtering
            1. Subscriber Parameter Filtering
            2. Publisher Filtering
        4. Summary
        5. References
          1. Bibliography
      8. 11. Scalability
        1. Introduction
        2. Resource Dispensers
        3. Just-in-Time (JIT) Activation
        4. Object Pooling
          1. Requirements for Poolable Objects
            1. Stateless
            2. No Thread Affinity
            3. Aggregatable
            4. Transactional Components
        5. Asynchronous Method Calls
          1. Asynchronous Clients
            1. Checking Call Status
            2. Call Completion Notification
            3. Call Cancellation
          2. Asynchronous Servers
          3. Canceling a Synchronous Call
        6. COM+ Pipes
        7. Summary
        8. References
          1. Bibliography
      9. 12. Administration
        1. Overview
        2. COM+ Administration Object Model
          1. COMAdminCatalog Object
          2. COMAdminCatalogCollection Object
          3. COMAdminCatalogObject Object
        3. Programming Considerations
          1. Error Handling
          2. Administrative Tasks and Transactions
            1. Changes to the normal administration programming model
            2. Participating in a Transaction
        4. Some Common Administrative Tasks
          1. Uninstalling an Application
          2. Installing an Application
          3. Deploying an Application
        5. Future Enhancements
        6. Summary
        7. References
          1. Bibliography