Is there a way to decide whether or not a module is private at injector construction time?

I have two modules that have a lot of overlapping, but different bindings. This is the "robot legs" problem mentioned on the FAQ. So in the real app I do something like:

Guice.createInjector( new RedDatabase(), new BlueDatabase(), ... );

I need private module here to keep red and blue from conflicting. But in integration test (of a single DB) or were I to make a new tool that might use just BlueDatabase for example, I might want them to act like normal modules so I can get at their full set of bindings. Right now I extend the module like so, to make it more like a normal, "public" module:

new BlueDatabase() {
  protected void configure() {
    super.configure();
    expose( Connection.class );
  }
}

That way if I make an injector using just BlueDatabase, I can get at its connection (unambiguously), since RedDatabase isn't in the picture. Is there a cleaner way to do this?

I can imagine the opposite could happen too, where someone else writes RedDatabase and BlueDatabase independently as AbstractModule and I want to combine them in my project. I don't think child injectors would help here. I don't have this problem but I am curious what I could do if I had to make a module "private" when it was "public".

Thanks,
Jason

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