0
votes

I am a little unsure the different types of session beans and how to use them properly in backing beans for JSF.

Stateless sessionbeans you use when the business process can be done in one invocation. Stateful session beans are used when the business process need to be done in multiple steps and you want to "cache" the data on the server between the invocation. These types have different performance and things that you have to take into consideration. I think I understand this part however, let say you have a stateless sessionbean that retrieves a user and do single-task things on the behalf of the user.

Then I want the user retrieved by that stateless sessionbean to be available for a period of time in the JSF. Do you inject this stateless sessionbean into a sessionscoped backing bean? What happens with this injected stateless sessionbean, it won't be returned to the pool before the sessionscoped backing bean is removed right? So this could potentially be a resource-hog if?

Then I thought of making the stateless sessionbean to a stateful sessionbean and let the backingbean be requestscoped instead.

I am a little confused about the different scopes in backingbeans and EJBs.

1
Related question with possibly a duplicate answer: stackoverflow.com/questions/8887140/…BalusC

1 Answers

0
votes

The HttpSession is different from EJB session. So, when you call a SLSB from your session scoped managed bean, just a SLSB from the pool will be used and will be returned back to the pool once the request is complete. So, as such a single SLSB will not be bound to the client managed bean. I believe it is better to have a session scoped managed bean rather than a request scoped one to manage user session.