Package com.atlassian.plugin.osgi.util
Class BundleClassLoaderAccessor
java.lang.Object
com.atlassian.plugin.osgi.util.BundleClassLoaderAccessor
Utility methods for accessing a bundle as if it was a classloader.
- Since:
- 2.3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassLoadergetClassLoader(org.osgi.framework.Bundle bundle, AlternativeResourceLoader alternativeResourceLoader) Creates a classloader that delegates to the bundlestatic <T> Class<T>Loads a class from the bundle
-
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 toalternativeResourceLoader- 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 bundlename- The name of the class to load- Returns:
- The class instance
- Throws:
ClassNotFoundException- If the class cannot be found in the bundle
-