Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scope of an EJB session

 
Anuradha Karunamuni
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anuradha,

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.

Regards,
Reza
 
Anuradha Karunamuni
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked...Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic