According to clean code by Robert C. Martin methods should have a small signature. The best case would be a method with no parameters at all. Instead it is recommended to use state variables. This is really useful. But what about stateless session beans?
The name is kind of confusing because SLSB can have state. You just have to do your housekeeping so you don't use state from the previous EJB call.
Getting back to clean code: I'd love to use instance variables in SLSBs too. This works fine and if you're careful enough you don't have any trouble with state inconsistencies since the state is overwritten on each public method call.
So far so good. But what happens if a used bean goes back to the pool? It takes its state with it. Depending on the size of the state this could be a real memory leak. JBoss is very generous with beans and generates quite a bunch of them causing some serious memory consumption - for nothing.
So one way would be to clean up the state before the bean method exists and the bean is returned to the pool. But this seems to me like useless code that should be avoided.
Is there a proper way to deal with this problem? What's the best practice in this situation?