org.eclipse.jetty.osgi.boot.internal.webapp
Class OSGiWebappClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.eclipse.jetty.webapp.WebAppClassLoader
                  extended by org.eclipse.jetty.osgi.boot.internal.webapp.OSGiWebappClassLoader
All Implemented Interfaces:
org.osgi.framework.BundleReference

public class OSGiWebappClassLoader
extends WebAppClassLoader
implements org.osgi.framework.BundleReference

Extends the webappclassloader to insert the classloader provided by the osgi bundle at the same level than any other jars palced in the webappclassloader.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.webapp.WebAppClassLoader
WebAppClassLoader.Context
 
Field Summary
static Set<String> JAR_WITH_SUCH_CLASS_MUST_BE_EXCLUDED
          when a logging framework is setup in the osgi classloaders, it can access this and register the classes that must not be found in the jar.
 
Constructor Summary
OSGiWebappClassLoader(ClassLoader parent, WebAppContext context, org.osgi.framework.Bundle contributor, BundleClassLoaderHelper bundleClassLoaderHelper)
           
 
Method Summary
 void addClassPath(String classPath)
          Parse the classpath ourselves to be able to filter things.
static void addClassThatIdentifiesAJarThatMustBeRejected(Class<?> zclass)
           
static void addClassThatIdentifiesAJarThatMustBeRejected(String zclassName)
           
protected  Class<?> findClass(String name)
           
 org.osgi.framework.Bundle getBundle()
          Returns the Bundle that defined this web-application.
 URL getResource(String name)
           
 Enumeration<URL> getResources(String name)
           
 void setWebappContext(WebAppContext webappContext)
          In the case of the generation of a webapp via a jetty context file we need a proper classloader to setup the app before we have the WebappContext So we place a fake one there to start with.
 
Methods inherited from class org.eclipse.jetty.webapp.WebAppClassLoader
addClassPath, addJars, getContext, getName, getPermissions, loadClass, loadClass, setName, toString
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, 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, getPackage, getPackages, getParent, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JAR_WITH_SUCH_CLASS_MUST_BE_EXCLUDED

public static Set<String> JAR_WITH_SUCH_CLASS_MUST_BE_EXCLUDED
when a logging framework is setup in the osgi classloaders, it can access this and register the classes that must not be found in the jar.

Constructor Detail

OSGiWebappClassLoader

public OSGiWebappClassLoader(ClassLoader parent,
                             WebAppContext context,
                             org.osgi.framework.Bundle contributor,
                             BundleClassLoaderHelper bundleClassLoaderHelper)
                      throws IOException
Parameters:
parent - The parent classloader. In this case
context - The WebAppContext
contributor - The bundle that defines this web-application.
Throws:
IOException
Method Detail

addClassThatIdentifiesAJarThatMustBeRejected

public static void addClassThatIdentifiesAJarThatMustBeRejected(Class<?> zclass)

addClassThatIdentifiesAJarThatMustBeRejected

public static void addClassThatIdentifiesAJarThatMustBeRejected(String zclassName)

getBundle

public org.osgi.framework.Bundle getBundle()
Returns the Bundle that defined this web-application.

Specified by:
getBundle in interface org.osgi.framework.BundleReference
Returns:
The Bundle object associated with this BundleReference.

getResources

public Enumeration<URL> getResources(String name)
                              throws IOException
Overrides:
getResources in class WebAppClassLoader
Throws:
IOException

getResource

public URL getResource(String name)
Overrides:
getResource in class WebAppClassLoader

findClass

protected Class<?> findClass(String name)
                      throws ClassNotFoundException
Overrides:
findClass in class URLClassLoader
Throws:
ClassNotFoundException

addClassPath

public void addClassPath(String classPath)
                  throws IOException
Parse the classpath ourselves to be able to filter things. This is a derivative work of the super class

Overrides:
addClassPath in class WebAppClassLoader
Parameters:
classPath - Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
Throws:
IOException

setWebappContext

public void setWebappContext(WebAppContext webappContext)
In the case of the generation of a webapp via a jetty context file we need a proper classloader to setup the app before we have the WebappContext So we place a fake one there to start with. We replace it with the actual webapp context with this method. We also apply the extraclasspath there at the same time.



Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.