RequestFactory
既存の Java エンティティ モデルで使用しようとしています。私たちの Java エンティティはすべてDomainObject
インターフェースを実装し、メソッドを公開しますgetObjectId()
(この名前はあいまいで、モデル化されているドメインからのドメイン オブジェクトの実際のIDgetId()
と競合する可能性があるため選択されました。
インターフェイスにより、ServiceLayerDecorator
ID およびバージョン プロパティのルックアップ戦略をカスタマイズできます。
public class MyServiceLayerDecorator extends ServiceLayerDecorator {
@Override
public Object getId(Object object) {
DomainObject domainObject = (DomainObject) object;
return domainObject.getObjectId();
}
}
ここまでは順調ですね。ただし、このソリューションをデプロイしようとすると、ランタイム エラーが発生します。特に、RequestFactoryInterfaceValidator
不満:
[ERROR] There is no getId() method in type com.mycompany.server.MyEntity
その後、次のようになります。
[ERROR] Type type com.mycompany.client.MyEntityProxy was previously marked as bad
[ERROR] The type com.mycompany.client.MyEntityProxy did not pass RequestFactory validation
[ERROR] Unexpected error
com.google.web.bindery.requestfactory.server.UnexpectedException: The type com.mycompany.client.MyEntityProxy did not pass RequestFactory validation
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.die(ServiceLayerDecorator.java:212) ~[gwt-servlet.jar:na]
私の質問は、との規則をハードコーディングしているServiceLayerDecorator
場合、カスタマイズされた ID とバージョンのルックアップ戦略を許可するのはなぜですか?RequestFactoryInterfaceValidator
getId()
getVersion()
「毒された」プロキシクラスを無視するようにオーバーライドできると思いますServiceLayerDecorator.resolveClass()
が、この時点では、フレームワークと戦いすぎているようです...