Class JRubyOSGiBundleClassLoader

java.lang.Object
java.lang.ClassLoader
org.jruby.embed.osgi.internal.JRubyOSGiBundleClassLoader
All Implemented Interfaces:
org.osgi.framework.BundleReference

public class JRubyOSGiBundleClassLoader extends ClassLoader implements org.osgi.framework.BundleReference
Closest thing to JRubyClassLoader's addURL but for OSGi bundles. Used as the parent classloader the usual jruby's bundle's classloader.
  • Field Details

    • LOG

      private static final Logger LOG
    • ADAPTER

      private static final IOSGiClassLoaderAdapter ADAPTER
    • _lookInOsgiFirst

      private final boolean _lookInOsgiFirst
      look in OSGi first? true by default for now. we could look in jruby first if that makes more sense.
      See Also:
    • _libraries

      private LinkedHashMap<org.osgi.framework.Bundle,ClassLoader> _libraries
  • Constructor Details

    • JRubyOSGiBundleClassLoader

      public JRubyOSGiBundleClassLoader()
      Throws:
      IOException
    • JRubyOSGiBundleClassLoader

      public JRubyOSGiBundleClassLoader(org.osgi.framework.Bundle creator)
      Throws:
      IOException
  • Method Details

    • addBundle

      public void addBundle(Class<?> classInOsgiBundle)
      Throws:
      IOException
    • addBundle

      public boolean addBundle(org.osgi.framework.Bundle bundle)
      Parameters:
      parent - The parent classloader. In this case jrubyLoader
      context - The WebAppContext
      contributor - The bundle that defines this web-application.
      Throws:
      IOException
    • removeBundle

      public boolean removeBundle(org.osgi.framework.Bundle bundle) throws IOException
      Parameters:
      parent - The parent classloader. In this case jrubyLoader
      context - The WebAppContext
      contributor - The bundle that defines this web-application.
      Throws:
      IOException
    • 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
      TODO: optimize: we should not have to look for the resources everywhere until called for it.
      Overrides:
      getResources in class ClassLoader
      Throws:
      IOException
    • getResource

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

      private List<URL> toList(List<Enumeration<URL>> l)
    • findClass

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