Package org.eclipse.jetty.ee10.osgi.boot
Class OSGiWebappClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.eclipse.jetty.ee10.webapp.WebAppClassLoader
org.eclipse.jetty.ee10.osgi.boot.OSGiWebappClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClassVisibilityChecker
,org.osgi.framework.BundleReference
public class OSGiWebappClassLoader
extends WebAppClassLoader
implements org.osgi.framework.BundleReference
OSGiWebappClassLoader
Extends the webapp classloader to also use the classloader of the Bundle defining the webapp.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.ee10.webapp.WebAppClassLoader
WebAppClassLoader.Context
-
Constructor Summary
ConstructorDescriptionOSGiWebappClassLoader
(ClassLoader parent, WebAppContext context, org.osgi.framework.Bundle contributor) -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<?>
findResource
(String name) org.osgi.framework.Bundle
Returns theBundle
that defined this web-application.getResource
(String name) Get a resource from the classloader NOTE: this method provides a convenience of hacking off a leading / should one be present.getResources
(String name) protected Class<?>
loadAsResource
(String name, boolean checkSystemResource) Try to load the class from the bundle classloader.Methods inherited from class org.eclipse.jetty.ee10.webapp.WebAppClassLoader
addClassPath, addClassPath, addJars, addTransformer, close, foundClass, getContext, getName, getPermissions, isHiddenClass, isProtectedClass, loadClass, removeTransformer, runWithServerClassAccess, setName, toString
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResources, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, 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, setSigners
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.ClassVisibilityChecker
isServerClass, isSystemClass
-
Constructor Details
-
OSGiWebappClassLoader
public OSGiWebappClassLoader(ClassLoader parent, WebAppContext context, org.osgi.framework.Bundle contributor) throws IOException - Parameters:
parent
- The parent classloader.context
- The WebAppContextcontributor
- The bundle that defines this web-application.- Throws:
IOException
- if unable to cerate the OSGiWebappClassLoader
-
-
Method Details
-
findClass
- Overrides:
findClass
in classWebAppClassLoader
- Throws:
ClassNotFoundException
-
getBundle
public org.osgi.framework.Bundle getBundle()Returns theBundle
that defined this web-application.- Specified by:
getBundle
in interfaceorg.osgi.framework.BundleReference
- Returns:
- The
Bundle
object associated with thisBundleReference
.
-
getResources
- Overrides:
getResources
in classWebAppClassLoader
- Throws:
IOException
-
getResource
Description copied from class:WebAppClassLoader
Get a resource from the classloader NOTE: 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:
getResource
in classWebAppClassLoader
-
findResource
- Overrides:
findResource
in classURLClassLoader
-
loadAsResource
protected Class<?> loadAsResource(String name, boolean checkSystemResource) throws ClassNotFoundException Try to load the class from the bundle classloader. We do NOT load it as a resource as the WebAppClassLoader does because the url that is returned is an osgi-special url that does not play properly with WebAppClassLoader's method of extracting the class from the resource. This implementation directly asks the osgi bundle classloader to load the given class name.- Overrides:
loadAsResource
in classWebAppClassLoader
- Parameters:
name
- the name of the class to loadcheckSystemResource
- 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- See Also:
-