Osgi 是否可以使用iPOJO将服务绑定到多个使用者?
在我的iPOJO应用程序中,我尝试将服务绑定到两个使用者: 消费者:Osgi 是否可以使用iPOJO将服务绑定到多个使用者?,osgi,ipojo,Osgi,Ipojo,在我的iPOJO应用程序中,我尝试将服务绑定到两个使用者: 消费者: @Component(immediate = true) @Instantiate(name = "com.example.consumerX") @Provides public class consumerX{ @Requires(id="ms",optional=true) private MyService[] services; @Bind(id = "ms", aggregate = tr
@Component(immediate = true)
@Instantiate(name = "com.example.consumerX")
@Provides
public class consumerX{
@Requires(id="ms",optional=true)
private MyService[] services;
@Bind(id = "ms", aggregate = true, optional = true)
public synchronized void register(MyService service) {
System.out.println("service bind to consumer");
}
@Unbind(id = "ms")
public synchronized void unregister(MyService service) {
System.out.println("service unbind from consumer");
}
}
服务:
@Component(immediate = true)
@Instantiate(name = "com.example.serviceX")
@Provides(specifications = { MyService.class, MyServiceX.class})
public class MyServiceX{
...
}
如果我启动consumerA、consumerB和serviceA,则服务仅绑定到consumerA。如果启动consumerB和serviceA,服务将绑定到consumerB
是否可以让服务绑定到两个使用者?有注释吗
谢谢。一项服务肯定有可能被多个消费者使用。您的代码看起来不错,因此应该可以工作
您是否尝试使用“实例”命令检查当前状态http://felix.apache.org/site/ipojo-arch-command.html ? 谢谢你的回答。所有实例都是有效的,错误必须在其他地方。我试着找到它。