On Wednesday, December 22, 2010 12:59:16 AM UTC+1, zixzigma wrote: > > Thank you, it all makes sense now. > > However what you described is how GWT RF uses those details > to do its magic behind the scenes. > > I am not clear what our responsibility is then ? >
Provide the "right" values so RF can "do its magic" ? What should go inside the Locator ? > > From the code I posted, > http://paste.pocoo.org/show/308153/ > > I don't know what I should put in there. > > I have a ServiceLocator ( one per application), > that locates Services. those Services are independent from GWT RF, > they can connect to persistent stores, do whatever they want. > and return a retult/perform action that is expected by RequestContext. > > and what you described for Locators > @ProxyFor(value=PersonEntity, locator=EntityLocator) > public interface PersonProxy { > > > from your explanation I understood why Locator is important, > but what should we/the developers put in it ? > and do we need one per Entity or one per Application ? Well, as always, it depends what you need and what you can do. 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) -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
