title: Please explain the @Produces annotation in CDI
body: <p>I have read about the @Produces annotation in CDI, but I don't understand its usage.</p>
  
  <pre><code>public class Resources {
  
  // Expose an entity manager using the resource producer pattern
  @SuppressWarnings("unused")
  @PersistenceContext
  @Produces
  private EntityManager em;                                        // 
  
  @Produces
  Logger getLogger(InjectionPoint ip) {                            // 
      String category = ip.getMember()
                          .getDeclaringClass()
                          .getName();
      return Logger.getLogger(category);
  }
  
  @Produces
  FacesContext getFacesContext() {                                 // 
      return FacesContext.getCurrentInstance();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>taken from:  <a href="http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/guide/GreeterQuickstart/#GreeterQuickstart-">http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/guide/GreeterQuickstart/#GreeterQuickstart-</a></p>
  
  <p>How does the container know to call a producer method? If I inject an EntityManager, how does the container call the @produces EntityManager? And how would a getLogger producer method get called?  </p>
  
  <p>I also don't see the reason to go through all of the trouble.</p>