/** * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface. * Copyright (C) 2012 Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /******************************************************************************\ * * This product was developed by * * SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), * * a government company established under Brazilian law (5.615/70), * at Department of Development of Porto Alegre. * \******************************************************************************/ package serpro.mailarchiver.util.transaction; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource; import org.springframework.transaction.aspectj.AbstractTransactionAspect; @Aspect public class AnnotationTransactionAspect extends AbstractTransactionAspect { public AnnotationTransactionAspect() { super(new AnnotationTransactionAttributeSource(false)); } /** * Matches the execution of any public method in a type with the * Transactional annotation, or any subtype of a type with the * Transactional annotation. */ @Pointcut("execution(public * ((@Transactional *)+).*(..)) && @this(org.springframework.transaction.annotation.Transactional)") private void executionOfAnyPublicMethodInAtTransactionalType() {} /** * Matches the execution of any method with the * Transactional annotation. */ @Pointcut("execution(* *(..)) && @annotation(org.springframework.transaction.annotation.Transactional)") private void executionOfTransactionalMethod() {} /** * Matches the execution of any method with the * WithReadOnlyTx annotation. */ @Pointcut("execution(* *(..)) && @annotation(serpro.mailarchiver.util.transaction.WithReadOnlyTx)") private void executionOfWithReadOnlyTxMethod() {} /** * Matches the execution of any method with the * WithReadWriteTx annotation. */ @Pointcut("execution(* *(..)) && @annotation(serpro.mailarchiver.util.transaction.WithReadWriteTx)") private void executionOfWithReadWriteTxMethod() {} /** * Definition of pointcut from super aspect - matched join points * will have Spring transaction management applied. */ @Pointcut("(executionOfAnyPublicMethodInAtTransactionalType()" + "||executionOfTransactionalMethod()" + "||executionOfWithReadOnlyTxMethod()" + "||executionOfWithReadWriteTxMethod()" + ")" + "&& this(txObject)") protected void transactionalMethodExecution(Object txObject) {} }