ares
ares

Reputation: 4413

ejb - Singleton lock mode when calling methods of same instance?

Here is my singleton class:

import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Singleton;


@Singleton
public class TestSingletons implements TestSingletonsRemote{

    @Lock(LockType.READ)
    @Override
    public void foo(int id) {
        bar(id);
    }


    private void bar(int id){
        // do stuff
    }

}

The method foo has a LockType.READ, so it can be accessed concurrently. foo actually does nothing but calls a private method of the class bar which is not annotated, so by default It should have a LockType.WRITE lock mode.

The question, as you might guess from the above scenario, is: Will the call to foo be practically concurrent?

Upvotes: 1

Views: 1437

Answers (1)

Amila
Amila

Reputation: 5213

Your bar method is private, it's not a business method.

Default LockType.WRITE is only applicable for business methods.

Upvotes: 4

Related Questions