This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Dependency Injection (DI) or Business Delegate (BD) when using EJB 3:
I am new to EJB 3 but have used EJB 2 almost 5 yrs back and am familier with Business Delegate -->Service Locator -->Session Facade -->DTO-->DAO way of accessing entities.
But EJB 3 supports POJO which eleminates the need for DTO and also supports DI which eleminates the need for BD. I didnt get a chance to use EJB 3 yet. So actually i am confused in choosing b/w these two. I think we can still have a BD to get access to a session facade (which is remote) from the presentation layer (which will be on a different machine on a different jvm). Have the DI for accessing local ejb's (with in same jvm). Any thoughts ?
Also how do i depict the DI in a class diagram, i know how to do that for a BD as we have pattern for that. Any references/example to depict DI in a class diagram will be greatly appreciated.
You can use DI which will inject Service Facade(EJB 3 Session Beans) into your presentation tier. You can refer to Mark Cade's book and show the DI and other common infrastructure/utilities/helper classes in a separate package(the way it is done in the book). That is sufficient.
How dependency injection eliminates the need for business delegate? As I understand they serve different purposes. Dependency injection eliminates the need for Service Locator, sometimes. Business Delegate's purpose is to decouple presentation from business logic. No matter whether it's EJB or not.
Anyway, in my assignment I've been used EJB3 and business delegate.