Name

DAO Factory

Goal

To hide the process of selecting an appropriate persistence layer or set DAO objects from the business tier, and to allow configuration of DAO features at runtime in a centralized manner (Figure B-3).

DAO factory with two DAO types
Figure B-3. DAO factory with two DAO types

Participants

Client

Includes a business tier or a presentation tier object.

DAO factory

Determines how to create the DAO object.

Implementation-specific factory

Responsible for creating the DAO objects.

DAO implementation

The implementation itself.

Interactions

The client, a business tier or presentation tier object, calls a method on a DAO factory object, requesting a DAO object. The DAO factory is responsible for determining how to create the DAO object. This may involve implementation-specific DAO factories responsible for creating the DAO objects.

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.