@ExtraTypes examples?

451 views
Skip to first unread message

Tiago Rinck Caveden

unread,
Sep 21, 2011, 7:55:21 AM9/21/11
to google-we...@googlegroups.com
Hello all,

I have a scenario which I'm having some headaches to implement in RequestFactory. Thomas Broyer was kindly helping me, and suggested the use of the ExtraTypes annotation, but I can't find examples or much documentation on it. There are these few words on the page about RequestFactory, but they did not help me...

First, let me quickly describe my scenario. In my server side, I have a class Revision<T extends AuditedEntity>. So, in a particular use case, I want to load in GWT proxies to Revision<EntityA>.
I was told to create a proxy RevisionProxy, which do not use generics, and for each particular use case create a sub-inteface of such proxy like EntityARevisionProxy. And then link it all together with @ExtraTypes.

Well... can someone show me an example  or point me to some doc of how precisely should I do this?

Thank you


Thomas Broyer

unread,
Sep 21, 2011, 9:26:17 AM9/21/11
to google-we...@googlegroups.com
@ExtraTypes({ EntityARevisionProxy.class, EntityBRevisionProxy.class })
@ProxyFor(Revision.class)
interface RevisionProxy extends EntityProxy { }

basically says: when a method in a RequestContext or proxy returns a RevisionProxy, it can actually be a EntityARevisionProxy or EntityBRevisionProxy (actually, those proxies are not bound to RevisionProxy because the annotation has been put there, but because they extend it)

Pro tip: when in doubt, have a look at the unit tests for the feature in the SVN repository.

Tiago

unread,
Sep 21, 2011, 11:23:14 AM9/21/11
to Google Web Toolkit
Hello Thomas!

On Sep 21, 3:26 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> @ExtraTypes({ EntityARevisionProxy.class, EntityBRevisionProxy.class })
> @ProxyFor(Revision.class)
> interface RevisionProxy extends EntityProxy { }

Thank you again for your answer. But I tried this. I either have a
stack overflow on GWT, when I add @ProxyFor(Revision.class) to
EntityARevisionProxy, or I have an error from GWT complaining that
EntityARevisionProxy has no @ProxyFor annotation if I don't.

> Pro tip: when in doubt, have a look at the unit tests for the feature in the
> SVN repository.

I'll take a look, thanks!

Tiago

unread,
Oct 21, 2011, 4:05:47 AM10/21/11
to Google Web Toolkit
I've opened the following issue concerning this stack overflow:
http://code.google.com/p/google-web-toolkit/issues/detail?id=6912

Kevin Jordan

unread,
Oct 21, 2011, 9:31:02 AM10/21/11
to Google Web Toolkit
More on the issue with a fix I had to make:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/1387f28687571bf7/bfc53339a05f5d00?lnk=gst&q=kjordan#bfc53339a05f5d00

The problem is that when it goes to examine the subclass in the
@ExtraTypes when it's set on a super type, the subclass ends up
examining itself in an infinite loop unless you keep track of which
ones in an overriden generator.
Reply all
Reply to author
Forward
0 new messages