1 22 package org.jboss.aspects.tx; 23 24 import org.jboss.aop.joinpoint.FieldReadInvocation; 25 import org.jboss.aop.joinpoint.FieldWriteInvocation; 26 import org.jboss.tm.TransactionLocal; 27 28 43 public class TransactionLocalAspect 44 { 45 private TransactionLocal txLocal = new TransactionLocal(); 46 47 public Object access(FieldReadInvocation invocation) throws Throwable 48 { 49 if (txLocal.getTransaction() == null) return invocation.invokeNext(); 51 52 if (txLocal.get() == null) 54 { 55 txLocal.set(invocation.invokeNext()); 56 } 57 return txLocal.get(); 58 } 59 60 public Object access(FieldWriteInvocation invocation) throws Throwable 61 { 62 if (txLocal.getTransaction() == null) return invocation.invokeNext(); 64 65 txLocal.set(invocation.getValue()); 66 return null; 67 } 68 } 69 | Popular Tags |