Class StoredBundleFactory
java.lang.Object
org.tentackle.common.DefaultBundleFactory
org.tentackle.i18n.StoredBundleFactory
- All Implemented Interfaces:
org.tentackle.common.BundleFactory
@Service(org.tentackle.common.BundleFactory.class)
public class StoredBundleFactory
extends org.tentackle.common.DefaultBundleFactory
Factory for stored bundles.
Replaces the
Replaces the
DefaultBundleFactory.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfindBundle(String baseName, Locale locale) findBundle(String baseName, Locale locale, ClassLoader loader) protected ResourceBundlestatic booleanReturns whether loading bundles from the backend is enabled at all.protected StoredResourceBundleloadStoredBundleChain(StoredBundle.StoredBundleUDK topKey, Function<StoredBundle.StoredBundleUDK, StoredResourceBundle> loader) Loads the stored bundle for a key and chains the stored bundles of the parent locales to it.static voidsetEnabled(boolean enabled) Sets whether loading bundles from the backend is enabled at all.Methods inherited from class org.tentackle.common.DefaultBundleFactory
createProviders, getClassLoader, getControl, getProviders, normalizeBasename, setClassLoader
-
Constructor Details
-
StoredBundleFactory
public StoredBundleFactory()Creates the bundle factory.
-
-
Method Details
-
isEnabled
public static boolean isEnabled()Returns whether loading bundles from the backend is enabled at all.- Returns:
- true if enabled (default)
-
setEnabled
public static void setEnabled(boolean enabled) Sets whether loading bundles from the backend is enabled at all.- Parameters:
enabled- true if enabled (default)
-
clearCache
public void clearCache()- Specified by:
clearCachein interfaceorg.tentackle.common.BundleFactory- Overrides:
clearCachein classorg.tentackle.common.DefaultBundleFactory
-
findBundle
- Specified by:
findBundlein interfaceorg.tentackle.common.BundleFactory- Overrides:
findBundlein classorg.tentackle.common.DefaultBundleFactory
-
findBundle
- Specified by:
findBundlein interfaceorg.tentackle.common.BundleFactory- Overrides:
findBundlein classorg.tentackle.common.DefaultBundleFactory
-
getBundle
- Overrides:
getBundlein classorg.tentackle.common.DefaultBundleFactory
-
loadStoredBundleChain
protected StoredResourceBundle loadStoredBundleChain(StoredBundle.StoredBundleUDK topKey, Function<StoredBundle.StoredBundleUDK, StoredResourceBundle> loader) Loads the stored bundle for a key and chains the stored bundles of the parent locales to it.Locales without a stored bundle are skipped, both when looking for the bundle itself and when linking its parents, just as
ResourceBundledoes for its list of candidate locales. A storedTexts_de_DE, for example, gets a storedTextsas its parent if there is noTexts_de.- Parameters:
topKey- the key of the requested bundleloader- loads the stored bundle for a key, returns null if there is no such bundle- Returns:
- the bundle with its parents linked, null if nothing is stored for the key or any of its parent locales
-