Top-level view: you seem to want to configure classes within A with the Foo that is exported from B. If A is a private module, simply install B without making B a PrivateModule. That will make the bindings in B be visible to everything in A, but it won't export anything from B into a potential collision with bindings in C.
Similarly, at least from the simplified example, I don't know that you'd need to export Foo from C. Fred On Wed, Apr 6, 2011 at 1:09 AM, Andy <[email protected]> wrote: > I understand what your saying about PrivateModules not being ideal, > but I need to use them. > > From my test code, I am unable to add bindings for the same class is > PrivateModule legs. > > class A extends PrivateModule > {@Override > protected void configure() {install(new B()); > } > > class B extends PrivateModule > {@Override > protected void configure() { > bind(Foo.class).to(FooImpl.class); > expose(Foo.class); > }} > > class C extends PrivateModule > { > @Override > protected void configure() { > bind(Foo.class).to(FooImpl.class); > expose(Foo.class); > }} > > > Creating an Injector with Modules A and C breaks, > i.e. > Guice.createInjector(new A(),new C()); > > Before I asked this question, this was basically my setup. What I > dont understand is, that I'm not exposing the Foo.class binding from > the A module, so why it is interfering with the binding in the C > module. > > When you said "Exposing a binding makes it visible to the containing > module and its sibling modules.", > > I thought perhaps that I could modify module A to wrap B in a > PrivateModule, > public class A extends PrivateModule{ > @Override > protected void configure() { > install(new PrivateModule() { > @Override > protected void configure() { > install(new B()); > }});}} > > No dice though, this fails too. Any recommendations? > > -- > 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. > > -- 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.
