> bind(FooComponentImpl.class).annotatedWith(named("1")).in(Scopes.SINGLETON);
>
> will fail (no implementation for FooComponentImpl annotated with
> @Named(value=1) was bound).

Yes, exactly what I see in my test.

> So you need to write
>
> bind(FooComponentImpl.class).annotatedWith(named("1")).to(FooComponentImpl.class).in(Scopes.SINGLETON);

Don't you mean

bind(FooComponent.class).annotatedWith(named("1")).to(FooComponentImpl.class).in(Scopes.SINGLETON);

Else how does Guice resolve requests for FooComponent?

> This works fine UNLESS you also want a singleton scoped, unannotated
> instance of FooComponentImpl:
>
>    bind(FooComponentImpl.class).in(Scopes.SINGLETON);
>
> If you do that, all the named bindings to FooComponentImpl will point to the
> same object the unannotated binding does.

I don't think I want, in fact want to prevent, unscoped instances of
FooComponentImpl being injected.

-Russ

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" 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?hl=en.

Reply via email to