Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServiceLocator on the web tier and the EJB tier

 
Stephen Suen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun PetStore 1.4 demonstrates two difference ServiceLocator implementations for the web tier and the EJB tier:

com.sun.j2ee.blueprints.servicelocator.web.ServiceLocator
com.sun.j2ee.blueprints.servicelocator.ejb.ServiceLocator

The one for the web tier uses the "singleton" strategy and also the "caching" strategy.

I wonder that why we need two different implementations. Is there any problem if we use a single one implementation that uses a cache for both web tier and EJB tier?

Any help will be appreciated.

Stephen
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephen,

Not sure if I can help you much since I don�t remember much about PetStore application and the only thing I remember is that PetStore is probably one of the best examples proving that J2EE in general and Sun design patterns in particular are such low quality software solutions. This gave Microsoft the possibility to develop their .NET PetShop counterpart that uses 10 times less amount of code and performs several times better, while it provides the same functionality. It�s also funny when you think that were people trying to improve the PetStore app, but they used different patterns and practice that were forbidden by Sun. What a mess�
Hence my first advice to you would be to look somewhere else for design patterns and don�t take it very hard to understanding PetStore.
On the other hand, without pretending I�ll give you the right answer, one good reason to have two different service locators, is because the web tier has two possibilities: to access the ejbs through remote or local interfaces, depending upon the clustering architecture, or simply if the web server and ejb container runs in different jvms. As for the ejb service locator, it supposes to use always the local interfaces, since the application uses a session fa�ade.
Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic