Name

Service Adapter

Goal

Simplify access to remote business data by adapting the data into Java objects.

Participants

Client

Manipulates business data using an adapter.

Service adapter

Adapts business data into a convenient Java implementation.

Business service

Stores and controls access to business data (Figure B-9).

Interactions in a SOAP service adapter
Figure B-9. Interactions in a SOAP service adapter

Interactions

The client creates and initializes the service adapter. The client requests business data from the adapter, passing in Java objects as arguments. The adapter connects to the remote service using an appropriate protocol and translates any arguments to the correct form. The adapter receives the results and translates them into Java objects, which are returned to the client.

Notes

Service adapters are most useful when business data is stored in a non-Java format. Adapters may also be used to impose desired semantics such as transactions onto services. For EJBs, service locators are usually more appropriate than service adapters.

Get J2EE Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.