Interface BundleClassLoaderHelper

All Known Implementing Classes:
DefaultBundleClassLoaderHelper

public interface BundleClassLoaderHelper
BundleClassLoaderHelper

Provides a ClassLoader for an OSGi Bundle.

The default implementation uses a specification-compliant approach that delegates to the standard OSGi Bundle API methods (Bundle.loadClass, Bundle.getResource, Bundle.getResources) instead of using reflection to access container-specific internal classloaders.

Custom implementations can be provided via OSGi fragments by implementing a class with the name specified by CLASS_NAME.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the custom implementation for this interface in a fragment.
    The default instance uses specification-compliant OSGi APIs
  • Method Summary

    Modifier and Type
    Method
    Description
    getBundleClassLoader(org.osgi.framework.Bundle bundle)
    Returns a ClassLoader for the given bundle that can be used to load classes and resources from the bundle.
  • Field Details

    • CLASS_NAME

      static final String CLASS_NAME
      The name of the custom implementation for this interface in a fragment.
      See Also:
    • DEFAULT

      static final BundleClassLoaderHelper DEFAULT
      The default instance uses specification-compliant OSGi APIs
  • Method Details

    • getBundleClassLoader

      ClassLoader getBundleClassLoader(org.osgi.framework.Bundle bundle)
      Returns a ClassLoader for the given bundle that can be used to load classes and resources from the bundle.
      Parameters:
      bundle - the bundle
      Returns:
      a ClassLoader for the bundle