Thursday, April 7, 2016

EJB : Stateless vs Singleton

http://stackoverflow.com/questions/14464823/difference-between-stateless-and-singleton and in particular this answer
http://docs.oracle.com/javaee/6/tutorial/doc/gipjg.html#gipmt
The EXCELLENT book "Beginning EJB 3: Java EE 7 Edition" (that I highly recommend to buy) explains it very well:
"Introduced in EJB 3.1, a singleton session bean is a session bean component that is instantiated only once per application. For an application, only one instance of a singleton session bean can ever exist. Once instantiated, a singleton session bean lives for the full duration of the application. The singleton session bean maintains its state between client invocations, but it cannot save that state after a container shutdown or crash. Similar to stateless and stateful session beans, the singleton session bean is comprised of a bean class and, optionally, one or more business interfaces."


https://docs.oracle.com/javaee/6/api/javax/ejb/Singleton.html
http://docs.oracle.com/javaee/6/api/javax/ejb/Stateless.html


No comments: