|< Day Day Up >|| |
The Application Integration pattern focuses on the mechanisms selected to achieve communication between two applications within the domain of a single organization.
To illustrate the various runtime patterns applicable when using the Direct Connection application pattern, we use a very simple Web application as the source application. It comprises a welcome page, a servlet, a factory class, command beans, a view bean and a JSP to display the response of the interaction.
We use an enterprise bean as the target application, which is exposed as a Web service. Selecting an EJB can simplify a business application because the EJB container provides services that handle complexities such as security, resource pooling, persistence, concurrency, and transactional integrity. The business logic provided by our EJB is also available to any Java source application using RMI.
Figure 8-1 highlights the ability to establish a Direct Connection between the source and target applications as the focus of our discussion. It also shows the major components constructed for the source and target applications used in our sample solution.
Figure 8-1: High level design for source and target application
A Welcome page, shown in Figure 8-2, enables the user to exercise a Direct Connection using a variety of different technologies by selecting the required option. The Update Inventory button invokes a Message-style interaction, where a reply is not needed. The Get Delivery Date button uses a Call-style interaction, where a reply providing an expected delivery date is required.
Figure 8-2: Welcome page
Our source application is a simple implementation of the Model-View-Controller (MVC) design pattern. The InventoryServlet acts as the Controller by parsing the request from the browser.
The CommandBean acts as the Model in our source application. This class is responsible for implementing the business logic of our application. A CommandBean is created using a singleton CommandBeanFactory class which instantiates the relevant CommandBean based on the option selected. The implementation of each specific CommandBean makes use of generated classes specific to the option selected. Each CommandBean implements an updateInventory() and a getDeliveryDate() method. The InventoryServlet calls the execute() method on the generic CommandBean, passing a parameter indicating which push button has been selected. The execute() method on the base class then invokes the required method. These methods interact with the target Web service application.
The View represents the result of the interaction with the target application. This is provided by an InventoryViewBean, which is created by the InventoryServlet and used in a JSP which is displayed to the user in the browser.
|< Day Day Up >|| |