Class DefaultBundleClassLoaderHelper

java.lang.Object
org.eclipse.jetty.osgi.util.DefaultBundleClassLoaderHelper
All Implemented Interfaces:
BundleClassLoaderHelper

public class DefaultBundleClassLoaderHelper extends Object implements BundleClassLoaderHelper
DefaultBundleClassLoaderHelper

Default implementation of the BundleClassLoaderHelper that uses only standard OSGi specification API methods to provide a ClassLoader for a bundle, avoiding the use of reflection or container-specific internal APIs.

This implementation returns a BundleDelegatingClassLoader that delegates class and resource loading to the bundle using the standard OSGi API methods (Bundle.loadClass, Bundle.getResource, Bundle.getResources). When the first class is loaded, it captures the real bundle classloader from the loaded class for subsequent operations.

  • Constructor Details

    • DefaultBundleClassLoaderHelper

      public DefaultBundleClassLoaderHelper()
  • Method Details

    • getBundleClassLoader

      public ClassLoader getBundleClassLoader(org.osgi.framework.Bundle bundle)
      Returns a ClassLoader for the given bundle using only specification-compliant OSGi APIs.
      Specified by:
      getBundleClassLoader in interface BundleClassLoaderHelper
      Parameters:
      bundle - the bundle
      Returns:
      a ClassLoader that delegates to the bundle's class and resource loading capabilities