Skip to content

Commit 112c719

Browse files
committed
Update README.md
Added service locator information
1 parent 1cb62f5 commit 112c719

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [Facade](#facade)
2222
* [Flyweight](#flyweight)
2323
* [Proxy](#proxy)
24+
* [Service Locator](#service-locator)
2425
* Behavioral Patterns
2526
* [Chain of responsibility](#chain-of-responsibility)
2627
* [Command](#command)
@@ -174,6 +175,19 @@
174175
* facilitate network connection
175176
* to count references to an object
176177

178+
## <a name="service-locator">Service Locator</a> [&#8593;](#list-of-design-patterns)
179+
**Intent:** Encapsulate the processes involved in obtaining a service with a strong abstraction layer.
180+
181+
![alt text](https://github.com/iluwatar/java-design-patterns/blob/master/service-locator/etc/service-locator.png "Proxy")
182+
183+
**Applicability:** The service locator pattern is applicable whenever we want to locate/fetch various services using JNDI which, typically, is a redundant and expensive lookup. The service Locator pattern addresses this expensicve lookup by making use of caching techniques ie. for the very first time a particular service is requested, the service Locator looks up in JNDI, fetched the relavant service and then finally caches this service object. Now, further lookups of the same service via Service Locator is done in its cache which improves the performance of application to great extent.
184+
185+
186+
**Typical Use Case:**
187+
188+
* When network hits are expesive and time consuming
189+
* lookups of services are done quite frequently
190+
* large number of services are being used
177191

178192
## <a name="chain-of-responsibility">Chain of responsibility</a> [&#8593;](#list-of-design-patterns)
179193
**Intent:** Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

0 commit comments

Comments
 (0)