[cdi-dev] Clarification: CDI and its relationship with Session beans

Abhishek Gupta abhirockzz at gmail.com
Fri Feb 13 01:43:30 EST 2015


Hello folks - just wanted to gain some clarity here

*Section 1.2.2* of the spec doc states that

[quote] *Any session bean instance obtained via the dependency injection
service is a contextual instance. It is bound to a lifecycle context and is
available to other objects that execute in that context. The container
automatically creates the instance when it is needed by a client. When the
context ends,the container automatically destroys the instance* [/quote]

(being a relative beginner) My first impression after reading this
statement was the following - "*If I use @Inject for DI of an EJB into my
class, the CDI container takes over it's control and actually destroys the
instance after the context ends*".

If we think in terms of @Stateless EJBs, this *might *not be the case,
since the EJB container might choose to return the instance to back to the
EJB pool (I understand that this is not mandated by the EJB spec). Keeping
this in mind, do you think that the statement in section 1.2.2 is correctly
framed since it seems as if the CDI container will actually destroy the EJB
instance?

I think this is better specified in *Section 7.3.3* (this section dives in
deeper)

[quote] *When the destroy() method is called, the container simply discards
this internal reference*.[/quote]

This might be a minor thing - but I am just trying to provide a 'beginner'
point of view of and how he/she might interpret the contents of the
specification with regards to its relationship with EJBs

Feel free to correct me in case I am missing something.

Best Regards
Abhishek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20150213/0b8e7126/attachment.html 


More information about the cdi-dev mailing list