CRUDService is no longer a Singleton (avoiding concurrency issues). @Stateless beans however, default to RequestScoped, which is too short a lifetime for the EntityManager. Since the EM is held in the Producer (and no longer implicitly in the CRUDService), we prolong the lifetime of the Producer to ConversationScoped. (And explicitly extend that to what amounts to SessionScoped for JSF.)
So much functional for so little code change. I'm impressed and scared at the same time.
CRUDService
is no longer a Singleton (avoiding concurrency issues).@Stateless
beans however, default toRequestScoped
, which is too short a lifetime for theEntityManager
. Since the EM is held in the Producer (and no longer implicitly in theCRUDService
), we prolong the lifetime of the Producer toConversationScoped
. (And explicitly extend that to what amounts to SessionScoped for JSF.)So much functional for so little code change. I'm impressed and scared at the same time.