This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding Business Delegate, Stateless Session Bean and Entity Bean in SCEA Part 2

 
Madhu Maniganta
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All Ranchers,
Thanks all for your support, I am working on part 2 and have a question about Dependency Injection in Business Delegate layer in a n Tier architecture.
(A) Is having jsp--->Managed Bean--->Business Delegate--->Service Locator--->Stateless Session Bean(Dependency Injection)---->Entity JPA acceptable in class and sequence diagrams?
OR
(B) should I show a Business Delegate with Dependency Injection also like Stateless Session Bean injects for EntityManager? which means
jsp--->Managed Bean--->Business Delegate (Dependency Injection)--->Stateless Session Bean(Dependency Injection)---->Entity JPA in my diagrams?

which among (A) and (B) is correct?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you were implementing this code, would you be writing a service locator? If so, A is correct. If not, B is correct.
 
Madhu Maniganta
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for the response. If I go with (B), can a Business Delegate be used just to separate Presentation layer and Business Layer. Because I read on the sun website (link below) that Business Delegate hides lookup and access details of EJB architecture, does it mean that Business Delegate and Service Locator must go together? or can I just use it as a Presentation and Business layer separator?

http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html
 
Dmitri Ericsson
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used much simplier and straightforward solution (and passed):
JSF->Stateless Bean (dependency injcection)->JPA
The lookup is done by the server in dependency incjection, so I think there is no need for locators or business delegaetes.
 
Rajiv Shr
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You dont need to use Service Locator if you are using Dependency Injection. Both do the same thing ie hiding the complexity of the lookup, and they both do it differently. You should use one or the other, not both. Read this article - http://martinfowler.com/articles/injection.html#ServiceLocatorVsDependencyInjection

For your follow-up question, yes, you can use Business Delegate as a separation between the presentation and business layer. There are different opinions on where to show the business delegate component in the Component diagram in part 2. I showed it in the presentation layer.

- Rajiv
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic