Class DefaultBundleFactory

java.lang.Object
org.tentackle.common.DefaultBundleFactory
All Implemented Interfaces:
BundleFactory

@Service(BundleFactory.class) public class DefaultBundleFactory extends Object implements BundleFactory
Default implementation of a bundle factory.

Works for modular and non-modular applications.

Author:
harald
  • Constructor Details

    • DefaultBundleFactory

      public DefaultBundleFactory()
      Creates the bundle factory.
  • Method Details

    • clearCache

      public void clearCache()
      Description copied from interface: BundleFactory
      Clears the bundle cache.
      Specified by:
      clearCache in interface BundleFactory
    • getClassLoader

      public ClassLoader getClassLoader()
      Description copied from interface: BundleFactory
      Gets the classloader to load the bundles.
      Specified by:
      getClassLoader in interface BundleFactory
      Returns:
      the classloader, null if default
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Description copied from interface: BundleFactory
      Sets the classloader to load the bundles.
      If set, this classloader will be used for BundleFactory.getBundle(java.lang.String) and BundleFactory.getBundle(java.lang.String, java.util.Locale).
      Specified by:
      setClassLoader in interface BundleFactory
      Parameters:
      classLoader - the classloader, null if default
    • getProviders

      public final List<ResourceBundleControlProvider> getProviders()
      Description copied from interface: BundleFactory
      Gets the control providers.
      Method can be used to add a provider explicitly.
      Specified by:
      getProviders in interface BundleFactory
      Returns:
      the non-empty list of providers or null, if no providers found
    • getControl

      public ResourceBundle.Control getControl(String baseName)
      Description copied from interface: BundleFactory
      Gets the control to load the bundle.
      Specified by:
      getControl in interface BundleFactory
      Parameters:
      baseName - the bundle basename
      Returns:
      the control, null if delegate to ResourceBundle's default
    • findBundle

      public ResourceBundle findBundle(String baseName, Locale locale)
      Description copied from interface: BundleFactory
      Finds a resource bundle using the specified base name and locale, and the caller's class loader.
      Specified by:
      findBundle in interface BundleFactory
      Parameters:
      baseName - the base name of the resource bundle, a fully qualified class name
      locale - the locale for which a resource bundle is desired
      Returns:
      a resource bundle for the given base name and locale
    • findBundle

      public ResourceBundle findBundle(String baseName, Locale locale, ClassLoader loader)
      Description copied from interface: BundleFactory
      Finds a resource bundle using the specified base name, locale, and class loader.
      Specified by:
      findBundle in interface BundleFactory
      Parameters:
      baseName - the base name of the resource bundle, a fully qualified class name
      locale - the locale for which a resource bundle is desired
      loader - the class loader from which to load the resource bundle
      Returns:
      a resource bundle for the given base name and locale
    • getBundle

      protected ResourceBundle getBundle(BundleSupport support, Locale locale)
      Gets the bundle from the corresponding module according to the bundle support.
      Parameters:
      support - the bundle support
      locale - the locale
      Returns:
      the bundle
    • createProviders

      protected List<ResourceBundleControlProvider> createProviders()
      Creates a list of providers.
      Returns:
      the non-empty list of providers, null if no providers found
    • normalizeBasename

      protected String normalizeBasename(String baseName)
      Normalizes the basename.
      The name is usually a dotted classname or a slashed resource name without a leading slash.
      Parameters:
      baseName - the name
      Returns:
      the normalized name