【发布时间】:2016-08-05 14:13:26
【问题描述】:
如果在我的 MANIFEXT.MF 中创建以下 OSGI-INF/service.xml 并通过 Service-Component: 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 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;
}
}
【问题讨论】: