J2EE Design Pattern : Business Tier Patterns : Transfer Object Assembler Design Pattern
|Transfer Object Assembler Design Pattern?|
Transfer Object Assembler obtain an application model this aggregates transfer objects from several business components.
Application clients frequently need to obtain business data or an application model from the business tier. When the clients need the application model data, they must locate, access, and obtain different parts of the model from different sources, such as Business Objects, Data Access Objects, Application Services, and other objects in the business tier. This approach leads to several problems:
Direct access between the clients and these components in a different tier introduces coupling between the tiers. Due to tight coupling, changes made to the business tier components cause a ripple effect throughout the clients.
The client code complexity increases because the client has to interact and manage with several business components and business logic to construct the model that gets embedded in the client code.
You want to obtain an application model that aggregates transfer objects from several business components.
Use a Transfer Object Assembler to build an application model as a composite Transfer Object. The Transfer Object Assembler aggregates multiple Transfer Objects from various business components and services, and returns it to the client.
The Transfer Object Assembler retrieves Transfer Objects from the business components. The Transfer Objects are then processed by the Transfer Object Assembler, which creates and assembles a composite Transfer Object to represent the application model data. The clients use the Transfer Object Assembler to obtain this application model for read-only purposes to display or to perform other intermediate processing. Clients do not change the data in the composite Transfer Object.
Participants and Collaborations
Client invokes the TransferObjectAssembler to obtain the application model data. The Client can be a component in the presentation tier or can be a Session Façade that provides the remote access layer for the clients accessing the TransferObjectAssembler. If the TransferObjectAssembler is implemented as a session bean, then the Client can be a Session Façade or a Business Delegate.
The TransferObjectAssembler is the main class of this pattern. The TransferObjectAssembler constructs a new composite transfer object based on the requirements of the application when the client requests the application model data.
The ApplicationModel object is a composite Transfer Object that is constructed by the TransferObjectAssembler and returned to the Client.
BusinessObject represents a Business Object that provides Transfer Objects to the TransferObjectAssembler to assemble the ApplicationModel.
The SessionFacade represents a Session Façade that provides part of the data required to construct the ApplicationModel transfer object.
DataAccessObject represents a Data Access Object, used when the TransferObjectAssembler needs to obtain data directly from the persistent store.
The Service is any arbitrary service object including an Application Service in the business tier that provides the data required to construct the ApplicationModel object.
- POJO Strategy
- Session Bean Strategy
|Example for Transfer Object Assembler|