I'm currently developing a web framework based on Guice + Guice Servlet.

I have a component that needs to dynamically check to see if a Provider has 
been binded for a given type. To do that, I inject the Injector in its 
constructor.

But it seems that if I *only inject the Injector itself*, the Injector 
isn't able to get a Provider :

------------
public class MyComponent
{
    @Inject
    public MyComponent(Injector injector)
    {
        // Throws a ConfigurationException exception :
        Provider<?> provider = 
injector.getProvider(HttpServletRequest.class);
    }
}

------------

But if I inject *any other dependency at the same time*, then the Injector 
works :

------------
public class MyComponent
{
    @Inject
    public MyComponent(AnotherComponent anotherComponent, Injector injector)
    {
        // Works!!
        Provider<?> provider = 
injector.getProvider(HttpServletRequest.class);
    }
}

------------


I'd really like to understand this behavior! Any help?




-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" 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-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to