Enterprise Application Integration Using .NET: The Controller
Controller class, which functions as a "traffic cop" that takes in the request sent from the web service and directs it to the appropriate places. Several other components are also covered.
At this point, we have several wrapper classes and the web service running. We are now ready to write the main Controller class that will take the transaction request from the web service, split it into individual requests, decide where each of the requests goes, and compile and return the results.
We will look at a few major items in this chapter. First, we will discuss the Controller component. This is the "traffic cop" that takes in the request sent from the web service and directs it to the appropriate places. We will also examine the RequestsProcessor component. In this class, the requests are broken apart and an appropriate RequestHandler component is called for the particular request type. Finally, we will look at the RequestHandlerFactory. This class has some nifty code to create an instance of the appropriate handler class simply by having a name passed in.
Because we are going to allow clients to send in synchronous or asynchronous requests, we will discuss the .NET System.Messaging namespace. We will illustrate how to send asynchronous requests to the Microsoft Message Queuing system, and we will look at the System.Reflection namespace to find the bit of magic that enables you to create an instance of a request handler class on the fly by just supplying the class name.