atg.core.i18n
Class LayeredResourceBundle

java.lang.Object
atg.core.i18n.LayeredResourceBundle

public class LayeredResourceBundle

extends java.lang.Object

A class capable of creating layered resource bundles. Layered
resource bundles function similiarly to Nucleus component
properties files, where it is possible to override a property
definitions by creating a properties file in the same location
as the original, but in a different configuration layer.

Layered resource bundles work by layering properties files
contained in different class paths. Properties definitions in files
that appear earlier in the classpath will override property
definitions which appear later in the classpath.

This class attempts to be a drop-in replacement for calls to
ResourceBundle.getBundle(). It implements allowing classes earlier
in the classpath to override or extend individual property values,
but allows values from later in the classpath to "bleed through."
Thus it mimics the same behavior that Nucleus properties have.

The known limitations of LayeredResourceBundle are:

It only supports properties file format for resources, not XML format

It does not know the ClassLoader of the calling class. It will attempt
to use the current Context ClassLoader, if one is not explicitly
passed in, and fall through to its own ClassLoader.

LayeredResourceBundle is not compatible with the "-collapse-class-path"
option of the /bin/runAssembler command.

ResourceBundle.getBundle() uses a non-public native call to get the ClassLoader
of the call of the ResourceBundle.getBundle() method. Since LayeredResourceBundle
does not have access to that call, you may need to pass in your ClassLoader
explicitly. So, you may need invoke
ResourceBundle.getBundle(String pBaseName, Locale pLocale, ClassLoader pLoader)
and pass in this.getClass().getClassLoader() for the ClassLoader argument.

getBundle

Gets a layered resource bundle using the specified base name and locale,
and the LayeredResourceBundle's class loader. Calling this
method is equivalent to calling
getBundle(baseName, Locale.getDefault(), Thread.currentThread().getContextClassLoader()).
And, if the above returns null, returning the result of:
getBundle(baseName, locale, LayeredResourceBundle.class.getClassLoader()).

Parameters:

pBaseName - the base name of the resource bundle, a fully qualified class name

pLocale - the locale for which a resource bundle is desired

Returns:

a resource bundle for the given base name and locale

Throws:

java.lang.NullPointerException - if baseName or locale is null

java.util.MissingResourceException - if no resource bundle for the specified base name can be found

See Also:

ResourceBundle.getBundle(String,Locale)

getBundle

Gets a resource bundle using the specified base name, locale, and class loader.
See ResourceBundle.getBundle(String,Locale,ClassLoader) for a
full description of the search path used to obtain a resource bundle. This is
further augmented by a pre-processing step, where all resource bundle properties
files with a given name will be collapsed into a single file. The files will be
combine in such a way that entries which come early in the classpath will appear
at the end of the input stream. The ResourceBundle code will then
create a Properties instance using that composite input stream. Given
that later entries in the Properties map will overwrite earlier
entries, the result will be a ResourceBundle whose values can be overriden
by prepending a sparse properties file, containing only the values to be altered,
to the beginning of the class-path.

Parameters:

baseName - the base name of the resource bundle, a fully qualified class name

locale - the locale for which a resource bundle is desired

loader - the class loader from which to load the resource bundle

Returns:

a resource bundle for the given base name and locale

Throws:

java.lang.NullPointerException - if baseName, locale, or loader is null

java.util.MissingResourceException - if no resource bundle for the specified base name can be found