Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about the EJB lifecycle  RSS feed

 
David Lidz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im fairly certain about the answer but I want to double check

I assume that the container makes sure that only one of the same EJB exists at a time.

For example:
If I were to use this code in three different ManagedBeans



The container would make sure that even though declared three times there will only be one EJB at a time, i.e they share the same EJB?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I assume that the container makes sure that only one of the same EJB exists at a time.

No. If the EJB were a stateful bean you can assume one instance per session. If it were stateless, it might be one instance it might be three. The only influence you can have on this is configuring the stateless bean pool to a maximum number.
 
David Lidz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, so with a stateful EJB there will be only one. Thanks!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Assuming the three different managed beans were part of the same session.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!