问题标签 [declarative-services]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
5821 浏览

eclipse - OSGi 声明式服务组件中的不满意引用

我在 OSGi 声明式服务组件中遇到了不满意的引用问题:

我从 Eclipse 启动 OSGi 应用程序,控制台显示服务处于以下Unsatisfied状态:

comp命令报告原因是对以下内容的不满意引用org.osgi.service.http

但是org.osgi.service.http可用,如packages命令所示:

我尝试从服务文档中删除引用,并且服务组件已正确实例化和激活,但没有必要的HttpService部分。

非常感谢任何进一步排除故障的帮助。

0 投票
1 回答
210 浏览

osgi - 如何在我自己的部署在 WAS 8.0 中的 OSGi 应用程序中启动特定的捆绑包?

我有一个相当复杂的 OSGi 应用程序,它使用声明式服务并被设计为部署在 Equinox 中。现在的任务是使这个应用程序可以在 WAS 8 中部署。

第一次尝试非常实用:我部署了一个 EAR,它启动了基本相同的 Equinox,并且在对 WAS 类加载策略进行了一些调整之后,它已经工作了。

现在我想更进一步:摆脱 Equinox 运行时并在 WAS 8 中“本地”部署我的包。所以我编写了一个 EBA,由我的业务包、它们的依赖项和 Equinox DS 运行时组成。EBA 作为资产部署并集成到 BLA 中。应用程序甚至已启动并运行,但组件未初始化。

关键是必须在自己的业务包之前启动 equinox.ds(更新:不是必须的,下面的讨论)才能使 DS 完成它的工作。但是我如何告诉捆绑包在部署的 EBA 中首先启动?我需要一些 Equinox 的 config.ini 文件的模拟。

我知道我可以使用原生支持的蓝图重新连接我的组件,但坦率地说,这是我最不想做的事情。应该可以让 Equinox DS 工作,不是吗?

另一个问题是:如何获取自己的应用程序在 WAS 8 下部署的 OSGi 控制台?我想控制我的捆绑包,但似乎无法从管理控制台中做到这一点。

更新

感谢 BJ 和 Neil(下面的讨论),问题归结为“如何在我自己的部署在 WAS 8.0 中的 OSGi 应用程序中启动特定包?”

0 投票
2 回答
282 浏览

osgi - 与声明式服务绑定的服务顺序

有没有办法找出或确定服务与声明式服务绑定的顺序?我的问题是我在我的 OSGI 中运行了一个日志服务以及其他服务。现在,我的组件绑定了这个日志服务和其他一些服务。每次绑定或取消绑定服务时,我都想写一条日志消息。但是,如果服务 A 在我的日志服务之前绑定,则无法写入 A 的日志条目。

我可以以某种方式配置绑定顺序吗?我阅读了有关将服务的绑定策略设置为“静态”的信息,这应该确保首先绑定该服务。但这并不是我想要的。我不希望每次我的日志服务由于某种原因消失时都重新创建我的组件。

0 投票
0 回答
85 浏览

java - 使用 Felix SCR 注释具有与没有默认值的 String 不同的类型

我在实践中的问题:

上面的注释生成:

我可以以“类型”为“整数”但没有默认值的方式指定@Property 注释吗?该示例使用整数,但问题与所有非字符串类型相同。

如果可以使用其他注释集(例如来自 BndLib 的注释集),我也对该解决方案感兴趣。但是,maven 支持对我来说非常重要。使用 felix-scr-plugin 有 m2e 生命周期映射,因此 XML 文件在 target/classes 文件夹中始终是最新的。

0 投票
2 回答
2373 浏览

java - 我不能点击这个 JTextField 来编辑它,为什么不呢?

更新

这只发生在 OS X 上运行时。Windows 上不存在此问题。我正在使用 Eclipse Kepler 和 Oracle 1.7.0_45.jdk


下面的代码是从 OSGI 声明式服务组件运行的基本 GUI。问题是当 GUI 启动时,我无法与JTextField loginField. 我可以与JButton loginButton. 如果我运行与 Java 应用程序相同的代码,我可以交互/编辑JTextField. 所以问题一定是由于它是作为 OSGi 包启动的。任何人都可以阐明问题可能是什么?

DoctorDevice.java

DoctorGUI.java

DbContextClient.xml - OSGi 组件定义

0 投票
3 回答
1449 浏览

java - Best Practice in an OSGi UI application

I am somewhat new to the OSGi world. And some concepts still elude me.

I'm trying to create a graphical OSGi application using Swing, Equinox and Declarative Services. The goal is to ease the creation of plugins and extensions for the application.

I have stumbled with a design problem and, since I am doing this from the ground up, I want to use all the best practices I can.

I do have a bundle that contains the API and only exposes interfaces to be implemented as services.

Let's say I have a bundle (Core) that provides a service that is a manager of certain types of objects (It basically contains an internal List and adds, removes and updates it).

I also have a second bundle (UI) that takes care of the main UI. It should not "care" for the object managing itself, but should be notified when an object is added, removed or changed in order to update a JTree. For that purpose I used a Whiteboard pattern: The UI bundle implements a service that is used by the Core bundle to fire object change events.

My problem here is the following:

The MainWindow is a DS component. I am using its activator to initiate the whole UI. The instance creation is handled by OSGi.

In order to get the updates from the manager, I am exposing the SomeClassUIListener as a Declarative Service. Its instance is also handled by OSGi.

How should I access the instance of the JTree model from the SomeClassUIListener?

I have come up with several options but I am not sure which to use:

Option 1: Use some kind of internal DI system for the UI bundle (like Guice or Pico) and put it in a class with a static method to get it and use it all over the bundle.

This approach seems to be frowned upon by some.

Option 2: Inject a reference to the MainWindow (by turning it into a service) in the SomeClassUIListener through OSGi and go from there. Is this possible or advisable? Seems to me that it is the simpler solution. But, on the other hand, wouldn't this clutter the bundle with component config files as the UI got more and more complex?

Option 3: Create a separate bundle only for listeners and use OSGi to update the MainWindow. This seems to me a bit extreme, as I would have to create an enormous amount of bundles as the UI complexity grows.

Option 4: Use the MainWindow class to implement the Listener. But, the more services in the main UI bundle, the bigger the MainWindow class would be. I think this would not be a good option.

I cannot think of more options. Is any of the above the way to go? Or is there another option?

Thank you in advance.

Edit:

Just to clarify as Peter Kriens had some doubts about this question.

My goal here is to decouple the user interface from the Manager. By Manager I mean a kind of repository in which I store a certain type of objects (For instance, if you consider the Oracle's JTree tutorial at http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html, the manager would contain instances of Books).

The Manager may be used by any other bundle but, according to my current plan, it would notify any listener registered in it. The listener may be the main UI bundle but may also be any other bundle that chooses to listen for updates.

0 投票
0 回答
632 浏览

websphere - WAS 8.5 - 蓝图管理的 OSGI 服务是否可以引用声明性服务管理的 OSGI 服务?

我们使用 WebSphere 8.5(NON-Liberty Profile……只是直接的 WAS),我们有一个 Spring 3.2 Web 应用程序,它正在访问一个 OSGI 服务,该服务通过 SCA 服务桥使用蓝图组件模型。我们这样做是因为据我们了解,这是能够从我们当前架构中访问 OSGI 服务层的唯一方法。如果有人可能知道另一种/更好的方法,我也对此全神贯注。

在此蓝图托管服务中,我们希望引用另一个服务。我们希望由声明式服务组件模型管理这个其他服务(以及其中的任何服务引用)。

我的问题是……这可能吗?有谁知道在 WAS 8.5 中混合这两个组件模型是否可以以任何方式、形状或形式进行?

如果可能的话,是否有人能够指出我如何解决这个问题的正确方向?

编辑 - 12 月 5 日

所以我决定采用的方法是首先构建一个小的概念验证应用程序,该应用程序使用三个不同的 OSGI 包,它们都使用蓝图。然后,一旦我完成了这项工作,请使用其中一项蓝图托管服务,并尝试将其转换为 ds 托管服务。

这是我到目前为止所得到的:我已经完成并创建了位于此处的教程。我目前有 CounterApp OSGI 捆绑应用程序,其中包含以下捆绑包作为应用程序内容:

  • CounterServiceBundle
  • CounterWebBundle
  • CounterWorldBundle

如教程中所述,以上所有内容都通过 blueprint.xml 文件使用蓝图组件模型绑定在一起。

所以这一切都分解如下:

在 CounterWebBundle 的 CounterServlet 的 doGet 方法中,我以以下方式使用了 Greet 服务:

此“问候”服务在蓝图 xml 中定义为“GreetBeanService”。现在,在它的实现类中,它引用了另外两个服务,“CounterBean”和“WorldRef”。

这是要澄清的 blueprint.xml 文件:

</blueprint>

所以事情是这样的:

我的目标是使用component.xml文件将“WorldRef”服务转换为 DS 托管服务,并将以下内容添加到Service-Component: OSGi-INF/component.xml实现类的 MANIFEST.MF 标头中,如果我理解正确,则不是 API 类。

这就是我需要为转换做的所有事情吗?还是我还需要为班级添加激活器?另外,我需要在 API 实现类中添加“激活”和“停用”方法吗?

另外,我知道我必须以某种方式将服务组件运行时包含在一个单独的包中并将其包含在“CounterApp”应用程序中,我该怎么做呢?我是否必须创建一个包含以下捆绑包/jar 的单独捆绑包项目

  • org.eclipse.equinox.util
  • org.eclipse.equinox.ds
  • org.eclipse.osgi.services

然后我将在哪里重新导出所有这些 jar 中的所有导出接口?或者我是否必须定义某种服务来导出暴露 SCR?

编辑 - 12 月 6 日

我继续创建了一个新的 DS OSGI 包/jar,其中包含提供 Equinox DS 实现所需的所有上述 jar 文件,然后在这个新包中传递每个 jar 的导出。然后,我将此 DS 包添加到我的 CounterApp 应用程序中,并将这些 DS 包导出中的每一个导入到包含 WorldRef 服务的包中。

这是我似乎被挂断的地方:

OSGI 框架正在加载包含 WorldRef 服务的包,但该服务未添加到注册表中,这表明未读取定义该服务的 component.xml 文件,这表明 SCR 未运行,因为据我了解,这就是读取该文件的内容。

所以仍然坚持让 SCR 运行的能力。我的最后期限非常紧迫(我知道……谁不是,对吧?

0 投票
2 回答
175 浏览

service - OSGi:在服务仍在运行时停止导入的服务会发生什么

假设我正在使用service A在另一个中导入的a service B。在B正常运行时(当然是活动的),在运行时卸载A会发生什么? service Aservice BService A -> Service B

如果我使用ServiceReference, ServiceTracker&会有什么不同的场景DS

0 投票
1 回答
187 浏览

websphere - 试图让声明式服务 SCR 在 WebSphere 8.5(非自由)上运行

我有一个运行在 WebSphere v8.5(非自由配置文件)上的蓝图管理的 OSGI 应用程序,其中一个服务 Service_A 引用了另一个服务 Service_B。我希望 Service_B 由声明性服务服务组件运行时而不是蓝图容器管理,但仍然让 Service_A 被蓝图管理。

我相信我在让 SCR 运行时遇到了困难。我不确定我是否正确包含它,或者我如何检查它是否正在运行。我已经用一些打印语句在 Service_B 的实现中定义了“激活”和“停用”,据我了解,当 SCR 找到我理解的服务时,应该调用它们,但我很确定它们是没有被调用,因为断点不会停在那里,我在控制台中看不到任何输出。

到目前为止,我为包含运行时所做的努力如下:

据我了解,以下三个 jars/bundle 就是运行 SCR 所需要的。

  • org.eclipse.equinox.ds
  • org.eclipse.equinox.util
  • org.eclipse.osgi.services

我继续创建了一个包含所有上述 jar 文件的新 OSGI 包/jar,然后在这个新包中传递每个 jar 的导出。然后,我将此 DS 包添加到我的主 OSGI 应用程序中,并将这些 DS 包导出中的每一个导入到包含将由 SCR 管理的服务的包中。

这是我似乎被挂断的地方:

OSGI 框架正在加载包含该服务的包,但该服务未添加到注册表中,这表明未读取定义该服务的 component.xml 文件,这表明 SCR 未运行,因为它据我了解,是读取该文件的内容。

所以仍然坚持让 SCR 运行的能力。非常感谢任何和所有帮助!我的截止日期非常紧迫(我知道......谁错了?:))并且欢迎所有帮助!谢谢!

0 投票
2 回答
1418 浏览

jpa - JPA 与 OSGi DS 示例

我试图找出JPA一个使用Eclipselink & Derby. 我可以在 Java EE 中做到这一点,但我无法找到一种简单的方法来OSGi使用Declarative Services.

任何人都可以分享有关使用的任何此类示例的一些信息JPA with OSGi DS吗?

我经历过的一些例子是here,但是这些例子使用getReference或者getTracker我不想使用它们。

谢谢你。