Home > Articles > Programming > Windows Programming

This chapter is from the book

This chapter is from the book

5.3 COM+ Component Services

The .NET Framework leverages many existing Windows services to make it a more robust application environment. A particular technology that deserves attention is COM+ Component Services. These technologies were the predecessors to the .NET Framework. To see how COM+ Component Services fits into the .NET Framework arena, let's explore a little about these technologies.

5.3.1 Overview of COM

The Component Object Model (COM) was designed to address the shortcomings of conventional object-oriented languages like C++ and traditional binary software distribution of code. COM is about not a particular type of software but rather a philosophy of programming. This philosophy is manifested in the COM specification. The specification explicitly states how a COM object should be constructed and what behaviors it should have.

COM objects are roughly equivalent to normal classes, but COM defines how these objects interact with other programs at the binary level. By binary, I mean compiled code, with all the methods and member variables of the class already built into an object. This "binary encapsulation" allows you to treat each COM object as a "black box." You can call the black box and use its functionality without any knowledge of the inner workings of the object's implementation. In the Windows environment, these binary objects (COM objects) are packaged as either DLLs or executable programs. COM is also backed by a series of utility functions that provide routines for instantiating COM objects, process communication, and so on.

COM was the first methodology to address object-oriented software reuse. COM has enjoyed great commercial success; many third-party software vendors provide COM objects to perform a wide range of tasks, from e-mail to image processing. COM is also highly useful for creating components called business objects. Business objects are COM objects in the strict sense, but they are used to encapsulate business rules and logic. Typically these business objects are tied to database tables. The objects move around the database according to the business rules implemented in the COM object.

Generally, several smaller business objects work together to accomplish a larger task. To maintain system integrity and to prevent the introduction of erroneous data into the application, transactions are used. A software service called Microsoft Transaction Server (MTS) is used to manage these transactions. We'll cover the function of MTS (and its successor, COM+) in Section 5.3.3.

5.3.2 Overview of Transactions

Simply stated, a transaction is a unit of work. Several smaller steps are involved in a transaction. The success or failure of the transaction depends on whether or not all of the smaller steps are completed successfully. If a failure occurs at any point during a transaction, you don't want any data changes made by previous steps to remain. In effect, you want to initiate an "undo" command, similar to what you would do when using, say, a word processor. A transaction is committed when all steps have succeeded. A failed transaction causes a rollback to occur (the "undo" operation).

Well-designed transactions conform to ACID principles. ACID is an acronym for Atomicity, Consistency, Isolation, and Durability.

  • Atomicity means that either the operation that the component performs is completely successful or the data that the component operates on does not change at all. This is important because if the transaction has to update multiple data items, you do not want to leave it with erroneous values. If a failure occurs at any step that could compromise the integrity of the system, the changes are undone.

  • Consistency deals with preserving the system state in the case of a transaction failure.

  • Isolation means that a transaction acts as though it has complete control of the system. In effect, this means that transactions are executed one at a time. This process keeps the system state consistent; two components executed at the same time that operate on the same data can compromise the integrity of the system.

  • Durability is the ability of a system to return to any state that was present before the execution of a transaction. For example, if a hard drive crash occurs in the middle of a transaction, you can restore the original state from a transaction log stored on another disk to which the system recorded.

A classic example of a transaction operation is a bank transfer that involves a transfer of funds from one account to another (a credit and a debit). Such a transaction moves through the following steps.

  1. Get the amount to be transferred, and check the source account for sufficient funds.

  2. Deduct the transfer amount from the source account.

  3. Get the balance of the destination account, and add the amount to be transferred to the balance.

  4. Update the destination account with the new balance.

Suppose a system failure occurs at step 4. The source account had the transfer amount deducted but the amount was not added to the destination account. Therefore, the money from the source account gets lost. Clearly, this is not good because the integrity of the database has been damaged.

Each of the account transfer's steps can be checked for success or failure. If a failure occurs before all values have been updated, the program needs to undo the deduction made to the source account. That's a rollback. If every step succeeds, the program needs to apply all the changes made to the database. That's when a commit operation is performed.

5.3.3 Automatic Transactions

Transactions have been in widespread use since the early days of enterprise computing. Many database systems include internal support for transactions. Such database systems contain native commands to begin, abort, and commit transactions. This way, several updates to database data can be made as a group, and in the event of a failure, they can be undone. Using a database's internal transaction-processing system is referred to as manual transaction processing.

Automatic transactions differ from manual transactions because automatic transactions are controlled by a system external to the database management system (DBMS). Earlier versions of Windows (95/98/NT) provide automatic transaction services using Microsoft Transaction Server (MTS). MTS works by coordinating database updates made by COM components grouped into a logical unit called a package. An MTS package defines the boundary of the transaction. Each component in the package participates in the transaction. After a component performs a piece of work (such as updating the database), it informs MTS that it successfully (or unsuccessfully) performed its share of the transaction. MTS then makes a determination to continue based on the success of the last component's signal of success or failure. If the transaction step was unsuccessful, the transaction is aborted immediately, and MTS instructs the DBMS to undo any changes made to data. If the step was successful, the transaction continues with the other steps. If all steps execute successfully, MTS commits the transaction and tells the DBMS to commit changes to the data.

5.3.4 COM+ Applications

With the release of Windows 2000 came the next version of COM, dubbed COM+. COM+'s raison d'être is the unification of COM and MTS. COM+ also offers performance improvements over MTS by implementing technologies such as object pooling, which maintains an active set of COM component instances. Other performance-enhancing features include load balancing, which distributes component instances over multiple servers, and queued components, which uses Microsoft Message Queue Server to handle requests for COM+ components.

The services that were formerly provided by MTS are known as COM+ Component Services in the COM+ model. COM+ Component Services works in a similar manner to MTS. Packages are now referred to as COM+ applications. Participating transactional components are grouped into applications in the same way components were grouped into packages under MTS.

Individual COM+ components in an application can be assigned different levels of involvement in an automatic transaction. When setting up COM+ applications, each component can have the levels of automatic transaction support shown in Table 5-2.

Table 5-2 COM+ Automatic Transaction Support Levels

Transaction Support

Description

Disabled

-No transaction services are ever loaded by COM+ Component Services.

Not Supported

-This is the default setting for new MTS components. Execution of the component is always outside a transaction regardless of whether or not a transaction has been initiated for the component.

Supported

-You may run the component inside or outside a transaction without any ill effects.

Required

The component must run inside a transaction.

Required New

-The component needs its own transaction in which to run. If the component is not called from within a transaction, a new transaction is automatically created.


5.3.5 COM+ Security

Security is of paramount importance, especially for applications intended to run on the Internet. In the past, programming security features into an Internet application was largely a manual effort. Often it consisted of custom security schemes that did not necessarily leverage the existing security infrastructure provided by the operating system. Besides being difficult to maintain, such security systems are typically costly to develop.

COM+ Component Services provides a security infrastructure for applications that uses Windows 2000/XP users and groups. COM+ security is declarative, which means you designate which users and groups have permission to access a COM+ application. This is done by defining roles for application access.

A role is a defined set of duties performed by particular individuals. For example, a librarian can locate, check out, and shelve books. The person fulfilling the librarian role is permitted to perform such duties under the security policies defined for that role. An administrator is responsible for assigning users and groups to roles. The roles are then assigned to a COM+ application.

This role-based security is not only easy to implement (it can be done by the system administrator) but it also typically doesn't require the programmer to work on the components to implement any security code. When a call is made to a component running under COM+ Component Services, COM+ checks the user/group identity of the caller and compares it against the roles assigned to the component. Based on that comparison, the call is allowed or rejected.

You can provide additional security checking by using procedural security. This type of security is implemented programmatically using special .NET classes designed for interaction with COM+ Component Services.

5.3.6 .NET Classes and COM+ Component Services

Thus far, our discussions about COM+ Component Services, transactions, and security deal specifically with COM+ components. COM+ predated the .NET Framework and has had much success in enterprise-wide applications developed using Microsoft Visual Studio 6.0. But how does .NET fit into all of this?

COM+ still remains a dominant technology and is a significant part of Windows. The architecture for .NET managed components was designed to take advantage of all the features COM+ Component Services has to offer (object pooling, transaction processing, security, and so on) by providing classes to implement those features. These concepts are very important when developing Web applications, too.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020