Key ATL Server Classes


In this section we briefly discuss some of the key ATL Server classes. These classes provide some of the core functionality in an ATL Server application. We begin by looking at the classes that play a key role in your ISAPI extension DLL, and then we cover the classes that are key to the success of your request handler (application DLL).

Key ISAPI Classes

The following classes play key roles in your ISAPI extension DLL:

  • CIsapiExtension (atlisapi.h): As the main ISAPI extension implementation, this class forms the basis for your ISAPI extension class. It takes several template parameters that enable specification of the following: thread pool class, request statistic class, error text message class, page cache statistics, and stencil cache statistics. You ll see that it implements HttpExtensionProc , which is the entry point in IIS for a normal request. You can see it initializes data structures when a request arrives and places the request in the thread pool by calling QueueRequest .

  • CThreadPool (atlutil.h): CThreadPool implements a simple I/O completion port “based thread pool. It s one of the classes that s useful outside of a Web application context, as I/O completion port “based thread pools are very efficient on Windows, and they re useful for many multithreaded applications. This class is templated on two parameters: the first is Worker , which is the class responsible for handling the requests that are queued on the thread pool, and the other is Traits , which implements a static CreateThread function that allows for overriding how threads are created. The SetSize and GetSize methods allow you to dynamically configure your thread pools. The Initialize function actually sets up the thread pool.

  • CIsapiWorker (atlisapi.h): This is the default worker class that your CThreadPool is instantiated on. The Initialize and Execute methods provide the bulk of the functionality for this class. In particular, you ll notice that Execute makes a call to DispatchStencilCall .

  • DispatchStencilCall (atlisapi.h): This isn t a class; rather, it s an important method in CIsapiExtension . This is the method that checks if the request is for an SRF file or a DLL (handler). It makes sure that the correct action is taken depending on the type of request. In the case of an SRF file, it will look at the handler, check if that handler is already in the cache, and call that handler. The parsing of the rest of the SRF file is done by your request handler.

Key Request Handler (Application DLL) Classes

The following classes play key roles in your request handler (application DLL):

  • CRequestHandlerT (atlstencil.h): This class implements the major functionality of the request handler. It includes several initialization functions, but of the most interest is HandleRequest , which performs the default processing of HTTP requests. It includes steps to load, parse, and render the stencil (SRF file), and it flushes the information out. If you need to put in some custom initialization before a request is handled, or if you want to customize the way a request is handled, then you should override this function. CheckValidRequest , as its name implies, checks if the given HTTP request is valid, and it can be overridden if you have some custom requirements in this space.

  • CHtmlTagReplacer (atlstencil.h): This class handles your stencil processing. It creates, stores, caches, initializes, loads, and parses CStencil -based objects. There s one instance of this class per request (typically), which is destroyed once the request is complete.

  • RenderStencil , Render , RenderToken , and RenderReplacement : These functions all contribute to rendering a stencil in their own way. RenderStencil does some initialization, such as setting the code page, before handing off to Render . Render in turn calls recursively into RenderToken , which actually handles the rendering of the various tokens, using RenderReplacement to render the tags into the stream. RenderReplacement gets and calls a pointer to the member function. It gets this pointer by offsetting into the method replacement map.

These classes form the basis of an ATL Server application. Figure 5-3 illustrates the Web request class flow.

click to expand
Figure 5-3. Web request class flow

There are many other classes and functions involved in a complete application, and ATL Server provides a very rich framework for a variety of tasks . The classes we described in this section represent some of the core functionality required to take an incoming request from IIS and get it to your handler methods in your request handler “derived class.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net