【发布时间】:2012-06-16 04:01:39
【问题描述】:
我正在制作一个捆绑包以插入 OSGi 以为用户提供功能:
Usercase: User input the classname string and click "list" button, the corresponding class will be decompiled and show the text on GUI for user.
所以这是我的问题:我只有我的包的类加载器,我怎样才能获得 OSGi 容器类加载器,我可以从整个 OSGi 容器中按名称加载类? (我希望当 OSGi 启动时,它会将所有的 bundle 和所有的类加载到内存中,任何类都可以被 OSGi 容器类加载器加载,如果它确实存在并且能够加载)
有人知道怎么做这个工作吗?示例代码非常感谢。
【问题讨论】:
-
你可以使用java反射通过类名动态加载类。