This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
And All the components in a server side managed environment are thread safe. Because in a managed environment we can't use multiple threads.
Joined: Jun 07, 2011
I think I'd to clarify my question:
PrinciplaBean is a Singleton (see code above), so on a heavy load machine the method "getPrincipal()" can be called simultaneously by two or more users (=threads). Each thread uses the same "ejbContext" (because it's a private member in a sigleton) to call "getCallerPrincipal()".
Without the @ConcurrencyManagement(ConcurrencyManagementType.BEAN) annotation there will be a write lock on "getPrincipal()" and then there's no concurrency problem, but this will not scale on a heavy load machine. So I decided to remove the lock.
So my question: Is ejbContext.getCallerPrincipal() threadsafe (in the way, that one (single) instance of ejbContext is called simultaneously by two or more users? Or in other words does getCallerPrincipal() return the proper principal?