When does Locator.getDomainType() gets called?

99 views
Skip to first unread message

Jens

unread,
Aug 16, 2011, 5:24:20 AM8/16/11
to google-we...@googlegroups.com
Hi,

I want to implement a generic Locator for RequestFactory and I am wondering what I should return in getDomainType().

I have a base Entity thats called EntityBase and holds the id and version. Any other entity extends from EntityBase. Then I have created an EntityLocator extends Locator<EntityBase, Long> and getDomainType() now has to return Class<EntityBase>. I want to use the Locator for every EntityProxy and somehow it doesn't feel right to return EntityBase.class when the Locator is used for example a PersonProxy.

It works for now but is it correctly implemented? As far as I can see the method doesn't get called for now and a quick source code search doesn't reveal if the method is ever called.

How have you implemented a generic Locator for JPA entities? Currently testing with GWT 2.4 RC1.

-- J.

Jens

unread,
Aug 16, 2011, 5:45:37 AM8/16/11
to google-we...@googlegroups.com
I have just seen: http://turbomanage.wordpress.com/2011/03/25/using-gwt-requestfactory-with-objectify/

Here getDomainType() just returns null. So can I assume that the method never gets used and will never be used by the RequestFactory framework?

-- J.

Jens

unread,
Aug 24, 2011, 8:05:15 AM8/24/11
to google-we...@googlegroups.com
No one has an idea?

-- J.

StefanR

unread,
Aug 24, 2011, 8:29:28 AM8/24/11
to google-we...@googlegroups.com
Well, if David Chandler says its not called (in his code comment), and you cannot find any calling piece of code, I think returning null is fine. I do so, too, and didn't run into any problems so far.

Regards,
Stefan.

Thomas Broyer

unread,
Aug 24, 2011, 8:58:22 AM8/24/11
to google-we...@googlegroups.com
I confirm: it's never called (a leftover from a previous iteration of the API I believe; and removing the method would have broken all the projects using Java 6 and putting an @Override annotation on the implemented method).

FWIW, I put a "throw new UnsupportedOperationException()" in mines.

Jens

unread,
Aug 24, 2011, 9:39:10 AM8/24/11
to google-we...@googlegroups.com
Thanks, I can understand that removing the method would be bad especially for projects that use one locator per entity. Hopefully Google marks it as @Deprecated and adds some JavaDoc in the future so that developers never use this method.

-- J.
Reply all
Reply to author
Forward
0 new messages