如何检测是否在osgi容器中运行 [英] how to detect if running in osgi container
本文介绍了如何检测是否在osgi容器中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
如果你没有激活器,您也可以尝试询问您的捆绑包:
Bundle b = org.osgi.framework.FrameworkUtil .getBundle(MyClass.this);
如果它返回null,你的类没有被OSGi加载。
I have an OSGi bundle that can also run in plain Java process. I need to be able to tell if the bundle was loaded in an OSGi system or not. How can I do that? If there is no OSGi-standard way of doing this, I will settle for Eclipse/Equinox-specific approach.
解决方案
If you don't have an activator, you can also try asking for your bundle:
Bundle b = org.osgi.framework.FrameworkUtil.getBundle(MyClass.this);
If it returns null, your class wasn't loaded by OSGi.
这篇关于如何检测是否在osgi容器中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文