/** * */ package org.jfraney.aspects; import javax.ejb.TransactionAttribute; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; @Aspect public class TransactionManager { @Pointcut("(execution(@javax.ejb.TransactionAttribute * *.*(..)) && this(attr))") void transactedMethod(javax.ejb.TransactionAttribute attr) {} @Before("transactedMethod(attr) ") public void beforeTransaction(TransactionAttribute attr) { System.out.println("before transaction"); } @AfterReturning("transactedMethod(attr)") public void afterTransaction(TransactionAttribute attr) { System.out.println("after transaction"); } @AfterThrowing(pointcut="transactedMethod(attr)", throwing="RuntimeException") public void failedTransaction(TransactionAttribute attr) { System.out.println("failed transaction"); } /* * The following pointcut and advice run without exception * Commented out to temporarily disable. * @Pointcut("(execution(@javax.ejb.TransactionAttribute * *.*(..)))") void transactedMethod() {} @Before("transactedMethod() ") public void beforeTransaction() { System.out.println("before transaction"); } @AfterReturning("transactedMethod()") public void afterTransaction() { System.out.println("after transaction"); } @AfterThrowing(pointcut="transactedMethod()", throwing="RuntimeException") public void failedTransaction() { System.out.println("failed transaction"); } */ }