File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Service Locators vs. Spring's Dependency Injection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Service Locators vs. Spring Watch "Service Locators vs. Spring New topic
Author

Service Locators vs. Spring's Dependency Injection

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 219
What are the benefits of service locators? I know that they encapsulate JNDI lookups in J2EE based architectures.

Also, a service locator hides the implementation details of the lookup mechanism and encapsulates related dependencies.

Is it true that they clash with Spring's dependency injection by creating somewhat of a "disjunct architecture" when included in the same system?

Thank you for taking the time to read this.
Ramon Anger
Ranch Hand

Joined: Apr 19, 2011
Posts: 56

Hi James,

there is an old article from Martin Fowler covering dependency injection (pattern) and service locators at http://martinfowler.com/articles/injection.html. Maybe it helps for a first answer, although it's not Spring specific.

Best regards,
Ramon


Blackbelt on BlackBeltFactory.com.
Yash Don
Greenhorn

Joined: May 19, 2010
Posts: 12
there is an old article from Martin Fowler covering dependency injection (pattern) and service locators at http://martinfowler.com/articles/injection.html. Maybe it helps for a first answer, although it's not Spring specific.



Very useful link.

Thanks,
Yash

Regards,
Yash

SCJP, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Service Locators vs. Spring's Dependency Injection