简体   繁体   English

以编程方式将捆绑软件部署到OSGI运行时

[英]Programmatically Deploying Bundle into OSGI Runtime

I have a system setup where I am running Eclipse Equinox in a server-side application and in my Eclipse RCP Application. 我有一个系统设置程序,在其中我要在服务器端应用程序和Eclipse RCP应用程序中运行Eclipse Equinox。 My goal is to take a plugin in the workspace and deploy it into the server-side app and I'm not sure how to go about it. 我的目标是在工作区中使用一个插件,然后将其部署到服务器端应用程序中,我不确定该怎么做。

I know OSGI supports runtime bundle installs but would I have to compile my workspace project into a jar first? 我知道OSGI支持运行时捆绑安装,但是我是否必须先将工作区项目编译到jar中? Is there an API I can use in Eclipse Runtime to say ..installBundle(String pathToJar or pathToProject) ? 我可以在Eclipse Runtime中使用一个API来说..installBundle(String pathToJar or pathToProject)吗?

This is an example I tested on eclipse equinox. 这是我在日蚀春分点上测试过的一个例子。 If "plugins" is the name of the folder containing all your osgi bundles, a method to install and start a bundle from there is: 如果“ plugins”是包含所有osgi捆绑软件的文件夹的名称,则可以从那里安装和启动捆绑软件的方法是:

void installAndStartBundle(String bundlName) throws BundleException{
    BundleContext bundlecontext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
    Bundle b = bundlecontext.installBundle("file:plugins" + File.separator + bundleName);
    b.start();
}

where bundleName is the name with jar extension of the deployable bundle. 其中bundleName是可部署捆绑软件的jar扩展名。

This is equivalent to the instructions from the osgi console 这等效于osgi控制台中的说明

install file:plugins/<bundle name>.jar
start <bundle id>

In general, you might want to consider Apache Felix File Install as a more robust option. 通常,您可能希望将Apache Felix File Install作为更可靠的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM