com.tonbeller.wcf.utils
Class ResourceLocator

java.lang.Object
  extended bycom.tonbeller.wcf.utils.ResourceLocator

public class ResourceLocator
extends java.lang.Object

searches for resources in a locale specific way

Author:
av

Method Summary
static java.net.URL getResource(javax.servlet.ServletContext context, java.util.Locale locale, java.lang.String uri)
          Searches for a resource in a way similar to ResourceBundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResource

public static java.net.URL getResource(javax.servlet.ServletContext context,
                                       java.util.Locale locale,
                                       java.lang.String uri)
                                throws java.net.MalformedURLException,
                                       java.util.MissingResourceException
Searches for a resource in a way similar to ResourceBundle. It tries to match the language and country codes. Example: with path "/test.xml", language "en" and country "US" the following resources will be searched:
  1. test_en_US.xml
  2. test_en.xml
  3. test.xml

Implementation note: the search results will be cached, so you have to restart the servlet after adding or removing files.

Throws:
java.util.MissingResourceException - if no resource is found
java.net.MalformedURLException