はい、できます。これは公式のGWTドキュメントに記載されていますが、あまり詳細ではありません。
DavidChandlerによるこのブログ投稿に大きな助けがありました。
いくつかのポインタ:(
リンクの例はブログ投稿で説明されているプロジェクトからのものです)
エンティティロケーターメソッド(find
、、、、 )はcreate
、汎用Locatorクラス(例getId
)でgetVersion
移動できます。これを機能させるには、エンティティがandメソッドを持つBasicEntityクラスを拡張する必要があります。次に、クライアントで次のようにロケーターを指定します。getId
getVersion
@ProxyFor(value = MyEntity.class, locator = GenericLocator.class)
public interface MyEntityProxy extends EntityProxy {
...
}
データアクセス方法は、サービス内で移動できます。汎用サービス(例)を作成し、それをエンティティごとに拡張して、特定のメソッドを提供することができます(例)。
クライアントでは、次のようにサービスを定義します。
// MyEntityDao is your server service for MyEntity
@Service(value = MyEntityDao.class, locator = MyServiceLocator.class)
interface MyEntityRequestContext extends RequestContext {
Request<List<MyEntityProxy>> listAll();
Request<Void> save(MyEntityProxy entity);
...
}
サービスロケーターの必要性にも注意してください。これと同じくらい簡単にすることができます。