Handle multiple EntityManager in Java EE application
I have Java EE application with about 10 EntityManagers (number of EMs will probably increase). My application also contains many stateless, statefull and message driven beans. Rather than inject in each bean my EMs with @PersistenceContext (and 2 methods to detect which EM to use for user), I probably store all of that inside a singleton bean and access it with others beans. Like that, no worries about maintainability. Nevertheless, is it thread-safe to store EMs inside one singleton bean? Can a bottleneck appear? Another solution is to create an abstract class and all beans will extend it.