私はいくつかのリクエストインターフェースを持つ RequestFactory を持っています
public interface FooRequest extends RequestContext {
Request<List<Foo>> findSmt();
}
実装を配置する場所findSmt()
と、その実装との配線方法がわかりません。
私はいくつかのリクエストインターフェースを持つ RequestFactory を持っています
public interface FooRequest extends RequestContext {
Request<List<Foo>> findSmt();
}
実装を配置する場所findSmt()
と、その実装との配線方法がわかりません。
@Service アノテーションを使用して、findSmt を実装するクラスを示すことができます。FooRequest を継承しないでください。
@Service(FooRequestImpl.class)
public interface FooRequest extends RequestContext {
Request<List<FooProxy>> findSmt();
}
...
public class FooRequestImpl
{
List<FooDAO> findSmt() //note that we dropped the Request and changed the Proxy to the DAO
{
return getFoos();
}
}
残念ながら、同じケースで、ドメイン エンティティに静的メソッドを配置することを余儀なくされました。InstanceRequest
別のクラスでを作成することはできないと思います。
のバインディングについてはfindSmt()
、GWT-RPCに関するドキュメントに記載されています。
RequestFactory サービス スタブは、RequestContext を拡張し、@Service アノテーションを使用して、サーバー上の関連するサービス実装クラスに名前を付ける必要があります。サービス スタブのメソッドはエンティティを直接返すのではなく、com.google.gwt.requestfactory.shared.Request のサブクラスを返します。これにより、GWT-RPC で各サービス メソッドに AsyncCallback オブジェクトを渡すのと同様に、インターフェイスのメソッドを Request.fire() で非同期的に呼び出すことができます。
例:
@Service(Foo.class)
public interface FooRequest extends RequestContext {
Request<List<Foo>> findSmt();
}
public interface FooRequestFactory extends RequestFactory {
FooRequest fooRequest();
}
最後に、配線
final EventBus eventBus = new SimpleEventBus();
requestFactory = GWT.create(FooRequestFactory.class);
requestFactory.initialize(eventBus);
FooRequest request = requestFactory.fooRequest();
request.findSmt().fire(new Receiver() {
@Override
public void onSuccess(void arg0) {
//My implementation comes here....
}
});
はfire()
、 を配線する場所ですfindSmt()
。