last update: 06/29/2004 11:06:27

The ResourceLocator


The ResourceLocator originated from O'Reilly's Java Servlet Book by .
We had people asking how to get the config.xml into their installation and we were destined to
use the basis from the ResourceLocator. Originally we looked for the config.xml by asking the
immediate ClassLoader, hey give me any config.xml as resource within your classpath. This
turned out to be insufficient as soon as servlet containers and ejb containers came into to the
game. People wanted generic config.xml files where the container would hold the resources.
Hence the need for the ResourceLocator.

The ResourceLocator is fairly easy to use, if only a ResourceLocator is needed. The
ResourceLocator created will attempt to return a File object. The main idea behind the
ResourceLocator is to check the immediate ClassLoader for resources or urls. If nothing is found
we move up to the next ClassLoader and try again until all ClassLoaders have been queried.