Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB and other Java EE Technologies and the fly likes Scope of an EJB session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Scope of an EJB session" Watch "Scope of an EJB session" New topic
Author

Scope of an EJB session

Anuradha Karunamuni
Ranch Hand

Joined: Dec 08, 2007
Posts: 64
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~
SCJP 1.4
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
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


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Anuradha Karunamuni
Ranch Hand

Joined: Dec 08, 2007
Posts: 64
It worked...Thanks.
 
Consider Paul's rocket mass heater.
 
subject: Scope of an EJB session
 
Similar Threads
Like to Share the knowledge
long post IBM.158
Some question I Like to Share with All of you
HFEJB: Pg 516, Question# 1
Tricky question (How to pass javax.ejb.Handle)