Class DefaultBundleFactory

  • All Implemented Interfaces:
    BundleFactory

    public class DefaultBundleFactory
    extends java.lang.Object
    implements BundleFactory
    Default implementation of a bundle factory.

    Works for modular and non-modular applications.

    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultBundleFactory()
      Creates the bundle factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearCache()
      Clears the bundle cache.
      protected java.util.List<java.util.spi.ResourceBundleControlProvider> createProviders()
      Creates a list of providers.
      java.util.ResourceBundle findBundle​(java.lang.String baseName, java.util.Locale locale)
      Finds a resource bundle using the specified base name and locale, and the caller's class loader.
      java.util.ResourceBundle findBundle​(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader)
      Finds a resource bundle using the specified base name, locale, and class loader.
      protected java.util.ResourceBundle getBundle​(BundleSupport support, java.util.Locale locale)
      Gets the bundle from the corresponding module according to the bundle support.
      java.lang.ClassLoader getClassLoader()
      Gets the classloader to load the bundles.
      java.util.ResourceBundle.Control getControl​(java.lang.String baseName)
      Gets the control to load the bundle.
      java.util.List<java.util.spi.ResourceBundleControlProvider> getProviders()
      Gets the control providers.
      Method can be used to add a provider explicitly.
      protected java.lang.String normalizeBasename​(java.lang.String baseName)
      Normalizes the basename.
      The name is usually a dotted classname or a slashed resourcename without a leading slash.
      void setClassLoader​(java.lang.ClassLoader classLoader)
      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).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultBundleFactory

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

      • getClassLoader

        public java.lang.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
      • getProviders

        public final java.util.List<java.util.spi.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 java.util.ResourceBundle.Control getControl​(java.lang.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 java.util.ResourceBundle findBundle​(java.lang.String baseName,
                                                   java.util.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 java.util.ResourceBundle findBundle​(java.lang.String baseName,
                                                   java.util.Locale locale,
                                                   java.lang.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 java.util.ResourceBundle getBundle​(BundleSupport support,
                                                     java.util.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 java.util.List<java.util.spi.ResourceBundleControlProvider> createProviders()
        Creates a list of providers.
        Returns:
        the non-empty list of providers, null if no providers found
      • normalizeBasename

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