title: Guice: is it possible to inject modules?
body: <p>I have a Module that requires some <code>Depedency</code>.  Is there a way Modules themselves can be injected?  I realize this is a bit of a chicken and egg situation...</p>
  
  <p>Example:</p>
  
  <pre><code>public class MyModule implements Module {
  
      private final Dependency d_;
  
      @Inject public MyModule(Dependency d) {
          d_ = d;
      }
  
      public void configure(Binder b) { }
  
      @Provides Something provideSomething() {
          // this requires d_
      }
  }
  </code></pre>
  
  <p>I suppose in this case the solution would be to turn the <code>@Provides</code> method into a full-fledged <code>Provider&lt;Something&gt;</code> class.  This is clearly a simplified example; the code I'm dealing with has many such <code>@Provides</code> methods so cutting them each into individual <code>Provider&lt;...&gt;</code> classes and introducing a module to configure them adds a fair amount of clutter - and I thought Guice was all about reducing boilerplate clutter?</p>
  
  <p>Perhaps it's a reflection of my relative noobyness to Guice but I've come across a fair few cases where I've been tempted to do the above.  I must be missing something...</p>