Package org.apache.openjpa.lib.util
Class MultiClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- org.apache.openjpa.lib.util.MultiClassLoader
-
public class MultiClassLoader extends java.lang.ClassLoaderClass loader type that can be configured to delegate to multiple internal class loaders. TheTHREAD_LOADERconstant is a marker that will be replaced with the context loader of the current thread.- Author:
- Abe White
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ClassLoaderSYSTEM_LOADERThe standard system class loader.static java.lang.ClassLoaderTHREAD_LOADERMarker that will be replaced with the context loader of the current thread whenever it is discovered in the class loader list.
-
Constructor Summary
Constructors Constructor Description MultiClassLoader()Constructor; initializes the loader with an empty list of delegates.MultiClassLoader(java.lang.ClassLoader... loaders)MultiClassLoader(MultiClassLoader other)Construct with the class loaders of another multi loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddClassLoader(int index, java.lang.ClassLoader loader)Add the given class loader at the specified index.booleanaddClassLoader(java.lang.ClassLoader loader)Add the given class loader to the set of loaders that will be tried.booleanaddClassLoaders(int index, MultiClassLoader multi)Adds all class loaders from the given multi loader starting at the given index.booleanaddClassLoaders(MultiClassLoader multi)Adds all the class loaders from the given multi loader.voidclear()Clear the list of class loaders.booleancontainsClassLoader(java.lang.ClassLoader loader)Returns true if the list contains the given class loader or marker.booleanequals(java.lang.Object other)protected java.lang.Class<?>findClass(java.lang.String name)protected java.net.URLfindResource(java.lang.String name)protected java.util.Enumeration<java.net.URL>findResources(java.lang.String name)java.lang.ClassLoadergetClassLoader(int index)Return the class loader at the given index.java.lang.ClassLoader[]getClassLoaders()Return an array of all contained class loaders.inthashCode()booleanisEmpty()Return true if there are no internal class laoders.booleanremoveClassLoader(java.lang.ClassLoader loader)Remove the given loader from the list.voidsetClassLoaders(MultiClassLoader multi)Set the class loaders of this loader to those of the given loader.intsize()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 Detail
-
THREAD_LOADER
public static final java.lang.ClassLoader 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
public static final java.lang.ClassLoader SYSTEM_LOADER
The standard system class loader.
-
-
Constructor Detail
-
MultiClassLoader
public MultiClassLoader()
Constructor; initializes the loader with an empty list of delegates.
-
MultiClassLoader
public MultiClassLoader(MultiClassLoader other)
Construct with the class loaders of another multi loader.
-
MultiClassLoader
public MultiClassLoader(java.lang.ClassLoader... loaders)
-
-
Method Detail
-
containsClassLoader
public boolean containsClassLoader(java.lang.ClassLoader loader)
Returns true if the list contains the given class loader or marker.
-
getClassLoaders
public java.lang.ClassLoader[] getClassLoaders()
Return an array of all contained class loaders.
-
getClassLoader
public java.lang.ClassLoader getClassLoader(int index)
Return the class loader at the given index.
-
addClassLoader
public boolean addClassLoader(java.lang.ClassLoader loader)
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
public boolean addClassLoader(int index, java.lang.ClassLoader loader)Add the given class loader at the specified index.- Returns:
- true if the loader was added, false if already in the list
-
setClassLoaders
public void setClassLoaders(MultiClassLoader multi)
Set the class loaders of this loader to those of the given loader.
-
addClassLoaders
public boolean addClassLoaders(int index, MultiClassLoader multi)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
public boolean addClassLoaders(MultiClassLoader multi)
Adds all the class loaders from the given multi loader.- Returns:
- true if any loaders were added, false if all already in list
-
removeClassLoader
public boolean removeClassLoader(java.lang.ClassLoader loader)
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
protected java.lang.Class<?> findClass(java.lang.String name) throws java.lang.ClassNotFoundException- Overrides:
findClassin classjava.lang.ClassLoader- Throws:
java.lang.ClassNotFoundException
-
findResource
protected java.net.URL findResource(java.lang.String name)
- Overrides:
findResourcein classjava.lang.ClassLoader
-
findResources
protected java.util.Enumeration<java.net.URL> findResources(java.lang.String name) throws java.io.IOException- Overrides:
findResourcesin classjava.lang.ClassLoader- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-