Class BundleResourceLoader

  • All Implemented Interfaces:
    ResourceLoader

    public class BundleResourceLoader
    extends Object
    implements ResourceLoader

    A specialized implementation of the ResourceLoader interface that make use of the default Java resource bundles.

    This class uses the passed in Locale and resource group name (which is interpreted as string) to find a corresponding resource bundle. For this bundle a wrapping object is returned that implements the ResourceGroup interface.

    When creating an instance a ClassLoaderProvider and a class loader name can be provided. If set, the resource bundle is loaded using the class loader specified this way.

    Version:
    $Id: BundleResourceLoader.java 211 2012-07-10 19:49:13Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • BundleResourceLoader

        public BundleResourceLoader()
        Creates a new instance of BundleResourceLoader without a special ClassLoaderProvider; a default one is created.
      • BundleResourceLoader

        public BundleResourceLoader​(ClassLoaderProvider clp,
                                    String clName)
        Creates a new instance of BundleResourceLoader and initializes it with the given class loader provider and the class loader name.
        Parameters:
        clp - the ClassLoaderProvider; can be null, then a default instance is created
        clName - the name of the class loader to use; can be null, then the default class loader of the ClassLoaderProvider is used
        Since:
        1.2
    • Method Detail

      • getClassLoaderProvider

        public ClassLoaderProvider getClassLoaderProvider()
        Returns the ClassLoaderProvider used by this object. Note: This method never returns null; if no class loader provider was passed to the constructor, a default instance is returned.
        Returns:
        the ClassLoaderProvider
        Since:
        1.2
      • getClassLoaderName

        public String getClassLoaderName()
        Returns the name of the class loader used for resolving resource bundles.
        Returns:
        the class loader name (may be null)
        Since:
        1.2
      • keyForGroup

        protected String keyForGroup​(Locale locale,
                                     Object name)
        Constructs a key for the given combination of a locale and a group name. This key is used for storing a group in the cache after it was created.
        Parameters:
        locale - the locale
        name - the group's name
        Returns:
        a key for this group