[jboss-user] [EJB 3.0] - Dependency Injection in EJB3

jaikiran pai do-not-reply at jboss.com
Sun Jul 11 04:54:30 EDT 2010


jaikiran pai [http://community.jboss.org/people/jaikiran] replied to the discussion

"Dependency Injection in EJB3"

To view the discussion, visit: http://community.jboss.org/message/552053#552053

--------------------------------------------------------------
> Swamy Nathan wrote:
> 
> 
> 
> 1. ) Can I inject a simple POJO Java bean/object using @javax.annotation.Resource into a EJB- Can we do this inside an EJB. 
>           @Resource
>           private SimpleNotEjbType type;
> 
> 
> 
Is the SimpleNotEjbType available in JNDI? If yes, then you can use the mappedName attribute of the @Resource to point to the jndi name of that resource and have it injected:

@Resource (mappedName="jndiname")
private SimpleNotEjbType type;



> Swamy Nathan wrote:
> 
>  2. ) Can I inject a DataSource using @javax.annotation.Resource into a non-ejb POJO being invoked by my EJB?
>      public class SimpleNotEjbType
>      {
>           @Resource(mappedName="MyDS")
>           private DataSource ds;
>      }

No, the EJB container will not inject the resources into that POJO class.

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/552053#552053]

Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100711/43a13743/attachment.html 


More information about the jboss-user mailing list