Flylib.com

Books Software

 
 
 

Web Services Patterns: Java Edition - page 136


Summary

You explored the Service Factory pattern in this chapter. The service factory is a derivative of common object-oriented Class Factory patterns, likely originating with the Abstract Class Factory pattern. The Service Factory pattern will prove useful as standards permeate the Web Service industry; until then, producing the return on investment will be difficult. In the short term, the service factory will be valuable as a way to isolate service selection and instantiation logic. In the medium term , as your partners come on board with Web Services, you can use the Mediator pattern to help mitigate differences in services. Eventually, assuming the success of Web Services, the service factory will be able to stand on its own. In the meantime, your company must remain active with standards bodies ”as well as with your partners ”to produce interfaces that benefit you and your partners.

In this chapter, you applied the Service Factory pattern to a business process. In most cases, the pattern applies best to business processes, especially in terms of fulfilling the requirements of activities within a business process. There are cases that you could use the Service Factory pattern to relate to business objects or object collections. For example, you could leverage the Service Factory pattern when you have two active business systems with one being the system of record in a transition. When the time for a transition comes, you could configure the factory to locate the new system of record for persistence of your data.



Related Patterns

The Service Factory pattern can apply to any of the four base types and can be enhanced in a variety of ways:

Business Object, Business Object Collection, Business Process, and Business Process Factory: Each of the primary structure types in aWeb Service environment can benefit from a service factory implementation. The Service Factory pattern applies when you connect to a Web Service without knowing the address of the Web Service before build time.

Service Cache: The Service Cache pattern decouples the responsibility of maintaining service access points for use in the service factory from the service factory. Instead, you deploy a separate component that interacts with UDDI and the UDDI notification mechanisms to maintain a list of valid access points. This pattern is not documented within this chapter, but it will be available from SourceForge after the book's publication.



Additional Reading

  • ebXML: http://www.ebxml.org

  • Oasis: http://www.oasisopen.org

  • Carey, James; Carlson, Brent. Framework Process Patterns: Lessons Learned Developing Application Frameworks . Addison-Wesley, 2002.

  • Carey, James; Carlson, Brent; Graser, Tim. San Francisco Design Patterns: Blueprints for Business Software . Addison-Wesley, 2000.

  • Fowler, Martin et. al. Patterns of Enterprise Application Architecture . Addison-Wesley, 2002.

  • Gamma, Erich et. al. Design Patterns: Elements of Reusable Object-Oriented Software . Addison-Wesley, 1995.



Chapter 16: Implementing the Data Transfer Object Pattern

Overview

The previous two chapters discussed mechanisms for optimizing a client's use of a Web Service. You will find that, in practice, Web Service operations are relatively expensive when compared to a local method call between objects in the same process. Consider Figure 16-1 (previously shown as Figure 4-2). A communication path between two components , ArchitectureAComponent and ArchitectureBComponent , contains at least two transformations in a single direction and an intermediate format. Then, consider that each call must return from the one-way trip with a new value.

click to expand
Figure 16-1: Web Service architecture participants

The first leg of a trip in a call from the ArchitectureAComponent component to the ClientAdapterA component typically traverses the A architecture's communication mechanism. The ClientAdapterA component transforms the call to the Simple Object Access Protocol (SOAP) format and traverses a Hypertext Transfer Protocol (HTTP) path to the ClientAdapterB component. There, ClientAdapterB transforms the call from SOAP to the ArchitectureBComponent 's format and communication mechanism. After receiving a response from the target component, the return trip duplicates the path through SOAP and HTTP. You can probably see how this path is a little more expensive than a local method call.

Now, consider a target object with five different values you would like to retrieve, each with a get operation. This is five separate Web Service calls: 10 trips through SOAP, 20 communication mechanism conversions, and 10 traversals through the HTTP protocol ”all for five values. If the Web Service developer knows that clients retrieve a particular group of values in a series of Web Service operations, you can drastically improve performance by allowing clients to retrieve all of the values in a single operation. This performance gain occurs simply by minimizing the number of operations the client must conduct. From 10 traversals through SOAP and HTTP, you reduce this to two. Imagine the secondary savings on garbage collectors and raw processing power.

This value proposition is the motivation for the Data Transfer Object and Data Transfer Collection patterns. The Data Transfer Object pattern became a heavily used pattern over the past five years as remote object manipulation became a reality. It is now used in Java 2 Enterprise Edition (J2EE) applications, Jini applications, and virtually all enterprise object-based systems. This chapter explores the basics of the Data Transfer Object pattern and then discusses how you apply it using Web Services. You will also see a slight variation of the Data Transfer Collection pattern, which is a simple extension to the Data Transfer Object pattern that applies to collections of objects rather than single objects.

Note  

Often, information in this chapter applies to both the Data Transfer Object and the Data Transfer Collection patterns; in these cases, this text refers to the pair of patterns as simply the Data Transfer patterns.