Class BundleClassLoaderAccessor

java.lang.Object
com.atlassian.plugin.osgi.util.BundleClassLoaderAccessor

public class BundleClassLoaderAccessor extends Object
Utility methods for accessing a bundle as if it was a classloader.
Since:
2.3.0
  • Constructor Details

    • BundleClassLoaderAccessor

      public BundleClassLoaderAccessor()
  • Method Details

    • getClassLoader

      public static ClassLoader getClassLoader(org.osgi.framework.Bundle bundle, AlternativeResourceLoader alternativeResourceLoader)
      Creates a classloader that delegates to the bundle
      Parameters:
      bundle - The bundle to delegate to
      alternativeResourceLoader - An alternative resource loader to bypass bundle, can be null
      Returns:
      A new classloader instance
    • loadClass

      public static <T> Class<T> loadClass(org.osgi.framework.Bundle bundle, String name) throws ClassNotFoundException
      Loads a class from the bundle
      Type Parameters:
      T - The type of the class
      Parameters:
      bundle - The bundle
      name - The name of the class to load
      Returns:
      The class instance
      Throws:
      ClassNotFoundException - If the class cannot be found in the bundle