Save This Page
Home » org.apache.sling.launchpad.base-2.2.0-source-release » org.apache.sling.launchpad.base.shared » [javadoc | source]
org.apache.sling.launchpad.base.shared
public class: LauncherClassLoader [javadoc | source]
java.lang.Object
   java.lang.ClassLoader
      java.security.SecureClassLoader
         java.net.URLClassLoader
            org.apache.sling.launchpad.base.shared.LauncherClassLoader
The 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

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.
Fields inherited from java.net.URLClassLoader:
ucp
Fields inherited from java.lang.ClassLoader:
nocerts,  classAssertionStatus
Constructor:
 LauncherClassLoader(File launcherJar) throws MalformedURLException 
Method from org.apache.sling.launchpad.base.shared.LauncherClassLoader Summary:
getResource,   loadClass
Methods from java.net.URLClassLoader:
access$000,   access$100,   addURL,   definePackage,   findClass,   findResource,   findResources,   getPermissions,   getURLs,   newInstance,   newInstance
Methods from java.security.SecureClassLoader:
defineClass,   defineClass,   getPermissions
Methods from java.lang.ClassLoader:
access$000,   access$100,   addClass,   clearAssertionStatus,   defineClass,   defineClass,   defineClass,   defineClass,   definePackage,   desiredAssertionStatus,   findClass,   findLibrary,   findLoadedClass,   findNative,   findResource,   findResources,   findSystemClass,   getBootstrapClassPath,   getCallerClassLoader,   getPackage,   getPackages,   getParent,   getResource,   getResourceAsStream,   getResources,   getSystemClassLoader,   getSystemResource,   getSystemResourceAsStream,   getSystemResources,   isAncestor,   loadClass,   loadClass,   loadLibrary,   resolveClass,   setClassAssertionStatus,   setDefaultAssertionStatus,   setPackageAssertionStatus,   setSigners
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.sling.launchpad.base.shared.LauncherClassLoader Detail:
 public URL getResource(String name) 
    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.

 protected synchronized Class<?> loadClass(String name,
    boolean resolve) throws ClassNotFoundException 
    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.