On Aug 27, 12:07 pm, Esko Luontola <[email protected]> wrote:
> Here a test to reproduce (also inhttp://pastebin.com/wt3YrkEx). The
> problem was that Foo had a direct dependency to Bar. The solution that
> I'll try is to create an interface for Bar, so that bindings are not
> created implicitly for it, and then expose Bar's interface from the
> other private module.

Another, maybe even better solution (it's more reliable), is to expose
Bar.class in the BarModule. That way the dependency from Foo to Bar
can be declared, but at the same time Bar will get its own instance of
the String.


class BarModule extends PrivateModule {
    protected void configure() {
        bind(String.class).toInstance("Bar-private");
        bind(PrivateValue.class).to(Bar.class);

        bind(Bar.class);
        expose(Bar.class);

 
bind(PrivateValue.class).annotatedWith(Names.named("Bar")).to(Bar.class);
        expose(PrivateValue.class).annotatedWith(Names.named("Bar"));
    }
}

-- 
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