i am designing a test architecture for my j2ee application. I have following queries regarding design patterns.
1) can session bean be used in replace of Daos? if yess! then under what possible scenario?( in fact, some one commented me that session bean and dao can be used as alternatives of each other... whereas my point of view is that session bean captures business object and business flows and dao separates the data access mechanism)
2) benefits of using business delegates over session beans? Are'nt these two do the same ?
I think I don't understand your question... but:
1/ DAO can be implemented with Stateless Session Bean or POJO.
With JPA in J2EE 5.0, implementing a DAO with a Stateless SB is really simple.
2/ The definition of the Business Delegates is:
Use a Business Delegate to encapsulate access to a business service. The Business Delegate hides the implementation
details of the business service, such as lookup and access mechanisms.
So, a Business Delegate is a Business Tier Pattern that resides in the client tier.
If you have business services implemented as Session Bean, the Business Delegates will be an abstraction of this Session Bean in the client tier.
I really recommend that you read "Core J2EE Patterns" to clarify those points.
Thank you for replying, Your reply of point 1.
made me to conculde that session Bean can be used as both, the implementation of session facade pattern and Dao Pattern.
DAO can be implemented with Stateless Session Bean or POJO.
Implementing Dao with pojo sounds good but i am wondoring is there any special benefit of using statless Session Bean as DAO then POJO. i guess POJO will be quite simpler for me.
If you want to take advantage of container services like transactions and security, to name but a couple, you can use annotations, and/or the ejb-jar.xml deployment descriptor, to deploy your POJOs as stateless session beans.
Issues like these are at the very heart of J2EE. I think you really need to read the relevant sections in the EJB specification to understand what stateless session beans are. If you want to use stateless session beans to manage access to your persistent entities then I suggest you also look through the JPA sections of the EJB specification, particularly those related to persistent contexts.