Status: New
Owner: ----

New issue 538 by mingfai.ma: Support JSR330 annotation for instance binding
http://code.google.com/p/google-guice/issues/detail?id=538

for instance binding ( bind(/*class*/).toInstance(/*instance*/), the instance will be injected only when using @com.google.inject.Inject but not @javax.inject.Inject

See the following test case (also attached)

public class AnnotationCompatibilityTest2{
    @Test public void testAnnotationCompatibility(){

        Injector g = Guice.createInjector(new Module(){
            @Override public void configure(Binder binder){
                binder.bind(GuiceBean.class).toInstance(new GuiceBean());
                binder.bind(JsrBean.class).toInstance(new JsrBean());
            }
        });

        TestBean test2 = g.getInstance(TestBean.class);
        assertNotNull(test2.guiceBean);
        assertNotNull(test2.jsrBean);//jsrBena is null, test failed
    }


    static class TestBean{
        @com.google.inject.Inject GuiceBean guiceBean;
        @javax.inject.Inject JsrBean jsrBean;
    }

    static class GuiceBean{
    }

    static class JsrBean{
    }
}




Attachments:
        AnnotationCompatibilityTest2.java  910 bytes

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to