Chapter 7: Channel Managers


Overview

User code never directly instantiates a channel; that job is reserved for special factory types. Although these factory objects are not channels, they are considered part of the channel layer. In Chapter 6, “Channels,” I borrowed Design Pattern terminology (by Erich Gamma et al, Addison-Wesley, 1995) and called these special types channel factories. In the Microsoft Windows Communication Foundation (WCF) type system, channel factories have specific names, and the names of these types differ on the sender and the receiver. On the receiver, these types are called channel listeners. On the sender, these types are called channel factories. Channel listeners and channel factories, although they share some common characteristics and purposes, have different object and behavioral models. When grouped together, channel listeners and channel factories are called channel managers. This chapter describes the internals of both types of channel managers: channel listeners and channel factories. In this chapter, you’ll learn about the basics of these types and their object models, and then we’ll look at examples illustrating how to build custom channel managers. Because a Binding creates a channel factory and a channel listener, the code sample will not run on its own until the end of the next chapter.

Because a channel is the physical means by which a WCF application implements some messaging functionality, channel factories and channel listeners are the means by which a WCF application creates that messaging functionality. Just as there is no one-size-fits-all channel definition, there is no one-size-fits-all channel factory or channel listener. Just as channels can be grouped according to their general functionality (for example, WS-ReliableMessaging, TCP/IP transport, and so on), channel managers can also be grouped according to the functionality of the channels they create. For example, the WS-ReliableMessaging channels are created by WS-ReliableMessaging channel managers, and those same channel managers would not also create transport channels.

This is not to say, however, that a channel manager can create only one type of channel. Quite the contrary, channel managers can and often do create several different kinds of channels, but these channels reside in a given functional group. Typically, the types of channels created by a given channel manager differ only in shape. In some cases, a channel manager can even create exactly the same type and shape of channel (for example, duplex channels).

Channel managers share many characteristics with channels. Because channels are frequently arranged in a stack at run time, channel managers are also frequently arranged in a stack. In one sense, the arrangement of channel managers within the stack dictates the arrangement of the channels in the channel stack. Channel managers implement the ICommunicationObject interface and share the same state machine described in Chapter 6. Furthermore, they also implement a query mechanism similar to the one available in channels.




Inside Windows Communication Foundation
Inside Windows Communication Foundation (Pro Developer)
ISBN: 0735623066
EAN: 2147483647
Year: 2007
Pages: 106
Authors: Justin Smith

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