title: Dynamically bind instances using guice
body: <p>In my application (stand alone apache camel) i have to bind several beans (instances of pojos).
  Because those pojos could not be used directly (in java) but have to be used via bound references in urls i want to "register" all available beans in an enum. The beans are then bound like this:</p>
  
  <pre><code>public class BeanRegistry extends JndiRegistry {
      public BeanRegistry() {
          for (Beans bean : Beans.values()) {
              try {
                  this.bind(bean.name(), bean.clazz().newInstance());
              } catch (InstantiationException | IllegalAccessException e) {
                  throw new IllegalStateException("Problem on instantiating bean " + bean.name() + " with type "
                                                  + bean.clazz().getName() + ", cause Exception: ", e);
              }
          }
  
      }
  
  
      public static enum Beans {
          sorter(SortingStrategy.class),
          policy(PolicyForStartAndStopRoutes.class),
          doneFilter(ExcludeDoneFilesFilter.class);
  
          private final Class&lt;?&gt; clazz;
  
          Beans(Class&lt;?&gt; clazz) {
              this.clazz = clazz;
          }
  
          public Class&lt;?&gt; clazz() {
              return clazz;
          }
      }
  }
  </code></pre>
  
  <p>With this no spelling mistakes could happen as long as you use enum's name to reference a bean. 
  My problem is <code>bean.clazz().newInstance()</code>. Is there a way to use guice to "provide" the instances? With guice i could bind the instances to arbitrary constructors or "implementations".</p>