This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Why 2 ServiceLocator Patterns, one for web and one for EJB? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Why 2 ServiceLocator Patterns, one for web and one for EJB?" Watch "Why 2 ServiceLocator Patterns, one for web and one for EJB?" New topic
Author

Why 2 ServiceLocator Patterns, one for web and one for EJB?

Saras Moven
Greenhorn

Joined: Jan 30, 2004
Posts: 2
Hello,

I have looked at the ServiceLocator pattern from the Sun J2EE blueprints website. I noticed that there are two ServiceLocators, one for use by the web tier and one for use by the EJB tier. I understand the principle of having only one instance of the ServiceLocator object in the web tier which is obtained by using the getInstance() method. But for the EJB tier the blueprint site says you should create a new instance of the ServiceLocator object each time you use it. I don't understand why this is so?

If anyone can shed some light on this it would be nice.

Thanks.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
kindly check it out.

http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html

may it would be helpful. cannot explain better than this. it includes all the explaination with relevent diagrams.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Saras,

Welcome to the 'ranch!

We have a naming policy which requires a display name to include a lastname so I'll have to ask you to add one.

Thanks.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
jQuery in Action, 2nd edition
 
subject: Why 2 ServiceLocator Patterns, one for web and one for EJB?