01 2013 档案
一种获取OSGi任意Bundle的ClassLoader的方法
摘要:在OSGi环境中,在Bundle内部代码中要得到自己Bundle的ClassLoader就很简单,在自己Bundle的代码中,直接写this.getClass().getClassLoader()就得到了自己Bundle的ClassLoader了。但怎么在其他Bundle或外部代码中得到任意一个Bundle的ClassLoader呢?Bundle和BundleContext都没有提供getClassLoader方法来获取,我就用了一种比较另类的方法来获取。突破口就在Bundle.loadClass(String className)方法,目前此方法已经在QuickWebFramework中应用了。
阅读全文
浙公网安备 33010602011771号