Package org.apache.openjpa.lib.util
Class MultiClassLoader
java.lang.Object
java.lang.ClassLoader
org.apache.openjpa.lib.util.MultiClassLoader
Class loader type that can be configured to delegate to multiple
internal class loaders.
The
THREAD_LOADER
constant is a marker that will be replaced
with the context loader of the current thread.- Author:
- Abe White
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ClassLoader
The standard system class loader.static final ClassLoader
Marker that will be replaced with the context loader of the current thread whenever it is discovered in the class loader list. -
Constructor Summary
ConstructorDescriptionConstructor; initializes the loader with an empty list of delegates.MultiClassLoader
(ClassLoader... loaders) MultiClassLoader
(MultiClassLoader other) Construct with the class loaders of another multi loader. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addClassLoader
(int index, ClassLoader loader) Add the given class loader at the specified index.boolean
addClassLoader
(ClassLoader loader) Add the given class loader to the set of loaders that will be tried.boolean
addClassLoaders
(int index, MultiClassLoader multi) Adds all class loaders from the given multi loader starting at the given index.boolean
addClassLoaders
(MultiClassLoader multi) Adds all the class loaders from the given multi loader.void
clear()
Clear the list of class loaders.boolean
containsClassLoader
(ClassLoader loader) Returns true if the list contains the given class loader or marker.boolean
protected Class<?>
protected URL
findResource
(String name) protected Enumeration<URL>
findResources
(String name) getClassLoader
(int index) Return the class loader at the given index.Return an array of all contained class loaders.int
hashCode()
boolean
isEmpty()
Return true if there are no internal class laoders.boolean
removeClassLoader
(ClassLoader loader) Remove the given loader from the list.void
setClassLoaders
(MultiClassLoader multi) Set the class loaders of this loader to those of the given loader.int
size()
Return the number of internal class loaders.Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
THREAD_LOADER
Marker that will be replaced with the context loader of the current thread whenever it is discovered in the class loader list. -
SYSTEM_LOADER
The standard system class loader.
-
-
Constructor Details
-
MultiClassLoader
public MultiClassLoader()Constructor; initializes the loader with an empty list of delegates. -
MultiClassLoader
Construct with the class loaders of another multi loader. -
MultiClassLoader
-
-
Method Details
-
containsClassLoader
Returns true if the list contains the given class loader or marker. -
getClassLoaders
Return an array of all contained class loaders. -
getClassLoader
Return the class loader at the given index. -
addClassLoader
Add the given class loader to the set of loaders that will be tried.- Returns:
- true if the loader was added, false if already in the list
-
addClassLoader
Add the given class loader at the specified index.- Returns:
- true if the loader was added, false if already in the list
-
setClassLoaders
Set the class loaders of this loader to those of the given loader. -
addClassLoaders
Adds all class loaders from the given multi loader starting at the given index.- Returns:
- true if any loaders were added, false if all already in list
-
addClassLoaders
Adds all the class loaders from the given multi loader.- Returns:
- true if any loaders were added, false if all already in list
-
removeClassLoader
Remove the given loader from the list.- Returns:
- true if removed, false if not in list
-
clear
public void clear()Clear the list of class loaders. -
size
public int size()Return the number of internal class loaders. -
isEmpty
public boolean isEmpty()Return true if there are no internal class laoders. -
findClass
- Overrides:
findClass
in classClassLoader
- Throws:
ClassNotFoundException
-
findResource
- Overrides:
findResource
in classClassLoader
-
findResources
- Overrides:
findResources
in classClassLoader
- Throws:
IOException
-
equals
-
hashCode
public int hashCode()
-