Search code examples
springejbjavabeansstateless

Spring equivalent of EJB Stateless bean


In EJB because of performance reasons beans should be stateless, then application server can maintain pool of beans and assign them to requesting clients.

What is Spring equivalent for such type of beans? In Spring we've got other scopes of beans: singleton, prototype, request, session, global session.


Solution

  • Each Spring bean should be implemented statelessly as a singleton. Do not introduce state into a singleton bean. There is no real benefit from pooling in such an architecture.