Hi Guys
I wanted to try and illustrate the difference between the two types of beans for myself, so I created a couple of classes and remote interfaces as follows:
I then exposed the call() methods through a web service and invoked each of them four times. My output (in the Glassfish log) was as follows:
INFO: Stateless bean: 1
INFO: Stateful bean: 1
INFO: Stateless bean: 2
INFO: Stateful bean: 2
INFO: Stateless bean: 3
INFO: Stateful bean: 3
INFO: Stateless bean: 4
INFO: Stateful bean: 4
I was expecting the stateful bean's counter to be incremented with each call, but I didn't expect the stateless bean to do the same - I thought that it would essentially lose track of whatever state it was in (i.e. that it would be lost after being invoked, and that the next call would get a new instance). What am I missing?
Cheers,
Riaan