Leveraging Partial Population in the Case Study

The P.T. Monday Coffee Company uses the Partial Population pattern on all business object and business object collection implementations for changing data. Clients of the Web Services will only have to specify the data they want changed in an existing business object rather than having to specify all of the data in the business object or data transfer object.

Using the pattern on data retrieval will happen in select locations only. Some business objects have quite a few complex object types. Rather than serializing all of this data to a client, you will allow users of the Web Service to specify the data they require. Overall, the Partial Population pattern has a larger effect when changing data on your Web Services than when retrieving data.

One example of usage is on client data. A single CustomerImpl instance contains the following properties:

  • Address : A complex object type made up of address lines and city, state, and zip information

  • CustomerInformation : A complex object type made up of Internet addresses, shipping addresses, and credit information

  • FirstName : A string identifying the first name of the customer

  • LastName : A string identifying the last name of a customer

  • CustomerId : A unique identifier for the customer generated by the Web Service

With the exception of CustomerId , which must be populated by the client so that you can uniquely identify a particular customer record, each of the properties is optional when a client updates a CustomerImpl instance. For example, to change the LastName property, there is no reason you need a populated CustomerInformation instance. This saves substantial work on the part of the client programmer and helps the performance of your application by having to marshal less data. You must apply similar logic to all of your business object types. You will identify optional fields when updating and ensure that the contract for the Web Service is specific enough so that users understand where the Partial Population pattern applies.

Identifying Important Classes and Files in the Case Study

Table 17-3 shows the primary code discussed in this chapter that you should browse in the downloaded source code.

Table 17-3: Sample Location





src\com\servicefoundry\books\ webservices \entities

This is a data transfer object implementation, as shown in Figure 17-3.



This is the modified collection implementation that adds the Data Transfer patterns to its interface and to the Partial Population pattern, as shown in Listing 17-2 and 17-4. Figure 17-3 shows the entire class structure.

Using Ant Targets to Run the Case Study

Table 17-4 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 Appendix A.

Table 17-4: Ant Targets




Data retrieval and modification client program that uses Listings 17-1 and 17-3

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