com.atlassian.plugin.osgi.util
Class BundleClassLoaderAccessor

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

public class BundleClassLoaderAccessor
extends java.lang.Object

Utility methods for accessing a bundle as if it was a classloader.

Since:
2.3.0

Constructor Summary
BundleClassLoaderAccessor()
           
 
Method Summary
static java.lang.ClassLoader getClassLoader(org.osgi.framework.Bundle bundle, AlternativeResourceLoader alternativeResourceLoader)
          Creates a classloader that delegates to the bundle
static
<T> java.lang.Class<T>
loadClass(org.osgi.framework.Bundle bundle, java.lang.String name)
          Loads a class from the bundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleClassLoaderAccessor

public BundleClassLoaderAccessor()
Method Detail

getClassLoader

public static java.lang.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> java.lang.Class<T> loadClass(org.osgi.framework.Bundle bundle,
                                               java.lang.String name)
                                    throws java.lang.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:
java.lang.ClassNotFoundException - If the class cannot be found in the bundle


Copyright © 2012 Atlassian. All Rights Reserved.