com.tonbeller.tbutils.res
Class ResourcesFactory

java.lang.Object
  extended bycom.tonbeller.tbutils.res.ResourcesFactory

public class ResourcesFactory
extends java.lang.Object

creates and caches Resources.

The factory is configured via four variables that are looked up in

  1. in JNDI java:/comp/env context
  2. resfactory.properties in root classpath
  3. System.getProperty()
in that order. This may be overridden by defining a java system property tbeller.initialResourceProvider, for example -Dtbeller.initialResourceProvider=com.tonbeller.tbutils.res.SystemResourceProvider will look up the initial variables in System properties only. This is meant for testing outside the web environment.

tbeller.locale
A string either 2 characters (e.g. "en") or 5 chars (e.g. "en_US"). If present, the application will not care about the browsers locale but use this locale instead.
tbeller.home
A directory that contains configuration files that have been modified by the customer and other resources. If not set the default is ${user.home}/.tbeller
tbeller.properties
whitespace separated list of property file names, relative to TBELLER_HOME. These files will be loaded via the file system. Should be defined in web.xml
tbeller.bundles
a whitespace separated list of ResourceBundle names that will be loaded via ResourceBundle.getBundle. Should be defined in web.xml

Author:
av

Field Summary
static java.lang.String INITIAL_PROVIDER
          If there is a ServletContext initParameter this provider will be used instead of the JNDI Provider.
static java.lang.String TBELLER_BUNDLES
           
static java.lang.String TBELLER_HOME
           
static java.lang.String TBELLER_LOCALE
           
static java.lang.String TBELLER_PROPERTIES
           
static java.lang.String USE_JNDI_PROVIDER
           
 
Method Summary
 java.util.Locale getFixedLocale()
          if the application was configured to use a fixed locale independent of the browsers locale, returns that locale.
static ResourcesFactory instance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_PROVIDER

public static final java.lang.String INITIAL_PROVIDER
If there is a ServletContext initParameter this provider will be used instead of the JNDI Provider.

See Also:
Constant Field Values

USE_JNDI_PROVIDER

public static final java.lang.String USE_JNDI_PROVIDER
See Also:
Constant Field Values

TBELLER_BUNDLES

public static final java.lang.String TBELLER_BUNDLES
See Also:
Constant Field Values

TBELLER_PROPERTIES

public static final java.lang.String TBELLER_PROPERTIES
See Also:
Constant Field Values

TBELLER_HOME

public static final java.lang.String TBELLER_HOME
See Also:
Constant Field Values

TBELLER_LOCALE

public static final java.lang.String TBELLER_LOCALE
See Also:
Constant Field Values
Method Detail

instance

public static ResourcesFactory instance()

getFixedLocale

public java.util.Locale getFixedLocale()
if the application was configured to use a fixed locale independent of the browsers locale, returns that locale. Returns null otherwise

Returns:
locale or null