Eclipse e4 OSGI 服务 @Component 注解

Eclipse e4 OSGI Service @Component Annotation

如果创建以下 OSGI-INF/service.xml 并通过服务组件进行设置:OSGi-INF/service.xml 在我的 MANIFEXT.MF

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="EvalManagerContextFunction">

   <implementation class="x.y.context.EvalManagerContextFunction"/>

   <property name="service.context.key" type="String" value="x.y.eval.EvalManager"/>

   <service>
      <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
   </service>

</scr:component>

如果第一次请求 EvalManager(调用 ContextFunction Class compute

现在,如果我尝试对注释执行相同的操作,则不会调用 compute 函数。

@Component(name = "EvalManagerContextFunction", service = IContextFunction.class, property = "service.context.key=x.y.eval.EvalManager")
public class EvalManagerContextFunction extends ContextFunction {

    @Override
    public Object compute(IEclipseContext context, String contextKey) {

        EvalManager manager = ContextInjectionFactory.make(EvalManager.class, context);

        context.get(MApplication.class).getContext().set(EvalManager.class, ContextInjectionFactory.make(EvalManager.class, context));

        return manager;

    }

}

我在 Eclipse 核心源代码中的任何地方都看不到对 @Component 注释 class 的任何引用,因此看起来它不受支持。

Eclipse Marketplace here 中有一个插件似乎添加了对此的支持(我没有尝试过)。

更新:已将对此的支持添加到 Eclipse Neon Milestone 6 (4.6M6) 构建中。