如何获得一个分组中的类加载器? [英] How to get classloader for a bundle in equinox?

查看:118
本文介绍了如何获得一个分组中的类加载器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多等分的代码,但是仍然无法弄清楚在eclipse equinox安装程序中获取osgi包的类加载器的非黑客方法。有没有一个?

I have read a lot of equinox code for this, but still can't figure out a non-hacky way of getting the classloader for a osgi bundle in eclipse equinox setup. Is there one?

推荐答案

简短的答案(当然对于OSGi 4.1,不确定4.2) bundle的类加载器。但是, Bundle 接口暴露了一个 loadClass() 方法,这将允许您编写一个包装软件包API和代理的类加载器到 loadClass()方法。或者你可以节省一些时间,并使用Spring DM的 BundleDelegatingClassLoader class。

The short answer (certainly for OSGi 4.1, not sure of 4.2) is you can't get a bundle's classloader. However the Bundle interface exposes a loadClass() method and this would allow you to write a classloader that wraps the bundle API and delegates to that loadClass() method. Or you can save some time and use Spring DM's BundleDelegatingClassLoader class instead.

这篇关于如何获得一个分组中的类加载器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆