私のプロジェクトでは、GWTEntityProxy
を次のように簡略化しています。
@ProxyFor(value = Item.class, locator = ItemService.class)
public interface ItemProxy extends EntityProxy
{
String getName();
// other getters and setters here
}
単純なJPA注釈付きエンティティBeanである対応するエンティティ実装を使用します。
リクエストコンテキストもあります:
@Service(value = ItemService.class, locator = InjectingServiceLocator.class)
public interface ItemRequestContext extends RequestContext
{
Request<List<ItemProxy>> findItems();
}
そして、対応するサービスとロケーターの実装:
public class ItemService extends Locator<Item, Long>
{
@Override
public Item find(Class<? extends Item> clazz, Long id)
{
return getItemFromJpa(id);
}
public List<Item> findItems()
{
return getAllItemsFromJpa();
}
// Remaining Locator and JPA methods skipped
}
RPCの観点からGWTリクエストコンテキストでメソッドを呼び出すと、findItems
すべてが期待どおりに機能しているように見え、クライアントで機能するコールバックメソッドのアイテムリストを取得します。
ただし、永続性の観点からは、実装は期待どおりに機能しません。サーバー側では、メソッドfindItems
が期待どおりに呼び出され、永続性からアイテムをフェッチして返します。次に、アイテムごとfind
に、アイテムのIDを使用してメソッドが呼び出され、もちろん、永続性からアイテムを次々に取得します。
GWTリクエストファクトリコンテキストがこれらの役に立たない呼び出しを行う原因と、それを防ぐにはどうすればよいですか?