Spring Stateful vs Stateless beans
Based on my (little) understanding, the way to expose a Spring bean remotely via webservices is to have a wrapper webservice end-point and have it lookup the spring bean via the webapplicationContext.
My question is: Say I have a remote client making a web service call to such a wrapper end-point, which in turn deligates to the spring bean. How is statefulness acheived in this case? The wrapper endpoint is by itself stateless - so when it looks up a spring bean - it will get a new instance of the spring bean each time (assuming scope=prototype). What is the technique to make sure that the client interacts with the same instance of the spring bean across multiple webservice calls?
One way I can think of is - in the webservice endpoint (which is really a servlet) - store the ref to the spring bean in session - and if I have a ref in the session use it, else get a new one from the webappcontext and store it in session for future interactions.