【发布时间】:2023-03-21 03:55:01
【问题描述】:
我有一个 IFoo 接口的 DS 服务使用者:
@Component
public class IFooListener {
@Reference(bind = "bind",
unbind = "unbind",
referenceInterface = IFoo.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC)
public static final Map<String, IFoo> allServices = new ConcurrentHashMap<>();
protected void bind(IFoo service, Map<String, String> properties) {
....
}
....
}
我有这样注册的 IFoo 服务:
BundleContext ctx = FrameworkUtil.getBundle(IFooListener.class).getBundleContext();
Properties properties = new Properties();
....
ServiceRegistration managementSrv = ctx.registerService(IFoo.class.getName(), iFooImpl, properties);
我想知道的是,是否保证当 ctx.registerService(...) 方法返回时,所有当时已经可用的 DS 消费者都会被通知 IFoo 服务已注册? 这是 osgi-implementation 特定的东西吗?或者这是 DS 规范的一部分?
【问题讨论】:
-
您应该指出您使用的注释,因为有多个注释。这些绝对不是标准的 OSGi 注释。作为答案,在系统中依赖此类保证是非常糟糕的做法。
标签: java osgi declarative-services