Class LauncherClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
LauncherClassLoader
extends the standard Java VM
URLClassLoader
such, that classes and resources which are
contained in the launcher JAR File are never looked up in the parent class
loader.
This class loader shields the Sling OSGi framework completely from the environment because
- Classes and resources contained in packages provided by the launcher JAR file are only looked up in the launcher JAR file
- Classes and resources from the environment are only used from within the
framework if the framework is configured to do so by the
org.osgi.framework.bootdelegation
ororg.osgi.framework.systempackages
framework properties.
The first point is important if Sling is deployed into any container, which provides some or all of the same packages as the Sling launcher JAR file. One such example is the Glassfish v3 Prelude application service, which itself runs in a Felix OSGi framework and sort of leaks the classes into the web application.
In the general case, we cannot prevent any leaking of classes, which may also be the OSGi core or compendium libraries, into Sling. So, this class loader is the barrier for this leaking and shields Sling from the environment unless explicitly configured to use this leaking.
Instances of this class loader are setup with the launcher JAR file as the
only contents of the URLClassLoaders
class path and the class
loader of this class itself as the parent class loader.
-
Method Summary
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, 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, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Method Details
-
loadClass
Load the name class and optionally resolve it, if found.This method checks whether the package of the class is contained in the launcher JAR file. If so, the launcher JAR file is looked up for the class and class loading fails if not found. Otherwise the standard class loading strategy is applied by calling the base class implementation.
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
getResource
Return an URL to the requested resource.This method checks whether the package of the resource is contained in the launcher JAR file. If so, the launcher JAR file is looked up for the resource and resource access fails if not found. Otherwise the standard resource access strategy is applied by calling the base class implementation.
- Overrides:
getResource
in classClassLoader
-