title: Ensure Module Is Loaded Only Once In Guice
body: <p>Having to deal with Guice, I wonder how I should handle dependencies in terms of modules.</p>
  
  <p>In Guice every module is provided by an instance. So if I have a module requiring a certain service it creates the module adding a binding to that service and installs it (binder.install(module)).</p>
  
  <p>Now I have two independent modules that make completely sense to be used independently and both install the same database module. </p>
  
  <p>Using both modules independently no problem arise but what happens if both modules are used in the same application? The database module will be loaded by both modules independently and that can not be correct.</p>
  
  <p>Is there a way to ask the binder if a certain type has already a binding? I can not use getProvider to check on that since all that is returned is a LookupProvider regardless if something is already bind or not.</p>
  
  <p>So how one has to deal with this scenario?</p>
  
  <p>Update:</p>
  
  <p>It seams Guice is unable to provide the following feature:</p>
  
  <ol>
  <li>Check if a given module was already loaded.</li>
  <li>Check if a given class was already bound.</li>
  <li>Use Providers within the configuration to be able to do distributed configuration (modules being able to configure objects being contributed).</li>
  </ol>