KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have read about the @Produces annotation in CDI, but I don't understand its usage. 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(); } } taken from: http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/guide/GreeterQuickstart/#GreeterQuickstart- 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? I also don't see the reason to go through all of the trouble.
Tags (comma-separated)
Save Edits
Cancel