Service Locator pattern

Please can any one help me with service locator patternMessage was edited by: casualProgrammer
[115 byte] By [casualProgrammera] at [2007-11-27 8:52:52]
# 1
Only if you ask a more specific question
georgemca at 2007-7-12 21:09:12 > top of Java-index,Java Essentials,Java Programming...
# 2

Say you're dealing with classes that extend org.dingbat.AbstractWidgetFactory.

In any jar which contains concete implementations you place a text file called

META_INF/services/org.dingbat.AbstractWidgetFactory

In this file you put the FQNs of the implementing classes, one per line (usual # comment convention applies).

When the getInstance() method of AbstractWidgetFactory is called it does getResources() to find all such service files on the class path, reads them, loads the classes, and then picks one to use.

malcolmmca at 2007-7-12 21:09:12 > top of Java-index,Java Essentials,Java Programming...