Java 如何在代码中执行osgi命令
我用的是春分。我想用代码执行osgi命令 例如,安装bundle命令Java 如何在代码中执行osgi命令,java,eclipse-plugin,osgi,equinox,Java,Eclipse Plugin,Osgi,Equinox,我用的是春分。我想用代码执行osgi命令 例如,安装bundle命令 public void start(BundleContext context) throws Exception { String cmd = "install file:///e://testBundle.jar" // How can I execute cmd in code? ... } 感谢您的帮助您可以通过BundleContext或捆绑包的实例管理捆绑包: BundleContex
public void start(BundleContext context) throws Exception {
String cmd = "install file:///e://testBundle.jar"
// How can I execute cmd in code?
...
}
感谢您的帮助您可以通过BundleContext或捆绑包的实例管理捆绑包:
BundleContext.installBundle
允许您从URL安装捆绑包Bundle
实例。请参见示例BundleContext.getBundles()
。在捆绑包
实例上,可以调用start()
、stop()
、update()
或uninstall()
CommandProcessor
的引用,从此处理器创建CommandSession
,并在此会话上调用execute
@Reference
CommandProcessor commandProcessor;
...
CommandSession commandSession = commandProcessor.createSession(System.in, System.out, System.err);
commandSession.execute("..");
您是希望执行命令来安装捆绑包,还是对任何命令更感兴趣?在osgi中安装/更新捆绑包很容易,您不必依赖命令即可完成此操作。我知道如何在osgi中安装捆绑包,但我希望在代码中动态执行start/stop/install/remove命令。谢谢。BundleContext.installBundle有效。但CommandProcessor无法导入。若要访问
CommandProcessor
和CommandSession
,请将依赖项添加到组:“org.apache.felix”,名称:“org.apache.felix.gogo.runtime”。