wood burning stoves 2.0*
The moose likes Spring and the fly likes compare Spring and ServiceLocator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "compare Spring and ServiceLocator " Watch "compare Spring and ServiceLocator " New topic
Author

compare Spring and ServiceLocator

Chandra Mohan
Ranch Hand

Joined: Oct 06, 2003
Posts: 62

How do you compare Spring and ServiceLocator Pattern? Which is better and Why?



Thanks and Regards
Chandra Mohan
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Do you like Blondes, Brunettes, or RedHeads, and why? ;)

Well the question is very open ended and I doubt you will get a full answer. But ServiceLocator is a pattern, Spring is a framework. You can do a Google search to find out the difference between that. Also Spring framework uses lots of design patterns, not just one.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Chandra Mohan
Ranch Hand

Joined: Oct 06, 2003
Posts: 62
well, This is one of the question has been asked in recent interview. I have very clear idea about the frame work and design patterns. It is open screat that spring has collection design patterns and service locator is one of the design pattern which has been included in spring. As per my understand (differences), Spring services are injected into your business classes rather than the business classes looking up a service.

I don't want full answer, Just to get the knowledge. I will not post this message if I get the answer in google, If you find anything in google search, give me link.

Any other differences ??
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
I suppose that you mean Spring IoC and Service Locator.

Spring IoC is better in terms of dependency management, the dependent doesn't look up or create dependencies, the control is inverted, the dependent just defines interfaces and the container injects dependencies to the dependent (dependency injection that is).


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Yeah, I guess a good simple explanation on the difference is that Inversion Of Control is pretty much the opposite of ServiceLocator. Instead of looking up its dependencies. the dependencies are injected into the class instead. But there is so much more with Proxies and AOP to add services like Transactions and stuff. That is why it becomes a comparison of Apples to Oranges and would require a very lengthy post to list all the differences.

Mark
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: compare Spring and ServiceLocator
 
Similar Threads
what is the advantage of spring over struts..
Spring vs Pico container
To authors
Hibernate and Spring ORM
Enthuware doubt : Buisness Delegate