Class EquinoxBundleClassLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, DelegatingBundleReference, org.osgi.framework.BundleReference

    public class EquinoxBundleClassLoader
    extends java.net.URLClassLoader
    implements DelegatingBundleReference
    ClassLoader for a Bundle.
    This ClassLoader implementation extends the URLClassLoader and converts resource "bundle" URLs (found in directories or embedded jar files) into regular jar URLs. This ClassLoader implementation will only work on Equinox framework.
    Version:
    $Rev: 1163514 $ $Date: 2011-08-31 09:37:38 +0200 (Wed, 31 Aug 2011) $
    • Constructor Summary

      Constructors 
      Constructor Description
      EquinoxBundleClassLoader​(org.osgi.framework.Bundle bundle)  
      EquinoxBundleClassLoader​(org.osgi.framework.Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)  
      java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)  
      org.osgi.framework.Bundle getBundle()
      Return the bundle associated with this classloader.
      org.osgi.framework.Bundle getBundle​(boolean unwrap)
      Return the bundle associated with this classloader.
      boolean getConvertResourceUrls()  
      java.net.URL getResource​(java.lang.String name)  
      boolean getSearchWiredBundles()  
      int hashCode()  
      protected java.lang.Class<?> loadClass​(java.lang.String name, boolean resolve)  
      void setConvertResourceUrls​(boolean convert)  
      void setSearchWiredBundles​(boolean search)  
      java.lang.String toString()  
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, findResource, 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, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • EquinoxBundleClassLoader

        public EquinoxBundleClassLoader​(org.osgi.framework.Bundle bundle)
      • EquinoxBundleClassLoader

        public EquinoxBundleClassLoader​(org.osgi.framework.Bundle bundle,
                                        boolean searchWiredBundles,
                                        boolean convertResourceUrls)
    • Method Detail

      • toString

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

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

        public java.net.URL getResource​(java.lang.String name)
        Overrides:
        getResource in class java.lang.ClassLoader
      • findResources

        public java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)
                                                          throws java.io.IOException
        Overrides:
        findResources in class java.net.URLClassLoader
        Throws:
        java.io.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 java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object