J2EE Design Pattern : Integration Tier Patterns : Domain Store Design Pattern
Domain Store Design Pattern? |
Domain Store is used for separating persistence from object model.
Problem
Many systems have a complex object model that requires sophisticated persistence strategies. With the addition of container-managed relationships (CMR) to EJB 2.x container managed persistence (CMP), it is much more feasible to employ CMP as a persistence strategy for complex object models .
However, some developers opt to not use entity beans or run an application in a web container, and prefer to separate persistence from the object model.
Context
You want to separate persistence from your object model.
Solution
Use a Domain Store to transparently persist an object model. Unlike J2EE’s container-managed persistence and bean-managed persistence, which include persistence support code in the object model, Domain Store’s persistence mechanism is separate from the object model.
You can implement Domain Store in two ways: either write a custom persistence framework, or use a persistence product.
The products are typically based on the Java Data Objects (JDO) specification or a proprietary object relational solution.
Participants and Collaborations
ApplicationService
It is an application service object and it interacts with persistable business objects.
Persistable
An interface or base class that all business objects that will be persisted must implement.
PersistenceManagerFactory
Creates and manages PersistenceManagers.
PersistenceManager (Unit of Work)
It manages the persistence and queries of the object model. The PersistenceManager interacts with the StateManager, not the business object. The PersistenceManager instructs the StateManager to update object state when necessary.
StateManager (Data Mapper)
It manages the state of Persistable objects. The Persistable object shares the responsibility for managing its state with the StateManager. The StateManager enforces transactional storage and retrieval of state from the Data resource.
StoreManager (Data Gateway)
It interacts with the data resource to perform CRUD operations. The StoreManager is a DAO and encapsulates all the data resource mechanisms.
Data resource
It is any resource service that manages data. It can be a relational database, object oriented database, EIS, and so on.
These are classes that are typical when implementing Domain Store, but are not central to the pattern.
SessionFacade
It is entry point into service layer. Communicates with one or more ApplicationServices.
PersistMap
It contains the relationships among the objects and the mappings between persistable objects and the data resource.
Transaction
This is an artifact of PersistenceManager, not an independent component. It is used to set transaction-oriented policies, and to delimit transactions in non-managed environments.
Query
It encapsulates a query, typically the extent of instances to query, filtering criteria, ordering, and parameter declarations.
Implementation Strategies
- Custom Persistence Strategy
- JDO Strategy
Example for Domain Store |
hi!,I really like your writing so a lot! proportion we keep in touch more about your article on AOL?
Good way of explaining, and good piece of writing to obtain facts regarding my presentation subject, which i am going to deliver in college.