简体   繁体   English

OSGi可以安装/部署URL上托管的捆绑软件吗?

[英]Can OSGi install/deploy bundles hosted on a URL?

I'm wondering if I can configure an OSGi container like Karaf (or any other popular ones) to download bundles (.BNDs) from a remote repository hosted on another machine, via any networking mechanism out there (RMI, HTTP, URLClassLoader, etc.)? 我想知道是否可以配置OSGi容器(例如Karaf (或任何其他流行的容器)),以便通过那里的任何联网机制(RMI,HTTP,URLClassLoader等)从托管在另一台计算机上的远程存储库中下载捆绑包(.BND)。 )?

Ideally, I'd be able to deploy new versions of my bundles to this remote repo at any time, and somehow have that trigger the OSGi container "downloading" (installing/deploying) the remote bundles and hot-deploying them over older versions of the same bundle. 理想情况下,我可以随时将新版本的捆绑软件部署到此远程存储库中,并以某种方式触发OSGi容器“下载”(安装/部署)远程捆绑软件,并将其热部署到旧版本的相同的捆绑包。

Is this possible? 这可能吗? If so, how? 如果是这样,怎么办? Thanks in advance! 提前致谢!

OSGi has an API for managing OSGi frameworks on the BundleContext that every bundle activator receives. OSGi具有一个API,用于在每个Bundle激活程序接收的BundleContext上管理OSGi框架。 This API allows you to install/update a bundle via URL or InputStream. 该API允许您通过URL或InputStream安装/更新捆绑软件。

Since this is a standardized API there have been lots of people making bundles that provide a policy around this deployment process. 由于这是一个标准化的API,因此有很多人制作捆绑软件,以提供有关此部署过程的策略。 The archetypical one is Apache FileInstall, it watches a directory and automatically installs every bundle found in this directory and uninstall the bundle when it is gone. 原型服务器是Apache FileInstall,它监视一个目录并自动安装在此目录中找到的每个捆绑软件,并在捆绑软件消失后将其卸载。 This works well with for example dropbox. 例如,这对于Dropbox效果很好。 It also supports configuring via the the Configuration Admin service. 它还支持通过Configuration Admin服务进行配置。 On the other hand of the spectrum you find Apache Ace which provides a remote management system. 另一方面,您可以找到提供远程管理系统的Ap​​ache Ace。

To find the best solution, try to enlist the requirements you have. 为了找到最佳的解决方案,请尝试列出您的要求。 One or two systems or 1 million? 一两个系统还是一百万? Local or remote over slow lines? 通过慢速线路本地还是远程?

One thing is for sure, you will find some project or provider being able to provide you with an OSGi bundle that implements your desired management policy. 可以肯定的是,您会发现一些项目或提供程序能够为您提供实现所需管理策略的OSGi捆绑包。

We use Apache Felix and maintain an OBR repository . 我们使用Apache Felix并维护OBR存储库 Once set up you can deploy new versions from the OSGi shell. 设置完成后,您可以从OSGi Shell部署新版本。 This does require you to manually log in and enter the command, for example deploy com.example.foo . 这确实需要您手动登录并输入命令,例如deploy com.example.foo

Alternatively you can install directly from urls, like install http://example.com/bundles/bundle.jar . 另外,您也可以直接从网址进行install http://example.com/bundles/bundle.jar ,例如install http://example.com/bundles/bundle.jar

Your last requirement (auto deploy) is trickier. 您的最后一个要求(自动部署)比较棘手。 You could perhaps enable a remote shell on your OSGi container and as part of your build push the commands via telnet. 您也许可以在OSGi容器上启用远程Shell,并在构建过程中通过telnet推送命令。

I recommend taking a look at the provisioning of Karaf at documentation for provisioning . 我建议在配置文档中查看 Karaf 的配置 Your able to deploy bundles either with maven urls, http or file references. 您能够部署带有Maven网址,http或文件引用的捆绑软件。 Or you might deploy your set of bundles either as a feature definition (which loads all required and used bundles from a maven repo) or by deploying a kar file. 或者,您可以将一组捆绑软件作为功能定义(从Maven存储库加载所有必需和已使用的捆绑软件)或通过部署kar文件来进行部署。

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

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