Class BundleClassLoader

java.lang.Object
java.lang.ClassLoader
org.apache.xbean.osgi.bundle.util.BundleClassLoader
All Implemented Interfaces:
DelegatingBundleReference, org.osgi.framework.BundleReference
Direct Known Subclasses:
BundleResourceClassLoader

public class BundleClassLoader extends ClassLoader implements DelegatingBundleReference
Version:
$Rev: 1163514 $ $Date: 2011-08-31 09:37:38 +0200 (Wed, 31 Aug 2011) $
  • Field Details

    • bundle

      protected final org.osgi.framework.Bundle bundle
    • resourceHelper

      protected final BundleResourceHelper resourceHelper
  • Constructor Details

    • BundleClassLoader

      public BundleClassLoader(org.osgi.framework.Bundle bundle)
    • BundleClassLoader

      public BundleClassLoader(org.osgi.framework.Bundle bundle, boolean searchWiredBundles)
    • BundleClassLoader

      public BundleClassLoader(org.osgi.framework.Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      Overrides:
      loadClass in class ClassLoader
      Throws:
      ClassNotFoundException
    • getResource

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

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

      public Enumeration<URL> findResources(String name) throws IOException
      Overrides:
      findResources in class ClassLoader
      Throws:
      IOException
    • setSearchWiredBundles

      public void setSearchWiredBundles(boolean search)
    • getSearchWiredBundles

      public boolean getSearchWiredBundles()
    • setConvertResourceUrls

      public void setConvertResourceUrls(boolean convert)
    • getConvertResourceUrls

      public boolean getConvertResourceUrls()
    • getBundle

      public org.osgi.framework.Bundle getBundle(boolean unwrap)
      Return the bundle associated with this classloader. In most cases the bundle associated with the classloader is a regular framework bundle. However, in some cases the bundle associated with the classloader is a DelegatingBundle. In such cases, the unwrap parameter controls whether this function returns the DelegatingBundle instance or the main application bundle backing with the DelegatingBundle.
      Specified by:
      getBundle in interface DelegatingBundleReference
      Parameters:
      unwrap - If true and if the bundle associated with this classloader is a DelegatingBundle, this function will return the main application bundle backing with the DelegatingBundle. Otherwise, the bundle associated with this classloader is returned as is.
      Returns:
      The bundle associated with this classloader.
    • getBundle

      public org.osgi.framework.Bundle getBundle()
      Return the bundle associated with this classloader. This method calls getBundle(true) and therefore always returns a regular framework bundle.

      Note: Some libraries use BundleReference.getBundle() to obtain a bundle for the given classloader and expect the returned bundle instance to be work with any OSGi API. Some of these API might not work if DelegatingBundle is returned. That is why this function will always return a regular framework bundle. See getBundle(boolean) for more information.
      Specified by:
      getBundle in interface org.osgi.framework.BundleReference
      Returns:
      The bundle associated with this classloader.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object