Class PlatformResourceBundleLocator

java.lang.Object
org.hibernate.validator.resourceloading.PlatformResourceBundleLocator
All Implemented Interfaces:
ResourceBundleLocator

public class PlatformResourceBundleLocator extends Object implements ResourceBundleLocator
A resource bundle locator, that loads resource bundles by invoking ResourceBundle.loadBundle(String, Local, ClassLoader).

This locator is also able to load all property files of a given name (in case there are multiple with the same name on the classpath) and aggregates them into a ResourceBundle.

Author:
Hardy Ferentschik, Gunnar Morling, Guillaume Smet
  • Constructor Details

    • PlatformResourceBundleLocator

      public PlatformResourceBundleLocator(String bundleName)
      Parameters:
      bundleName - the name of the bundle to load
    • PlatformResourceBundleLocator

      public PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader)
      Parameters:
      bundleName - the name of the bundle to load
      classLoader - the classloader to be used for loading the bundle. If null, the current thread context classloader and finally Hibernate Validator's own classloader will be used for loading the specified bundle.
      Since:
      5.2
    • PlatformResourceBundleLocator

      public PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader, boolean aggregate)
      Parameters:
      bundleName - the name of the bundle to load
      classLoader - the classloader to be used for loading the bundle. If null, the current thread context classloader and finally Hibernate Validator's own classloader will be used for loading the specified bundle.
      aggregate - Whether or not all resource bundles of a given name should be loaded and potentially merged.
      Since:
      5.2
    • PlatformResourceBundleLocator

      @Incubating public PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize)
      Parameters:
      bundleName - the name of the bundle to load
      localesToInitialize - the set of locales to initialize at bootstrap
      Since:
      6.1.1
    • PlatformResourceBundleLocator

      @Incubating public PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize, ClassLoader classLoader)
      Parameters:
      bundleName - the name of the bundle to load
      localesToInitialize - the set of locales to initialize at bootstrap
      classLoader - the classloader to be used for loading the bundle. If null, the current thread context classloader and finally Hibernate Validator's own classloader will be used for loading the specified bundle.
      Since:
      6.1.1
    • PlatformResourceBundleLocator

      @Incubating public PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize, ClassLoader classLoader, boolean aggregate)
      Parameters:
      bundleName - the name of the bundle to load
      localesToInitialize - the set of locales to initialize at bootstrap
      classLoader - the classloader to be used for loading the bundle. If null, the current thread context classloader and finally Hibernate Validator's own classloader will be used for loading the specified bundle.
      aggregate - Whether or not all resource bundles of a given name should be loaded and potentially merged.
      Since:
      6.1
  • Method Details

    • getResourceBundle

      public ResourceBundle getResourceBundle(Locale locale)
      Search current thread classloader for the resource bundle. If not found, search validator (this) classloader.
      Specified by:
      getResourceBundle in interface ResourceBundleLocator
      Parameters:
      locale - The locale of the bundle to load.
      Returns:
      the resource bundle or null if none is found.