jakarta-eeejbstatestateful-session-bean

How EJB 3.X Stateful session bean maintains state?


I am kind of new to EJB. I have understanding how HTTPSession is maintained (all cookies funda). All the resource in the internet says " Stateful Session Bean Maintenance session(remembers client). But I could not find answer to

How Stateful Session maintenance state ?

Oracle docs says

The state of an object consists of the values of its instance variables. In a stateful session bean, the instance variables represent the state of a unique client/bean session. Because the client interacts (“talks”) with its bean, this state is often called the conversational state.

Thanks.


Solution

  • Instance is created when you first get a reference to the bean and you can only use this reference to maintain state through. Instance is destroyed when you call the method annotated with @Remove or the bean instance times out.

    Source, the EJB JSR : download.oracle.com/otndocs/jcp/ejb-3.1-pfd-oth-JSpec. Chapter 4.6