public final class CmsResourceBundleLoader
extends java.lang.Object
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.
ResourceBundle
,
PropertyResourceBundle
,
CmsPropertyResourceBundle
限定符和类型 | 方法和说明 |
---|---|
static void |
addBundleToCache(java.lang.String baseName,
java.util.Locale locale,
I_CmsResourceBundle bundle)
Adds the specified resource bundle to the permanent cache.
|
static void |
flushBundleCache()
Flushes the complete resource bundle cache.
|
static void |
flushBundleCache(java.lang.String baseName,
boolean flushPermanent)
Flushes all variations for the provided bundle from the cache.
|
static java.util.ResourceBundle |
getBundle(java.lang.String baseName,
java.util.Locale locale)
Get the appropriate ResourceBundle for the given locale.
|
public static void addBundleToCache(java.lang.String baseName, java.util.Locale locale, I_CmsResourceBundle bundle)
baseName
- the raw bundle name, without locale qualifierslocale
- the localebundle
- the bundle to cachepublic static void flushBundleCache()
public static void flushBundleCache(java.lang.String baseName, boolean flushPermanent)
baseName
- the bundle base name to flush the variations forflushPermanent
- if true, the cache for additional message bundles will be flushed, toopublic static java.util.ResourceBundle getBundle(java.lang.String baseName, java.util.Locale locale)
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.
baseName
- the name of the ResourceBundlelocale
- A locale