0 Replies Latest reply on Dec 7, 2013 3:05 PM by Jonathan Fields

    The order of lock and transaction in @Singleton

    Jonathan Fields Novice

      It appears that for a @Singleton, that the transaction is started, the lock acquired, and upon return, the lock released and transaction committed. That seems somewhat backward to me, and indeed does not work for my use case (serializing updates to a JCR node in Modeshape)

       

      Is there any way to reconfigure the ordering on @Singleton? If not, would be it feasible to implement the behavior that I desire (acquire lock, start tx, ... do work..., commit tx, release lock) using EJB interceptors? For example, create my own transaction interceptor that injects UserTransaction using @Resource, and my own locking interceptor that uses java.util.concurrent.locks.ReentrantLock? Would that be a safe thing to do - I've not delved into interceptors yet....

       

      Thanks!