The RequestFactoryServlet is instantiated by Guice (configured in the ServletContextListener); the ServiceLayerDecorators are instantiated by Guice too and injected into the RequestFactoryServlet constructor. Here I'm using a ServiceLayerDecorator that'll use Guice to create the Locators and ServiceLocators, and there's a GuiceServiceLocator that RequestContext can't point to to have their services created by Guice.
On Friday, February 8, 2013 6:01:11 PM UTC+1, Yan wrote:
-- On Friday, February 8, 2013 6:01:11 PM UTC+1, Yan wrote:
Hi there,I wish to use Guice to inject objects in ServiceLocator class. I am having trouble getting it done, end up with injector.injectMembers(), which I should avoid.Any suggestion how I use Guice in the code below so that my object can be injected into either MyServiceLocator or MyService.public class MyServiceLocator implements ServiceLocator {// field injection does not work here, because GWT internal code is creating ServiceLocator using class.newInstance(), which expects non-argument constructor.@Overridepublic Object getInstance(Class<?> clazz) {if (clazz.equals(MyService.class)) return new MyService(); // cannot use injection because I am creating the object using new() else return null;}}Thanks,Yan
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
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.
No comments:
Post a Comment