Class WebAppClassLoader
- All Implemented Interfaces:
- Closeable, AutoCloseable, ClassVisibilityChecker
- Direct Known Subclasses:
- CachingWebAppClassLoader
Specializes URLClassLoader with some utility and file mapping methods.
This loader defaults to the 2.3 servlet spec behavior where non
system classes are loaded from the classpath in preference to the
parent loader.  Java2 compliant loading, where the parent loader
always has priority, can be selected with the
WebAppContext.setParentLoaderPriority(boolean)
method and influenced with WebAppContext.isHiddenClass(Class) and
WebAppContext.isProtectedClass(Class).
If no parent class loader is provided, then the current thread context classloader will be used. If that is null then the classloader that loaded this class is used as the parent.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceThe Context in which the classloader operates.
- 
Constructor SummaryConstructorsConstructorDescriptionWebAppClassLoader(ClassLoader parent, WebAppClassLoader.Context context) Constructor.Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddClassPath(String classPathList) voidaddClassPath(Resource resource) voidAdd elements to the class path for the context from the jar and zip files found in the specified resource.voidaddTransformer(ClassFileTransformer transformer) voidclose()protected Class<?> protected Class<?> foundClass(String name, URL url) getName()Get the name of the classloader.getResource(String name) Get a resource from the classloadergetResources(String name) booleanisHiddenClass(Class<?> clazz) Is the class a Hidden (Server) Class.booleanisProtectedClass(Class<?> clazz) Is the class a Protected (System) Class.protected Class<?> loadAsResource(String name, boolean checkSystemResource) Look for the classname as a resource to avoid loading a class that is potentially a system resource.protected Class<?> booleanremoveTransformer(ClassFileTransformer transformer) static <T> TRun an action with access to ServerClassesvoidSet the name of the classloader.toString()Methods inherited from class URLClassLoaderaddURL, definePackage, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class SecureClassLoaderdefineClass, defineClassMethods inherited from class ClassLoaderclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignersMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ClassVisibilityCheckerisServerClass, isSystemClass
- 
Constructor Details- 
WebAppClassLoaderConstructor.- Parameters:
- context- the context for this classloader
- Throws:
- IOException- if unable to initialize from context
 
- 
WebAppClassLoaderConstructor.- Parameters:
- parent- the parent classloader
- context- the context for this classloader
- Throws:
- IOException- if unable to initialize classloader
 
 
- 
- 
Method Details- 
runWithServerClassAccessRun an action with access to ServerClassesRun the passed PrivilegedExceptionActionwith the classloader configured so as to allow server classes to be visible- Type Parameters:
- T- the type of PrivilegedExceptionAction
- Parameters:
- action- The action to run
- Returns:
- The return from the action
- Throws:
- Exception- if thrown by the action
 
- 
getNameGet the name of the classloader.- Overrides:
- getNamein class- ClassLoader
- Returns:
- the name of the classloader
 
- 
setNameSet the name of the classloader.- Parameters:
- name- the name of the classloader
 
- 
getContext
- 
addClassPath- Parameters:
- resource- The resources to add to the classpath
 
- 
addClassPath- Parameters:
- classPathList- Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
- Throws:
- IOException- if unable to add classpath
 
- 
addJarsAdd elements to the class path for the context from the jar and zip files found in the specified resource.- Parameters:
- libs- the directory resource that contains the jar and/or zip files.
 
- 
getPermissions- Overrides:
- getPermissionsin class- URLClassLoader
 
- 
getResources- Overrides:
- getResourcesin class- ClassLoader
- Throws:
- IOException
 
- 
getResourceGet a resource from the classloaderNOTE: this method provides a convenience of hacking off a leading / should one be present. This is non-standard and it is recommended to not rely on this behavior - Overrides:
- getResourcein class- ClassLoader
 
- 
loadClass- Overrides:
- loadClassin class- ClassLoader
- Throws:
- ClassNotFoundException
 
- 
addTransformer
- 
removeTransformer
- 
loadAsResourceprotected Class<?> loadAsResource(String name, boolean checkSystemResource) throws ClassNotFoundException Look for the classname as a resource to avoid loading a class that is potentially a system resource.- Parameters:
- name- the name of the class to load
- checkSystemResource- if true and the class isn't a system class we return it
- Returns:
- the loaded class
- Throws:
- ClassNotFoundException- if the class cannot be found
 
- 
findClass- Overrides:
- findClassin class- URLClassLoader
- Throws:
- ClassNotFoundException
 
- 
foundClass- Throws:
- ClassNotFoundException
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- URLClassLoader
- Throws:
- IOException
 
- 
toString
- 
isProtectedClassDescription copied from interface:ClassVisibilityCheckerIs the class a Protected (System) Class. A System class is a class that is visible to a web application, but that cannot be overridden by the contents of WEB-INF/lib or WEB-INF/classes- Specified by:
- isProtectedClassin interface- ClassVisibilityChecker
- Parameters:
- clazz- The fully qualified name of the class.
- Returns:
- True if the class is a system class.
 
- 
isHiddenClassDescription copied from interface:ClassVisibilityCheckerIs the class a Hidden (Server) Class. A Server class is a class that is part of the implementation of the server and is NOT visible to a web application. The web application may provide its own implementation of the class, to be loaded from WEB-INF/lib or WEB-INF/classes- Specified by:
- isHiddenClassin interface- ClassVisibilityChecker
- Parameters:
- clazz- The fully qualified name of the class.
- Returns:
- True if the class is a server class.
 
 
-