为什么不能将 osgi 引用声明为静态数据类型?

Why cant an osgi reference be declared as static datatype?

我正在创建这样的 osgi 组件:

@Component (configurationPolicy = ConfigurationPolicy.OPTIONAL, immediate = true)
public class MyServiceAccessor
{
    @Reference (bind = "bindCluster", unbind = "unbindCluster", policy = ReferencePolicy.STATIC, cardinality = ReferenceCardinality.MANDATORY)
    private static Cluster cluster;

我在日志中收到以下消息:

 395 !ENTRY com.test.eventrecovery 4 0 2021-09-08 10:32:32.559
    396 !MESSAGE [com.test.eventrecovery.MyServiceAccessor(265)] Field cluster in component class com.test.eventrecovery.MyServiceAccessor must not be static

当我们为@Component、@Reference 使用felix 注解时,我们没有遇到这个问题。 当我们转向 OSGI 注释时,我看到了这一点。 这种行为有什么具体原因吗?请指教。 此外,我无法访问官方 OSGI 文档,这增加了我的麻烦。 :( http://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html - 这个 link 打不开。

组件实例是对象,因此所有引用都被注入到实例字段中。不是静态字段。由于一个组件可以有多个实例,允许注入静态字段会有问题。

尝试https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html