-
1. Re: Injecting @EJB references fails?
asiandub Jul 15, 2010 6:47 AM (in response to ljnelson)to sort out the obvious:
- if Frobnicator is a local EJB, you could skip the production process and use / inject it directly
- if Frobnicator is a remote EJB, you should provide the link to the relevant archive (from the example: @Produces @EJB(ejbLink="../their.jar#PaymentService")
)is that of any help?
cheers,
Jan
-
2. Re: Injecting @EJB references fails?
ljnelson Jul 15, 2010 11:45 PM (in response to ljnelson)Yes, that is of help. I was not aware from the reference documentation (I'm sure it's in there somewhere) that one could skip the production process entirely (not so obvious after all). Indeed that works!
Thanks,
Laird -
3. Re: Injecting @EJB references fails?
asiandub Jul 16, 2010 2:13 AM (in response to ljnelson)
I was not aware that one could skip the production processthat's an import part of the concept. CDI is a stateful implementation of the dependency injection pattern - this means, that the CDI-container managers not only the dependencies but also the lifecycle of the managed beans.
What you're usually doing is declare the dependencies and let the container do the rest. CDI will instantiate all beans in the correct scope for you. Producer methods are for (rare) cases when you need more control about that process, like maybe joining a transaction or not.
These parts of the documentation give a good overview:
http://docs.jboss.org/weld/reference/1.0.1-Final/en-US/html/injection.html
http://docs.jboss.org/weld/reference/1.0.1-Final/en-US/html/scopescontexts.html
cheers,
Jan