On Saturday, April 6, 2013 11:53:15 AM UTC+2, Aman Sharma wrote:
>
> I'm using JDO with RequestFactory and MVP pattern. Example to  implement 
> service in firty way is very clear to me from 
> https://developers.google.com/web-toolkit/doc/latest/DevGuideRequestFactory#entity_service
>
> But how do you implement a service as instance methods in a service class? 
> I am not very clear with the definition and use of ServiceLocator , 
> Locator. When do you use them?
>
> Is a service class different from persistence capable entity?


There are 2 ways to have your RequestContext methods backed by instance 
methods:

   - a return-type of InstanceRequest<SomeProxy, Result> tells RF to call 
   the method on the domain object backing the SomeProxy instance passed to 
   using()
   - a locator in the @Service or @ServiceName annotation tells RF to 
   instantiate the ServiceLocator class and then use it to get an instance of 
   the service class.

The Locator that you use in @ProxyFor / @ProxyForName is about moving the 
findXxx static method and the getId and getVersion instance methods out of 
your entity and in a Locator instance.

The doc only shows 2 ways of using RF:

   - using the entity as both an entity and service (with static methods): 
   this is the default when you don't provide locators (this is because the 
   Spring Roo guys with whom RF was built tried to somehow mimic Ruby on Rails 
   / ActiveRecord),
   - removing all static methods from the entity by using both a Locator 
   and ServiceLocator

but you can mix and match things as you like: you can use Locator without 
ServiceLocator, or ServiceLocator without Locator; when you don't use a 
ServiceLocator, your service class can be distinct from an entity (domain 
object).

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to