[英]How to get running OSGi container info (name, version etc.) from code?
I want to detect under which OSGi container my application (bundle) is running. 我想检测我的应用程序(捆绑包)在哪个OSGi容器下运行。 How to do this from java code? 如何从Java代码做到这一点?
Bundle systemBundle = bundleContext.getBundle(0);
String symbolicName = systemBundle.getSymbolicName();
Version version = systemBundle.getVersion();
You can guess the implementation (felix, equinox, ...) from the symbolicName and the version from the version of the systemBundle . 您可以从symbolicName和systemBundle的版本中猜测实现(felix,equinox等)。
The id of the systemBundle is always 0 . systemBundle的id始终为0 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.