3

について読みましorg.eclipse.e4.core.contexts.IContextFunctionたが、実際の例をオンラインで見つけることができませんでした。
私の理解では、コンポーネントは を実装し、別のオブジェクトIContextFunctionを呼び出すと、compute遅延して作成されます。
しかし、computeメソッドがいつどのように呼び出されるかは明確ではありません。
たとえば、次のようにします。

<?xml version="1.0" encoding="UTF-8"?>  
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"   
  name="com.example.e4.rcp.todo.contextservice.translate">  

<implementation class="com.example.e4.rcp.todo.contextservice.Test"/>  

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

 <property name="service.context.key" type="String"   
   value="com.example.e4.rcp.todo.contextservice.test"/>  

</scr:component>   

誰かがcom.example.e4.rcp.todo.contextservice.testforcomputeを呼び出す必要がありますが、これがどのように使用されるかは不明です。
誰かが参照例を持っていますか?

4

1 に答える 1

5

それがあなたのポジョに注入されるものです。例えば

public class YourPojo {
   @Inject
   @Named("com.example.e4.rcp.todo.contextservice.test")
   private Object yourObject;
}

また

public class YourPojo {
   @Inject
   public void test(IEclipseContext ctx) {
        Object yourObject = ctx.get("com.example.e4.rcp.todo.contextservice.test");
   }
}

また

public class YourPojo {
   @Inject
   public void test(@Named("com.example.e4.rcp.todo.contextservice.test") Object yourObject) {
      // consume yourObject
   }
}
于 2012-10-21T20:33:57.243 に答える