-
1. Re: Performance impact of injecting javax.ejb.Singleton vs javax.inject.Singleton
atomicknight Nov 22, 2012 3:14 AM (in response to troup)By default, singleton session beans are transactional (section 13.3.7 of the EJB 3.1 specification) and require acquisition of an exclusive lock for every business method invocation (sections 4.8.5.4 and 4.8.5.5). In contrast, a javax.inject.Singleton is not transactional and does not support container-managed concurrency (the major consequence being that no locking scheme is implemented by the container).
If you annotate your singleton session bean with @TransactionAttribute(NOT_SUPPORTED) and @Lock(READ), you should see significantly better performance, though there may still be some overhead. If you don't need EJB features, stick with @ApplicationScoped (javax.inject.Singleton is not defined by CDI, and its semantics are therefore not governed by that specification).
-
2. Re: Performance impact of injecting javax.ejb.Singleton vs javax.inject.Singleton
troup Nov 22, 2012 3:32 AM (in response to atomicknight)Thanks for the info. I had already annotated the singleton session bean with @Lock(READ) but not @TransactionAttribute(NOT_SUPPORTED). Since I don't need EJB features I will stick to @ApplicationScoped.