• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

When to use the servicesLocator pattern, question about petstore1.3

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Today when I looked at petstore source code, I found this:
1. When signonEJB sessionbean calls the UserEJB entitybean local interface, it just simply lookup, it did not use serviceLocator.
2 .Then I found when shoppingClientFacadeLocalEJB session lookup the Customer entitybean, it uses serviceLocator.
3. Then I check the CORE PATTERN books, from the UML, it looks like if you try to lookup the sessionfacade from outside EJB container , using serviceLocator, if a sessionbean calls a entitybean, it does not use serviceLocator.
So anybody can explain this, I am really confuse by this. I am so suprised about this, before I thought we should always use serviceLocator whenever you try to lookup a EJB, I have been using this for a while in our project.
 
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think if you locate the REMOTE interface,the servicelocator can reduce the times to the jndi lookups,but to the LOCAL interface,i don't think the servicelocator make sense.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ServiceLocator pattern can be used (as the name suggests) for any Service. You can use this for getting the Datasources, database Connection from connection pool, JNDI lookups etc. The main purpose is to reduce the network calls. If your looking for an EJBHome object for the first time it will look for it on the network and cache it for later use. So you do not have to make a number of network calls again and again.
try:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html
http://www.precisejava.com
 
James Liu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the post, but the problem is :
in petstore example, when signonEJB sessionbean calls the UserEJB entitybean local interface, it just simply lookup, it did not use erviceLocator.
but when shoppingClientFacadeLocalEJB session lookup the Customer entitybean local interface, it uses serviceLocator. I mean why both cases is sessionbean lookup entityBean local interface, but one it uses servicesLocator, but the other not?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear James,
Try to think the following points:
1. the benefit of service locator
2. the applicability of service locator
3. the relationship between service locator and session facade
4. the type and functionality of SignOnEJB and ShoppingClientFacadeLocalEJB
Sincerely,
Hayes Sprint
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic