Class I18nClassLoader
ClassLoader for use with building ResourceBundle
s that uses an explicit search path for finding resources
for use with ResourceBundleControl
to control the order with which values from bundles over-write each other.
Maintains a list of class loaders and gives methods for adding new ones at various points to adjust precedence order. Precedence is based on list order where list item 0 is highest to list item n lowest.
Also adds a new getResourcesByPrecedence(String)
method to allow the control file to create a
MergedPropertiesResourceBundle
with application-defined precedence. This allows us to make sure that things
like default message can be replaced and redefined by plugins and then again by explicit i18n folders on the user's
installed system.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(Object owner, ClassLoader loader) Inserts a class loader at the end of the list(lowest precedence).protected Class<?>
getResource
(String name) getResources
(String name) boolean
insertAfter
(Object owner, ClassLoader loader, BiPredicate<Object, ClassLoader> searchMethod) boolean
insertBefore
(Object owner, ClassLoader loader, BiPredicate<Object, ClassLoader> searchMethod) Inserts a class loader pair before the pair matched by searchMethod.void
unshift
(Object owner, ClassLoader loader) Inserts a class loader at the head of the list(highest precedence).Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
I18nClassLoader
public I18nClassLoader()
-
-
Method Details
-
append
Inserts a class loader at the end of the list(lowest precedence).
- Parameters:
owner
-loader
-
-
unshift
Inserts a class loader at the head of the list(highest precedence).
- Parameters:
owner
-loader
-
-
insertBefore
public boolean insertBefore(Object owner, ClassLoader loader, BiPredicate<Object, ClassLoader> searchMethod) Inserts a class loader pair before the pair matched by searchMethod.
If searchMethod does not match any existing class loader pairs then no class loader is inserted and this method returns false.
- Parameters:
owner
-loader
-searchMethod
- to match pair to insert before- Returns:
- true is class loader pair was added, false otherwise.
-
insertAfter
public boolean insertAfter(Object owner, ClassLoader loader, BiPredicate<Object, ClassLoader> searchMethod) -
findClass
- Overrides:
findClass
in classClassLoader
- Throws:
ClassNotFoundException
-
getResource
- Overrides:
getResource
in classClassLoader
-
getResourcesByPrecedence
-
getResources
- Overrides:
getResources
in classClassLoader
- Throws:
IOException
-