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.

Reply via email to