This is an extract from a post that helped me a lot:

If you can implement a single Locator class that works for all your
entities, then go with it; and otherwise make one for each entity.
For instance, if you have a base class for your entities that provides an ID
and version, then you can easily cast any entity to that class to implement
getId and getVersion, and you probably can implement getIdType by returning
a fixed type.
You can clazz.newInstance() in the create() or use
PersistenceManager#newInstace with JDO.
And you can easily "find" using the Class and ID with JPA using
EntityManager#find(clazz,id), or with JDO using
PersistenceManager#getObjectById(clazz,id).
 
Basically, you could very well have only one Locator class per "id type".
 
Oh, and something to keep in mind: the Locator and *your services* instances
(not the ServiceLocator instances though) are cached aggressively and reused
for all subsequent requests, so make sure they are thread-safe !
(have a look at the ServiceLayerCache class to see all "memoized" methods) 


Original 
Post<https://groups.google.com/d/topic/google-web-toolkit/hGVk6fwwO-A/discussion>
 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to