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 DefaultBundleFactory.
  • 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:
      clearCache in interface org.tentackle.common.BundleFactory
      Overrides:
      clearCache in class org.tentackle.common.DefaultBundleFactory
    • findBundle

      public ResourceBundle findBundle(String baseName, Locale locale)
      Specified by:
      findBundle in interface org.tentackle.common.BundleFactory
      Overrides:
      findBundle in class org.tentackle.common.DefaultBundleFactory
    • findBundle

      public ResourceBundle findBundle(String baseName, Locale locale, ClassLoader loader)
      Specified by:
      findBundle in interface org.tentackle.common.BundleFactory
      Overrides:
      findBundle in class org.tentackle.common.DefaultBundleFactory
    • getBundle

      protected ResourceBundle getBundle(org.tentackle.common.BundleSupport support, Locale locale)
      Overrides:
      getBundle in class org.tentackle.common.DefaultBundleFactory
    • loadStoredBundleChain

      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 ResourceBundle does for its list of candidate locales. A stored Texts_de_DE, for example, gets a stored Texts as its parent if there is no Texts_de.

      Parameters:
      topKey - the key of the requested bundle
      loader - 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