Reputation: 75
I have the following EJB singleton:
@Singleton
public class MySingleton {
@Lock(LockType.WRITE)
public void doSomethingWrite(){
//code that writes something to DB
}
@Lock(LockType.READ)
public void doSomethingRead(){
//code that READS something from DB
}
@Lock(LockType.READ)
public void doSomethingReadButCanDoWrite(){
if(somethingDoesNotExistInDB()){
doSomethingWrite(); // <-- My question is about this call.
}
doSomethingRead();
}
}
My question, is the call doSomethingWrite()
performed with LockType.WRITE
as declared on the target method or with LockType.READ
as declared on the enclosed method?
Upvotes: 0
Views: 195
Reputation: 618
In that case, the call is a local call, it is not an EJB method call, because of this, it does not apply any EJB concern.
There is a way to configure the application server to make this kind of direct calls pass through the EJB context, but those configurations are vendor specific.
If you want to do this call as an EJB method call an use the EJB context you can use it through an EJB instance, in this case, the method will apply its own lock (WRITE lock)
I hope have been clear enough.
Upvotes: 2