How to auto-start/eager start OSGi services on Eclipse platform(如何在 Eclipse 平台上自动启动/急切启动 OSGi 服务)
问题描述
我开发了一个 Eclipse RCP 应用程序,它大量使用了 OSGi 包,这些包提供服务供以后使用.用例要求捆绑包注册其服务(例如导入过滤器),以便稍后在不同情况下使用.OSGi 捆绑包是使用 maven-bundle-plugin 构建的.
I develop an Eclipse RCP application which makes heavy use of OSGi bundles which provide services for later use. The use case requires the bundles to register their services (e.g. import filters) to be used later on in different situations. The OSGi bundles are build with maven-bundle-plugin.
如何让 Equinox 自动启动 OSGi 包?通过 Activator 的正常方法不起作用.只有惰性模式有效,但我无法触摸未知包中的类.我阅读了 OSGi 规范,并没有提供与延迟加载相反的急切加载.是否还有机会将捆绑包标记为自动加载?
How can I tell Equinox to start the OSGi bundles automatically? The normal approach via Activator is not working. Only the lazy mode is working, but I can not touch classes within unknown bundles. I read the OSGi specification and the opposite to lazy load, eager load, is not provided. Is there another chance to mark the bundle for an auto load?
在 Eclipse 中,我有机会将 Auto-Start 设置为 true,但是在 Maven 和 Tycho 构建的发行版中我该怎么办?
Within Eclipse I have a chance to set Auto-Start to true, but what do I do within a distribution build by Maven and Tycho?
由于未加载 org.eclipse.equinox.ds 的问题,声明式服务无法正常工作.我可以以某种方式启动它而不是激活器吗?这也是一个解决方案,但我不知道如何构建分发或设置什么配置.
Declarative services are not working due to the issue of a not loaded org.eclipse.equinox.ds. Can I get it started somehow instead of an Activator? This would be a solution, too, but I do not know how to build the distribution or what to set as configuration.
这里有哪些最佳做法?还有其他可能吗?Eclipse 平台上的 OSGi 包的文档有点薄.
What are best practices here? Are there any other possibilities? The documentation on OSGi bundles on Eclipse platform is a little thin.
推荐答案
您在声明式服务方面走在了正确的轨道上.手动注册你的服务很像艰苦的工作,安全地查找它们可能是更多的工作,而且很难做到正确.这方面需要注意的另一个标准是蓝图,但如果您有 DS 元数据,我当然不建议您重写任何东西.蓝图在非常动态的环境中具有更好的特性,并且配置更丰富.(我是 Blueprint 实现之一 Apache Aries 的提交者.)对于 Blueprint 和 DS,重要的是还有其他东西正在为您管理服务.
You were on the right track with declarative services. Registering your services manually is a lot like hard work, and looking them up safely can be even more work, and tricky to get right. Another standard in this area to be aware of is Blueprint, although I certainly don't suggest you rewrite anything if you have DS metadata in place. Blueprint has slightly nicer characteristics in a very dynamic environment, and a richer configuration. (I'm a committer on one of the Blueprint implementations, Apache Aries.) With both Blueprint and DS the important thing is that something else is managing your services for you.
这让我们回到了为什么您的捆绑包没有启动的问题.我认为他们确实从费利克斯开始的事实一定有线索.您是否启动了 Equinox 控制台并确认您的所有捆绑软件都已安装并解决?('ss' 列出捆绑包.)您是否查看了 config.ini 文件并确认列出了您的捆绑包,并且具有适当的启动级别 - 或者您是否使用 Equinox 自动启动其他所有捆绑包?
This leaves us back with the issue of why your bundles aren't being started. I think there must be a clue in the fact that they do start in Felix. Have you fired up an equinox console and confirmed all your bundles are installed and resolved? ('ss' to list bundles.) Have you had a look in the config.ini file and confirmed your bundles are listed, and with an appropriate start level - or are you using the Equinox auto-start-everything else bundle?
这篇关于如何在 Eclipse 平台上自动启动/急切启动 OSGi 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Eclipse 平台上自动启动/急切启动 OSGi 服务
基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01