In a project i am working on, we have an EJB backend where various clients connect remotely (i.e. Web layer, web services layer, etc). The clients are on another machine and can be in another data center, so the front end and backend are never in the same app server.
The backend is layered as follows:
SLSB <-> Service Layer Objects <-> DAO
All objects are spring managed, except for the SLSB. The chain of events is as follows:
Initialization:
- Entity Manager injected into DAO
- DAO injected into Service Object
- Service Object injected into SL EJB
- SLSB's only provide a remote interface All objects are Singleton and stateless
Request/Response:
method invoked on EJB, delegates to Service Object, uses DAO's, return DTO
The DAO's encapsulate all the query operations on JPA entities. No JPA entity bleeds past the service layer. The service layer demarcates the transaction.
What happens to the JPA entities once the request/response lifecycle is complete with this architecture? Should the service layer attempt to cache the entities, or is that hibernates job?
And any comments on this architecture is welcome.
thanks
- Billworth