I have EJB with two methods
@Singleton(name = "RatingCalculatorEJB")
public class RatingCalculatorBean {
public void countRating() {}
public void countRating(int someID) {}
}
By default all methods has concurrency lock: @Lock(LockType.WRITE) If method invoked by any thread - another thread will wait to invoke this method.
But I need more - if any method invoked by a thread, all other threads that call any method of EJB should wait. Does I have any way to do it?
The same question for @Stateless beans
@Lock(LockType.WRITE) locks ALL EJB methods of the bean, so it already does what you want.
Stateless beans only handle one client at a time, so concurrency should rarely be a problem there.