"Hi, I'm Mary Kirtland. I'm a Program Manager with the COM+ Services team, and I'm going to talk about designing COM+ applications.
"First, I'll give a bit of background information about some Application Services we use with COM+ to build Windows DNA applications. Then we'll look at some specifics of how you go about the process of designing an application that uses COM+ technologies.
"Initially, though, I'll give you some background on Windows DNA. Windows DNA is a three-tier architecture that helps developers build distributed applications, from the user service layer through business logic, and finally to the data service layer. Windows DNA gives us a framework for thinking about how to build applications and how Microsoft technologies fit into them. COM+ fits in the Application Services that are provided by the operating system and are used to primarily build the business logic of your application. There's a little bit of overlap with the user and data layers, but COM+ primarily involves business logic.
"The first key thing about Windows DNA is that it is a three-tier application architecture, which we believe is the best way to build scalable distributed applications. The second key thing is that Windows DNA enables you to build your applications from components.
"Basically, components are reusable binary pieces of software that provide services to an application. Components give you a way to build up your application in increments, and they also enable you to modify your application over time. At this point, we're not specifically talking about COM or COM+ components. When we refer to components, we mean anything that you can reuse as a unit of distribution. Eventually, you'll pick COM and COM+ services for some parts of your application.
"The main enablers of Windows DNA are tools that help you build these components and eliminate some extraneous or non-specific work. An example is providing a framework for building the component infrastructure itself. You'll also need to have middleware services on which you can depend, and that provide transactions or security support. In addition, you'll want these services to save you time by providing auxiliary but necessary tools for you to use your systems properly. Finally, it's rare that you'll have an application that can exist without having to communicate with anything else. To facilitate in this communication process, Windows DNA can interoperate with your existing data and applications.
"The main Application Service that we're concerned with here is COM+. This is the run-time environment for COM components. COM+ provides a way for you to declare services or interest in services that you want. Microsoft provides the infrastructure that makes COM+ services work. A key element of this infrastructure is the Distributed Transaction Coordinator (DTC), which lets you compose components into larger units of functionality. Using DTC, you can make sure the resources that need to be updated as a group, are updated either all at once or not at all (even if there are multiple components used to build up that functionality unit). Microsoft also provides administrative tools that make it a little easier to deploy and package applications built of many components.
"Basically speaking, COM+ is the evolution of COM, which has been around for a long time, and also of MTS, which shipped with Windows NT 4 in the Option Pack. Microsoft combines COM and MTS into a single programming model, COM+, which ships with Windows 2000. Most of the information I'll discuss in this presentation also applies to developing applications for MTS. So if your applications must also work on Windows NT 4, or if you have clients with no access to Windows 2000 capabilities, many of the same principles I'll discuss here will apply also to MTS.
"Other key services that we use in conjunction with COM+ are Internet Information Server, and in particular Active Server pages, or ASP pages, where ASP pages are used to dynamically construct HTML that targets Internet clients. Components encapsulate much of the work that you'll do within these ASP pages, and you'll use script commands to trigger actions on the components. You should use HTML to provide information about how you want your application to look and to be displayed to users in a platform-neutral way.
"Another Application Service that's available is Microsoft Message Queue Server. MSMQ allows you to send messages in a standard infrastructure that you can define. It also enables you to see what the message format looks like. MSMQ ultimately provides a great way to combine applications that aren't necessarily implemented in conjunction with one another. Another advantage of MSMQ is that you can guarantee that a message will be delivered exactly once. You can also make sure that the message gets routed through the least expensive mechanism, and you can assign priorities to your messages. So there's a lot more flexibility with MSMQ messages than with DCOM messages.
"To give you a bit of history, with COM, Microsoft introduced the notion of objects and interfaces. The key element in COM is that all access to an object is through its interfaces. Microsoft provides a standard object called a class factory, which is a means of creating other objects you want to interact with. Each object exposes a standard interface called IUnknown, which allows access to other interfaces that each object might expose. The classes that implement particular objects are combined into binary units of code called COM components. These components primarily include registration code that helps publish information about the COM components to a particular computer. COM components also provide information about how objects can be packaged object together and hooked into your computer's underlying operating system.
"With MTS, Microsoft added a few new elements, primarily declarative programming and state management. With declarative programming, you have the basic components, and you talk to them in the same way via interfaces. Clients get interface pointers, and they talk through those interface pointers to an object. You can specify information at the component, class, interface, and, with COM+, method level that indicates how you want to apply services to a particular component. Attributes could be, for example, simple requests or permissions allowed to users.
"Based on these attributes, and also on some information about the client computer, you can create a context in which the objects are going to operate. A context basically provides a safe environment for your objects. The object context also provides information about the transaction to which the object belongs, the security context, and additional data that the operating system and the MTS environment need to know to make sure that services are applied to the objects correctly. If you then create a subcomponent, or sub-object, from a given object, you should create contexts for those, too, by examining the attributes of a newly requested object, and also the context information for each current object. Attributes and context information are then combined to create a context for the new object.
"The ultimate direction in which Microsoft is moving with COM+ is to make the notion of attributes and context a fundamental part of the programming model. Instead of calling an API to access a particular service, in which you might call an initialization API and then call another API that provides instructions on configuring a service, you would simply declare an attribute. In other words, you would specify a desired action, and the system would determine how to execute that action for you.
"Another much-discussed aspect of MTS is state management. We often talk about MTS as promoting stateless objects, and that's not the ideal way to think about it. You should consider where your state will be. The key idea is that you shouldn't maintain per-object state across the transaction boundary, because you don't want to leak information from one transaction to another. You want to make sure that the information remains correct and consistent.
"You should also consider different types of state information. Rather than keeping state within each object, you may want to keep it with the client. Whenever the client needs to provide information to a particular object or component, the client can pass the information in its call to a particular interface method. You can still keep state in each object, as member variables; for example, you can keep state in a C++ class or in a Visual Basic class. But once again, you shouldn't assume that your state will be maintained across the transaction boundary. Thus, as long as the lifetime of your object is less than the lifetime of the transaction, you'll be just fine.
"If you need to maintain state across a transaction boundary, but you don't always want to pass it over from the client, you can keep it in shared transient state. You can also use shared transient state for information that applies to multiple clients. Microsoft provides a service called Shared Property Manager that can help you achieve shared transient states. To illustrate how Shared Property Manager works, imagine a location on a server computer in which you want to collect and track information. In this instance, you'd most likely pass, from your client, a key that requests the state you want. Otherwise, you'd want your objects to locate a key and request a state out of the shared location. You can also keep state information in a persistent store, like a database, to get the most flexibility and scalability. Then you can read it in only when you need it. If you can reuse or share the connections to that persistent state, you can get high scalability rates.
"Another important programming model aspect, from a component developer's point of view, is that you can indicate that you're done with the per-object state that you have in a particular object. You can make such an indication when your method call returns by calling the SetComplete and SetAbort methods. This procedure lets MTS know that it can reclaim the object, destroy it, and free up any server resources that might be associated with that object.
"As I mentioned, COM+ is the evolution of COM and MTS, or rather the result of the combining of the two to make an improved programming model. I want to emphasize that the basic programming models of COM+ and MTS are identical. A couple of years ago, Microsoft defined COM+ as a way to change how programmers build components. In Windows 2000 currently, Microsoft presents COM+ as much more of an evolutionary path than simply a new way of building components. The way that developers writing components is exactly the same as it was for MTS and COM as separate entities. With COM+, you'll still need to write in-process components and expose interfaces. Also, if you want to use automation, you have to implement IDispatch and registration code. Ultimately, whatever functions you've had to perform previously, you'll still need to do with COM+ in Windows 2000.
"However, there are some new services that you can use to expand the range and the types of applications that you can build. I'll briefly go through each of these items and talk about where you might want to use it in just a minute.
"There are also improvements to the existing MTS services. For example, if you're accustomed to using transactions and JIT activation in MTS, or if you don't need a transaction or JIT, the new COM+ Transaction Services can alleviate these issues. Microsoft has factored the services out so that you can choose which ones you want. If you don't want JIT, you can still get role-based security, for example. The role-based security has been improved to provide more information about the entire chain of callers. Overall, COM+ simply makes things easier for you, even if you're using the same services that were available in MTS.