gpt4 book ai didi

java - 蓝图服务列表 : Wait for all services

转载 作者:行者123 更新时间:2023-11-29 05:49:32 26 4
gpt4 key购买 nike

我正在使用 Eclipse Virgo/Gemini Blueprint 并且有一个具有多个实现的接口(interface):

实现 1:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

<bean id="MyID1"
class="ImplementationCLass1">
</bean>

<service ref="MyID1"
interface="MyInterface" />

实现 2:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

<bean id="MYID2"
class="ImplementationClass2">
</bean>

<service ref="MYID2"
interface="MyInterface" />

实现 3:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

<bean id="MyID3"
class="ImplementationClass3">
</bean>

<service ref="MyID3"
interface="MyInterface" />

还有一个客户:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

<reference-list id="MyImplementations"
interface="MyInterface" />

<bean id="clientID" class="ClientClass"
init-method="startUp">

<property name="services" ref="MyImplementations"></property>

</bean>

startUp 方法是一个简单的方法,它遍历整个列表并打印出一个简单的字符串(用于测试目的)

问题是如果我安装客户端 Bundle,我的列表中只有树服务中的两个。如果我停止并再次启动 Bundle,所有三个服务都在我的列表中。

有什么想法/建议吗?

是否可以告诉 virgo 列表必须包含与 MyInterface 匹配的所有服务?

如果您需要更多信息,请随时询问

最佳答案

引用列表的内容是动态的,项目将随着匹配服务的出现和消失而添加和删除。但是您可以实现一个引用监听器,当列表发生变化以跟踪可用服务时,该监听器会收到通知。 Se discussion and examples here .

关于java - 蓝图服务列表 : Wait for all services,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14462944/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com