For information:

   - I use Guice's ServletModule to bind my RequestFactory servlet
   - to benefit from Guice in Service-s and Locator-s, I use a very simple 
   ServiceLayerDecorator, that I inject into a RequestFactoryServlet subclass 
   (so I can pass it to the super() constructor). The ServiceLayerDecorator is 
   being injected the Injector, and overrides createServiceInstance and 
   createLocator
   - createLocator is implemented by directly calling the Injector's 
   getInstance
   - because of the way it's done, createServiceInstance first calls 
   getTop().resolveServiceLocator. If it's not null, then it get's an instance 
   from the Injector and calls getInstance on it (with the 
   domainMethod.getDeclaringClass() as argument, to mimic the default 
   behavior). That way, the ServiceLocator is dependency-injected.
   - Because I want my services to be dependency-injected (and not 
   necessarily my ServiceLocator-s), I created an InjectingServiceLocator that 
   get's injected the Injector and then uses injector.getInstance to implement 
   the ServiceLocator#getInstance. You the just have to use that ServiceLocator 
   for your service for it to be dependency-injected by Guice.

It all fits in approx. 20 LoC.

-- 
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