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.

    @Override
    public 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 [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