Leveraging Physical Tiers and the Connector Patterns in the Case Study

The P.T. Monday Coffee Company application, when completed, will contain two separate tiers with the service implementations forwarding requests to a separate logic tier. Isolating the JDO implementation to a single tier and bringing it under your own control rather than the Web Service implementation's control is the primary motivation for the physical separation. In the end, your logic is complex enough that you can optimize it by running in your own application space. Further, a separate logic tier can facilitate both Web Services and stand-alone Java-based or Java Server Pages “based clients who go directly to the Java components and bypass the Web Services.

In addition to physical tier separation, you also need to use the Connector pattern to communicate with stand-alone applications deployed for the employees at the P.T. Monday Coffee Company. These applications should be able to register for events with Web Services that are outside of the P.T. Monday Coffee Company. An example of a case where you could use immediate notification is when you want immediate notification of package delivery to special customers or of specials that your suppliers may have for raw coffee beans.

Identifying Important Classes and Files in the Case Study

The sample for this chapter is the most complex yet, with multiple layers of remote protocols, Web Services, and RMI, as well as a chain of event handlers that act in different processes. As you view the source code listed in Table 13-1, use Figure 13-7 to understand the class's place in the chain of active class instances.

Table 13-1: Sample Location





src/com/ servicefoundry/books/ webservices /eventservice

This is the Subscriber class as shown in Listing 13-3. This subscriber deploys as a Web Service and uses RMI to communicate with the connector registered in Listing 13-5 when the Subscriber receives an event.

ApplicationSubscriber. java

src/com/ servicefoundry/books/ webservices/eventservice

This is the interface to the application's subscriber, as shown in Listing 13-1.

ApplicationSubscriberImpl. java

src/com/ servicefoundry/books/ webservices/eventservice

This is the application's subscriber implementation, as shown in Listing 13-2.

ServiceToApplicationTest. java

src/com/ servicefoundry/books/ webservices/test

This is a graphical client that displays event data when its subscriber receives notifications.
This client also registers the connector, an instance of the RMI class shown in Listing 13-2, via the RMI Naming service, as shown in Listing 13-5.

Using Ant Targets to Run the Case Study

Table 13-2 describes the targets to run for the Ant environment to see the programs and chapter samples in operation. Before running any samples, be sure you read and perform all of the install steps in the appendix.

Table 13-2: Ant Targets




This runs the ServiceToApplicationTest.java client, which is a stand-alone application containing a simple logic tier ApplicationSubscriberImpl instance that receives event interactions from the Web tier and publishes them to the user .


This registers your Web tier subscriber with the EventService Web Service built in the previous chapters. The Subscriber Web Service later locates the physically separate logic tier and delivers events to the ApplicationSubscriberImpl via RMI.


This publishes an event to the EventService Web Service. The Subscriber Web Service will see this event and forward it to the Subscriber service implementation in the Web tier. The Subscriber service implementation forwards the event through the Connector pattern to the ApplicationSubscriberImpl instance residing in the application's logic tier. The ApplicationSubscriberImpl instance publishes the event to the presentation tier of the application.

Web Service Patterns
Web Services Patterns: Java Edition
ISBN: 1590590848
EAN: 2147483647
Year: 2003
Pages: 190

Similar book on Amazon

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