1 22 package org.jboss.aspects.txlock; 23 24 import org.jboss.aop.joinpoint.Invocation; 25 import org.jboss.logging.Logger; 26 27 import javax.transaction.Transaction ; 28 import javax.transaction.TransactionManager ; 29 30 37 public class TxLockInterceptor implements org.jboss.aop.advice.Interceptor 38 { 39 42 protected Logger log = Logger.getLogger(this.getClass()); 43 44 private final TransactionManager tm; 45 private final QueuedTxLock lock; 46 47 public TxLockInterceptor(TransactionManager tm, QueuedTxLock lock) 48 { 49 this.tm = tm; 50 this.lock = lock; 51 } 52 53 public String getName() 54 { 55 return "TxLockInterceptor"; 56 } 57 58 61 public Object invoke(Invocation invocation) throws Throwable 62 { 63 Transaction tx = tm.getTransaction(); 64 if (tx == null) return invocation.invokeNext(); 65 66 else 67 { 68 } 69 70 71 lock.schedule(tx, invocation); 72 try 73 { 74 return invocation.invokeNext(); 75 } 76 finally 77 { 78 lock.endInvocation(tx); 79 } 80 } 81 82 83 } 84 | Popular Tags |