org.springframework.osgi.util
Class BundleDelegatingClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.springframework.osgi.util.BundleDelegatingClassLoader

public class BundleDelegatingClassLoader
extends ClassLoader

ClassLoader backed by an OSGi bundle. Provides the ability to use a separate class loader as fall back. Contains facilities for tracing class loading behaviour so that issues can be easily resolved. For debugging please see DebugUtils.

Author:
Adrian Colyer, Andy Piper, Costin Leau

Method Summary
static BundleDelegatingClassLoader createBundleClassLoaderFor(Bundle aBundle)
          Factory method for creating a class loader over the given bundle.
static BundleDelegatingClassLoader createBundleClassLoaderFor(Bundle bundle, ClassLoader bridge)
          Factory method for creating a class loader over the given bundle and with a given class loader as fall-back.
protected  Class findClass(String name)
           
protected  URL findResource(String name)
           
protected  Enumeration findResources(String name)
           
 URL getResource(String name)
           
protected  Class loadClass(String name, boolean resolve)
           
 String toString()
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createBundleClassLoaderFor

public static BundleDelegatingClassLoader createBundleClassLoaderFor(Bundle aBundle)
Factory method for creating a class loader over the given bundle.

Parameters:
aBundle - bundle to use for class loading and resource acquisition
Returns:
class loader adapter over the given bundle

createBundleClassLoaderFor

public static BundleDelegatingClassLoader createBundleClassLoaderFor(Bundle bundle,
                                                                     ClassLoader bridge)
Factory method for creating a class loader over the given bundle and with a given class loader as fall-back. In case the bundle cannot find a class or locate a resource, the given class loader will be used as fall back.

Parameters:
bundle - bundle used for class loading and resource acquisition
bridge - class loader used as fall back in case the bundle cannot load a class or find a resource. Can be null
Returns:
class loader adapter over the given bundle and class loader

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Overrides:
findClass in class ClassLoader
Throws:
ClassNotFoundException

findResource

protected URL findResource(String name)
Overrides:
findResource in class ClassLoader

findResources

protected Enumeration findResources(String name)
                             throws IOException
Overrides:
findResources in class ClassLoader
Throws:
IOException

getResource

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

loadClass

protected Class loadClass(String name,
                          boolean resolve)
                   throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2008 Spring Framework. All Rights Reserved.