Class PlatformResourceBundleLocator
java.lang.Object
org.hibernate.validator.resourceloading.PlatformResourceBundleLocator
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionPlatformResourceBundleLocator(String bundleName) Creates a newPlatformResourceBundleLocator.PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader) Creates a newPlatformResourceBundleLocator.PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader, boolean aggregate) Creates a newPlatformResourceBundleLocator.PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize) Creates a newPlatformResourceBundleLocator.PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize, ClassLoader classLoader) Creates a newPlatformResourceBundleLocator.PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize, ClassLoader classLoader, boolean aggregate) Creates a newPlatformResourceBundleLocator. -
Method Summary
Modifier and TypeMethodDescriptiongetResourceBundle(Locale locale) Search current thread classloader for the resource bundle.
-
Constructor Details
-
PlatformResourceBundleLocator
Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to load
-
PlatformResourceBundleLocator
Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to loadclassLoader- the classloader to be used for loading the bundle. Ifnull, the current thread context classloader and finally Hibernate Validator's own classloader will be used for loading the specified bundle.- Since:
- 5.2
-
PlatformResourceBundleLocator
Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to loadclassLoader- the classloader to be used for loading the bundle. Ifnull, 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) Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to loadlocalesToInitialize- the set of locales to initialize at bootstrap- Since:
- 6.1.1
-
PlatformResourceBundleLocator
@Incubating public PlatformResourceBundleLocator(String bundleName, Set<Locale> localesToInitialize, ClassLoader classLoader) Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to loadlocalesToInitialize- the set of locales to initialize at bootstrapclassLoader- the classloader to be used for loading the bundle. Ifnull, 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) Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to loadlocalesToInitialize- the set of locales to initialize at bootstrapclassLoader- the classloader to be used for loading the bundle. Ifnull, 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
Search current thread classloader for the resource bundle. If not found, search validator (this) classloader.- Specified by:
getResourceBundlein interfaceResourceBundleLocator- Parameters:
locale- The locale of the bundle to load.- Returns:
- the resource bundle or
nullif none is found.
-