This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am accessing an EJB module from an external web module. The process is comprised of two phases. The first phase ends when a method call of a stateful session bean returns its value to the web module and that point onwards the second phase starts. Phase 02 needs to invoke another method of the same stateful session bean instance as the previous phase.
Is it possible to consider both the phases as one session in an EJB perspective? If yes, how do I make sure if the stateful session bean instance which is being accessed in phase 02 is same as the instance which is being accessed in phase 01? Or else will I have to consider two phases as two different EJB sessions?
Thanks in advance.
"Simplicity is the ultimate sophistication..." ~Leonardo da Vinci~
Stateful session beans are designed for the specific use-case you are mentioning. You don't have to do anything else other than to make sure you hold on to the same stateful session bean reference across calls.
Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1