Class StoredBundleControl
java.lang.Object
java.util.ResourceBundle.Control
org.tentackle.i18n.StoredBundleControl
- All Implemented Interfaces:
DomainContextProvider
Bundle control to use stored bundles.
Used by
Used by
StoredBundleFactory in modular apps as well as by ResourceBundle in non-modular apps.- Author:
- harald
-
Field Summary
Fields inherited from class ResourceBundle.Control
FORMAT_CLASS, FORMAT_DEFAULT, FORMAT_PROPERTIES, TTL_DONT_CACHE, TTL_NO_EXPIRATION_CONTROL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StoredBundle.StoredBundleUDKCreates the unique domain key to load a stored bundle.Gets the domain context.getFormats(String baseName) longgetTimeToLive(String baseName, Locale locale) static booleanReturns whether properties should be tried if no stored bundle found.protected StoredResourceBundleLoads the bundle from storage.newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) static voidsetFallbackToProperties(boolean fallbackToProperties) Sets whether properties should be tried if no stored bundle found.Methods inherited from class ResourceBundle.Control
getCandidateLocales, getControl, getFallbackLocale, getNoFallbackControl, needsReload, toBundleName, toResourceNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DomainContextProvider
isWithinContext, isWithinContext, on, on, op, op
-
Constructor Details
-
StoredBundleControl
public StoredBundleControl()Creates a stored bundle control object.
-
-
Method Details
-
isFallbackToProperties
public static boolean isFallbackToProperties()Returns whether properties should be tried if no stored bundle found.- Returns:
- true for using resources from properties (default)
-
setFallbackToProperties
public static void setFallbackToProperties(boolean fallbackToProperties) Sets whether properties should be tried if no stored bundle found.- Parameters:
fallbackToProperties- true to use resources from properties, false to throwMissingResourceException
-
getDomainContext
Description copied from interface:DomainContextProviderGets the domain context.- Specified by:
getDomainContextin interfaceDomainContextProvider- Returns:
- the domain context
-
getFormats
- Overrides:
getFormatsin classResourceBundle.Control
-
getTimeToLive
- Overrides:
getTimeToLivein classResourceBundle.Control
-
newBundle
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException - Overrides:
newBundlein classResourceBundle.Control- Throws:
IllegalAccessExceptionInstantiationExceptionIOException
-
createUDK
Creates the unique domain key to load a stored bundle.The locale suffix is derived from the locale, not by searching the bundle name for an underscore: base names may contain underscores themselves, and
org.myapp.Texts_v2must not be read as the bundleorg.myapp.Textsfor the localev2.- Parameters:
baseName- the base bundle name of the resource bundlelocale- the locale- Returns:
- the unique domain key
-
loadStoredBundle
Loads the bundle from storage.- Parameters:
key- the unique domain key- Returns:
- the stored resource bundle or null if no such bundle in the database
-