Leveraging the Service Factory Pattern in the Case Study


The case study application, if implemented today, has a problem with standardized interfaces to business processes, activities, and business objects. Your best bet is to use the service factory in preparation for the day when standards are available. In the meantime, you can use another pattern, such as the Mediator pattern, to mitigate the differences between available services.

Because the coffee industry is light in terms of current standardization efforts, it is likely that you could work with your partners to develop a set of standardized interfaces for the coffee industry. In fact, you can often originate service interfaces for the entire industry; after all, the first person to the party often gets to choose the music.

In terms of the original requirements from Chapter 2, "Introducing the P.T. Monday Case Study," the Service Factory pattern helps you with the requirements identified in Table 15-1. Embracing the Service Factory pattern should also help you with the long- term maintenance of your programs.

Table 15-1: Business Requirements

ID

REQUIREMENT

B2

The application shall have the ability to integrate bean suppliers into the company's value chain.

B3

The application shall enable the company to decrease its dependency on individual bean suppliers.

F9

The inventory management system shall automatically request additional beans from suppliers based on management-configured parameters for the definition of low supplies and grower preferences.

NF1

The application shall embrace open standards for the external API.

One of the most important things to keep in mind, if you are to be successful with automating your operations, is to remain active with your business partners to embrace your interfaces. Further, you should stay abreast of the other services you use to ensure that you are not surprised by changes to partner services that you have little influence over, such as the shipping industry.

Identifying Important Classes and Files in the Case Study

A single class implements the Service Factory pattern in the case study. The sample returns a ProductCollectionImpl instance, which is an architecture adapter that represents a company's product collection, discussed in earlier chapters. Table 15-2 contains a list of Java code that implements the Service Factory pattern for your application.

Table 15-2: Sample Location

FILE

LOCATION

DESCRIPTION

ProductCollectionImpl.java

src\com\servicefoundry\books\ webservices \entities

This is the service implementation that the ProductCollection Web Service uses to fulfill requests for product data. This implementation is a target of the service factory but exists before the implementation of the service factory.

ProductCollectionServiceFactory.java

src\com\servicefoundry\books\webservices\ servicefactory

This is the Service Factory pattern discussed in this chapter. Although the code is not available in this chapter, you should use Listing 15-2 and Figure 15-4 to help you navigate the source code, which is complex.

Using Ant Targets to Run the Case Study

Table 15-3 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 15-3: Ant Targets

TARGET

DESCRIPTION

testservicefactory

This runs the main program presented in Listing 15-2. This code leverages ProductCollectionServiceFactory to retrieve a reference to a single product collection. The code then prints all of the products in the collection.




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

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