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 invokingResourceBundle.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
Constructors Constructor Description PlatformResourceBundleLocator(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceBundlegetResourceBundle(Locale locale)Search current thread classloader for the resource bundle.
-
-
-
Constructor Detail
-
PlatformResourceBundleLocator
public PlatformResourceBundleLocator(String bundleName)
Creates a newPlatformResourceBundleLocator.- Parameters:
bundleName- the name of the bundle to load
-
PlatformResourceBundleLocator
public PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader)
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
public PlatformResourceBundleLocator(String bundleName, ClassLoader classLoader, boolean aggregate)
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 Detail
-
getResourceBundle
public ResourceBundle getResourceBundle(Locale locale)
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.
-
-