[cdi-dev] [JBoss JIRA] (CDI-255) Support for Implicit Producers

Antonio Goncalves (JIRA) issues at jboss.org
Sat Sep 20 09:14:03 EDT 2014


    [ https://issues.jboss.org/browse/CDI-255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13002319#comment-13002319 ] 

Antonio Goncalves edited comment on CDI-255 at 9/20/14 9:13 AM:
----------------------------------------------------------------

When you look at all the Java EE 7 specs, you don't find much : 

*Bean Validation 1.1* (§ 10.3. Context and Dependency Injection (CDI) integration)

{code}
@Inject ValidatorFactory;
@Inject Validator;
{code}

*JMS 2.0* (§ 12.4.3. Injection syntax)

{code}
@Inject
private JMSContext context;
{code}

*CDI 1.2* (3.8. Additional built-in beans)

A Java EE or embeddable EJB container must provide the following built-in beans, all of which
have qualifier {{@Default}}:
* a bean with bean type {{javax.transaction.UserTransaction}}, allowing injection of a reference
to the JTA UserTransaction, and
* a bean with bean type {{javax.security.Principal}}, allowing injection of a Principal
representing the current caller identity.
A servlet container must provide the following built-in beans, all of which have qualifier @Default:
* a bean with bean type {{javax.servlet.http.HttpServletRequest}}, allowing injection of a
reference to the {{HttpServletRequest}}
* a bean with bean type {{javax.servlet.http.HttpSession}}, allowing injection of a reference
to the {{HttpSession}},
* a bean with bean type {{javax.servlet.ServletContext}}, allowing injection of a reference to
the {{ServletContext}},

BTW, in the Java EE 7 spec there is *only one single* line of code showing {{@Inject}}

Other Java EE objects that could be implicitly produced :

{code}
@Inject FacesContext facesContext; // From JSF
@Inject EntityManager em;          // From JPA, handy when there is only one persistence unit
{code}


was (Author: agoncal):
When you look at all the Java EE 7 specs, you don't find much : 

*Bean Validation 1.1* (§ 10.3. Context and Dependency Injection (CDI) integration)

{code}
@Inject ValidatorFactory;
@Inject Validator;
{code}

*JMS 2.0* (§ 12.4.3. Injection syntax)

{code}
@Inject
private JMSContext context;
{code}

*CDI 1.2* (3.8. Additional built-in beans)

A Java EE or embeddable EJB container must provide the following built-in beans, all of which
have qualifier {{@Default}}:
• a bean with bean type {{javax.transaction.UserTransaction}}, allowing injection of a reference
to the JTA UserTransaction, and
• a bean with bean type {{javax.security.Principal}}, allowing injection of a Principal
representing the current caller identity.
A servlet container must provide the following built-in beans, all of which have qualifier @Default:
• a bean with bean type {{javax.servlet.http.HttpServletRequest}}, allowing injection of a
reference to the {{HttpServletRequest}}
• a bean with bean type {{javax.servlet.http.HttpSession}}, allowing injection of a reference
to the {{HttpSession}},
• a bean with bean type {{javax.servlet.ServletContext}}, allowing injection of a reference to
the {{ServletContext}},

BTW, in the Java EE 7 spec there is *only one single* line of code showing {{@Inject}}

Other Java EE objects that could be implicitly produced :

{code}
@Inject FacesContext facesContext; // From JSF
@Inject EntityManager em;          // From JPA, handy when there is only one persistence unit
{code}

> Support for Implicit Producers
> ------------------------------
>
>                 Key: CDI-255
>                 URL: https://issues.jboss.org/browse/CDI-255
>             Project: CDI Specification Issues
>          Issue Type: Tracker
>    Affects Versions: 1.0
>            Reporter: Pete Muir
>
> An implicit producer could be registered for every unambiguous resource the Java EE container knows about.



--
This message was sent by Atlassian JIRA
(v6.3.1#6329)



More information about the cdi-dev mailing list