javapolymorphismrequestfactorygwt-2.4

GWT 2.4.0 RequestFactory polymorphism


Does GWT 2.4 support this case:

@Entity class MyBase {...}
@Entity class MyChild1 extends MyBase {...}
@Entity class MyChild2 extends MyBase {...}
...
@ProxyFor(MyBase.class) class MyBaseProxy extends EntityProxy {...}
@ProxyFor(MyChild1.class) class MyChild1Proxy extends MyBaseProxy {...}
@ProxyFor(MyChild2.class) class MyChild2Proxy extends MyBaseProxy {...}
...
@Service(ArticleBase.class)
public interface MyBaseRequest extends RequestContext {
    Request<MyBaseProxy> getStuff(); // MyChild1 here
}
...
Request<MyBaseProxy> getStuffRequest = request.getStuff();
getStuffRequest.fire(new Receiver<MyBaseProxy>() {
    @Override
    public void onSuccess(MyBaseProxy proxy) {
        button.setText(((MyChild1Proxy)proxy).getQwerty()); // HERE!
    }
});

?

The problem is, I can't make it work. It's either not supported yet or I need to add some magic annotation somewhere. Everything works fine when I use concrete types, but it doesn't work if I use the base ones.

What do you think?


Solution

  • Fixed it with @ExtraTypes:

    @Service(ArticleBase.class)
    @ExtraTypes({MyChild1Proxy.class, MyChild2Proxy.class})
    public interface MyBaseRequest extends RequestContext {
        Request<MyBaseProxy> getStuff(); // MyChild1 here
    }