Search code examples
javaejb-3.0stateful

EJB: what does maintaining state across method calls mean?


"Stateful: These beans can hold client state across method invocations. This is possible with the use of instance variables declared in the class definition. The client will then set the values for these variables and use these values in other method calls."

What does maintaining state across method calls mean ?

sorry for the noobness of my question.


Solution

  • You can think of it as the HttpSession on a web application. What you save on HttpSession is available across different requests to the web server. Likewise what you store as class variables in a session EJB is available across different method invocations done on the same session EJB.

    Refer:

    Lookup returns new instance of Stateful session bean http://www.javaworld.com/article/2071724/java-web-development/ejb-fundamentals-and-session-beans.html