org.opencms.i18n
Class CmsResourceBundleLoader

java.lang.Object
  extended by org.opencms.i18n.CmsResourceBundleLoader

public final class CmsResourceBundleLoader
extends java.lang.Object

Resource bundle loader for property based resource bundles from OpenCms that has a flushable cache.

The main reason for implementing this is that the Java default resource bundle loading mechanism provided by ResourceBundle.getBundle(java.lang.String, java.util.Locale) uses a cache that can NOT be flushed by any standard means. This means for every simple change in a resource bundle, the Java VM (and the webapp container that runs OpenCms) must be restarted. This non-standard resource bundle loader avoids this by providing a flushable cache.

In case the requested bundle can not be found, a fallback mechanism to ResourceBundle.getBundle(java.lang.String, java.util.Locale) is used to look up the resource bundle with the Java default resource bundle loading mechanism.

Since:
6.2.0
Version:
$Revision: 1.9 $
Author:
Alexander Kandzior
See Also:
ResourceBundle, PropertyResourceBundle, CmsResourceBundle

Method Summary
static void flushBundleCache()
          Flushes the resource bundle cache.
static java.util.ResourceBundle getBundle(java.lang.String baseName, java.util.Locale locale)
          Get the appropriate ResourceBundle for the given locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

flushBundleCache

public static void flushBundleCache()
Flushes the resource bundle cache.


getBundle

public static java.util.ResourceBundle getBundle(java.lang.String baseName,
                                                 java.util.Locale locale)
Get the appropriate ResourceBundle for the given locale. The following strategy is used:

A sequence of candidate bundle names are generated, and tested in this order, where the suffix 1 means the string from the specified locale, and the suffix 2 means the string from the default locale:

In the sequence, entries with an empty string are ignored. Next, getBundle tries to instantiate the resource bundle:

If no resource bundle was found, the default resource bundle loader is used to look for the resource bundle. Class based resource bundles will be found now.

Parameters:
baseName - the name of the ResourceBundle
locale - A locale
Returns:
the desired resource bundle