Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Common Service Locator widely used?

I'm working on a new project now, and have given some thought to the IoC setup. I'm aware that you shouldn't be depending on the service location pattern (much, anyway), but that there are just a few places in a well-structured application where it may be necessary. In that case, do you use the CommonServiceLocator project, or not bother with it?

I'm essentially looking for feedback on whether the CSL is used at all, or how widely it is used.

like image 704
Grant Palin Avatar asked Feb 07 '10 19:02

Grant Palin


People also ask

Should I use service locator?

Service Locator is a well-known pattern, and since it was described by Martin Fowler, it must be good, right? No, it's actually an anti-pattern and should be avoided.

What is common service locator?

Service Locator holds reference of all types/objects an application needs. So whenever you need to use an instance of a type/class, ask service locator to provide the instance. Simply, the Service Locator uses a container to hold all references to class/type to instance/object mapping.

What is the difference between service container and service locator?

Worth to note that a service locator is often called a container. Both things are the same. Both of them are meant to provide instances or services however you prefer to call them.

What is Servicelocator in Java?

Service Locator - Service locator is a design pattern that allows a service to be decoupled from its consumer by using a “service locator” to retrieve it. In Java an interface or abstract class is used to define the structure of the service.


1 Answers

Going purely on the number of recorded downloads here: Common Service Locator Downloads it looks like it has a very small number of users for a general purpose library.

It provides a level of indirection between client code and its service locator. The deal is that you sacrifice access to the APIs of your chosen IoC framework in return for portability across IoC frameworks. Unless your code needs to support multiple service locators, then it doesn't really help you. See: When would you use the Common Service Locator.

Version 1.0 looks like a very basic factory pattern implementation, so it's probably not worth worrying about too much either way.

like image 58
richj Avatar answered Nov 10 '22 16:11

richj