Eclipse4 OSGI服务@组件注释
如果是,请创建以下OSGI-INF/service.xml并通过服务组件进行设置:my MANIFEXT.MF中的OSGI-INF/service.xmlEclipse4 OSGI服务@组件注释,osgi,rcp,e4,Osgi,Rcp,E4,如果是,请创建以下OSGI-INF/service.xml并通过服务组件进行设置:my MANIFEXT.MF中的OSGI-INF/service.xml <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="EvalManagerContextFunction"> <implementation
<?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>
我在Eclipse核心源代码中的任何地方都看不到对
@Component
注释类的任何引用,因此它似乎不受支持
Eclipse Marketplace中有一个插件,它似乎增加了对此的支持(我还没有尝试过)
更新:EclipseNeonMilestone6(4.6M6)版本中已经添加了对此的支持。好的,谢谢greg。现在我将使用xml文件。我使用了您提到的DS支持插件,它工作得非常好。每当您更改组件时,插件会自动动态创建XML定义文件。我正在使用Neon M6,但因插件不兼容而失败。这个插件的作者回答了一个问题,他说它应该在Neon M6中工作,而不添加一些额外的插件
Dirk,这个插件实现的功能从Neon M6(即将发布)起就直接添加到Eclipse PDE中。看见https://bugs.eclipse.org/bugs/show_bug.cgi?id=376950
在答案中添加了关于Eclipse Neon的注释。
@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;
}
}