This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
share stateful session bean among stateless session beans
Marco Dalla Torre
Joined: Apr 21, 2011
I am quite new to EJB so please bear with me :-) I am trying to write an ejb web application that has multiple stateless session beans thah share a stateful session. The latter provides methods tha use data read from database. That is, the SLSBs inject the SFSB and use it in their methods. The intended reason is to share the same information and code, instead of having multiple DB lookup points for each SLSB. In some cases I also directly use the stateful session bean from presentation tier.
Now this does not work since the SFSB injected is a different instance for each SLSB, and this causes trouble when its data gets modified, and its state is not shared to other SLSBs. So my question is: is it possible to share an SFSB instance among multiple SLSBs? Is it a crazy idea (this thread seems to suggest so)? And in that case what would be a better solution?