title: Use entity manager in CDI extension
body: <p>I want to write a CDI extension which loads some entities from database (which are in fact groovy scripts that implement a certain interface) and provide them as beans, so that it is possible to get all implementations of this interface injected by CDI. I think of sth. like the following:</p>
  
  <pre><code>public class ExtensionClass implements Extension {
    @Inject 
    EntityManager em;
  
    public void afterBeanDiscovery(@Observes final AfterBeanDiscovery event, final BeanManager manager) {
      Entity entity = em.find();
      //do sth with entity...
    }
  }
  </code></pre>
  
  <p>When i try to inject the entity manager this way, it is null (which does not surprise me that much, i did not expect @Inject to work inside a CDI extension class).</p>
  
  <p>Is it possible to get access to the entity manager inside a CDI extension somehow (via BeanManager for example)? Or do i have to access the db in another way?</p>