Component Creation Tools

There are three primary choices for languages with which to create server components. These choices are Visual Basic, C++, and Java. Each of these languages can produce COM objects that can be used as server components inside of MTS. They also have different levels of support when it comes to creating components using the various threading models that we just looked at.

Visual Basic is the quickest way to create application components. All of the examples in this chapter, as well as the case study that follows in the next few chapters, will be created using Visual Basic. However, with this ease of use comes a tradeoff. The default threading model for components created in Visual Basic is single-threaded. As you have probably gathered by now, single threading is bad. However, with the release of the Visual Studio Service Pack 2, Visual Basic can now create apartment threaded components. While these are not optimal in all uses, they will be sufficient for the majority of cases where application components are used.

C++ can also be used to create application components. Nearly all of the components that make up IIS and MTS and ASP are built using C++. A new feature of Visual C++, known as the Active Template Library, or ATL, has a wizard that lets you get a lot of the COM plumbing generated for you automatically. All that you will then need to write is your application specific code. C++ and ATL can generate components that use the both threading model. As we have seen, this is the most versatile threading model for all component uses.

Java, despite all of its hype, is an excellent programming language. With the COM-specific support that Microsoft has added to Visual J++, you can use Java to create server components. There are a set of Java classes that are provided with ASP that allow the developer to use standard Java to create the components. All of the COM-specific constructs, like variants, are mapped onto native Java types. By default, Java components are marked as both threaded, making them optimal for use in all parts of an ASP and MTS application.

© 1998 by Wrox Press. All rights reserved.