0

私はいくつかのリクエストインターフェースを持つ RequestFactory を持っています

public interface FooRequest extends RequestContext {
   Request<List<Foo>> findSmt();
}

実装を配置する場所findSmt()と、その実装との配線方法がわかりません。

4

2 に答える 2

1

@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別のクラスでを作成することはできないと思います。

于 2011-03-24T17:33:29.910 に答える
0

のバインディングについては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()

于 2011-03-24T17:36:51.843 に答える