2
votes

I am reading a book on JPA and EJB and it has a line there stating:

"Singleton session beans can use container-managed or bean-managed concurrency. The default is container-managed, which corresponds to a write lock on all business methods. All business method invocations are serialized so that only one client can access the bean at any given time. The actual implementation of the synchronization process is vendor-specific."

What does it mean by method invocation being serialized and why does that guarantee only one client can access the bean at any given time?

1
Here, "serialized" is synonymous to "sequential" order of invocation. - Amitesh Rai

1 Answers

5
votes

By "serialized" they mean "done one at a time" (so don't get that confused with Object Serialization).

Each Singleton Session Bean has a single lock associated with it that can be used by one client at a time. So if you are using the Singleton Session Bean and have the write lock, I can't use it and must wait. Once you release your lock, I will (presumably) grab it and be able to use it, making anybody else who wants to use it wait until I release the lock.

Edit: I found a pretty good explanation of Singleton Session Bean locks and how/when to use them.