Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41073
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic