Foobar&Sons, vendor of Multigrate, a platform that aims to integrate CRM data from various vendors, wants to handle data transfer between a growing number of systems, starting with FirstSYS and SecondSYS.
Both systems Multigrate deals with, have customer data (person and address) but represented in a different way. Multigrate shall transfer customer data between the two platforms.
In this scenario we want to apply the Mapper Pattern to provide an object that sets up a communication between two independent objects (Fowler).
We have identified the customer as the object that exists in firstsys and secondsys but represented in a different way. To connect both sides we introduce the CustomerMapper.
The CustomerMapper moves data from firstsys to secondsys and vice-versa.
Here the mapping process (when to map) is triggered by the Session.
Open MapperTest.java to start playing with this pattern. By setting the log-level for this pattern to DEBUG in logback.xml you can watch the pattern working step by step.
- The pattern effectively limits dependencies. The CustomerMapper depends on details in firstsys and secondsys, none of them depends in any way on the mapper.
- (Fowler) Fowler, M.: Patterns of Enterprise Application Architecture. Addison-Wesley (2002)