如何在Eclipse平台上自动启动/启动OSGi服务 [英] How to auto-start/eager start OSGi services on Eclipse platform

查看:104
本文介绍了如何在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软件包?通过激活器的正常方法不起作用。只有懒惰模式正在工作,但我无法触及未知软件包中的类。我阅读了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中我有机会将自动启动设置为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的问题,声明式服务不起作用。我可以以某种方式开始,而不是Activator吗?这也是一个解决方案,但是我不知道如何构建分发或者什么设置为配置。

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.

推荐答案

您在声明服务方面处于正确的轨道。手动注册您的服务非常像努力工作,安全查找可以更多的工作,而且很难做到正确。要注意的另一个标准是Blueprint,尽管如果您有DS元数据,我当然不建议您重写任何内容。蓝图在非常动态的环境中具有稍微更好的特性,并且更丰富的配置。 (我是蓝图实现之一,Apache Aries的提交者)。蓝图和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.

这让我们回到了为什么你的软件包没有启动的问题。我认为在Felix开始的时候一定有一个线索。你已经开了一个平衡控制台,并确认所有的捆绑是安装和解决的? ('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服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆