spring op 트 랜 잭 션 알림 (절단면 이상 처리)

2454 단어 JavaEE
Spring Aop        ,     spring aop   service         ,                       service    ,   spring aop         。
   :    spring-context.xml   Aspectj    ,                 ,    。


   :     spring aop        ,     aop  ,         @Aspect         。
/**
 *    
 * @author Anson
 */ 
@Component
@Aspect
public class AopThrowsAdvice {
     private Logger logger = LoggerFactory.getLogger(getClass());
     @Autowired
     private AopServiceComm aopServiceComm; //   service 
     @Autowired
     private SqlSessionFactory sqlSessionFactory;
     
     /**
     *    -             
     */
     @Before("execution(* com.casking.cdds.modules.task.service.*.*(..))")
     public void beforeMethod(JoinPoint joinPoint) {
	   Object object = joinPoint.getSignature();
	   String methodName = joinPoint.getSignature().getName();
	   List list = Arrays.asList(joinPoint.getArgs());
	   if (logger.isDebugEnabled()) {
		logger.debug("======================    ======================");
		logger.debug(DateUtils.formatDateTime(new Date()) + "   【" + object + "      ......】");
	   }
	   //            ,   
	   this.aopServiceComm.saveLogInfo(null,methodName,CommonVariate.TASK_SAVE_STARTONE);
     }
      /**
     *    -    
     */
     @AfterThrowing(value = "execution(* com.casking.cdds.modules.task.service.*.*(..))", throwing = "e")
     @Transactional(propagation=Propagation.NOT_SUPPORTED)
     public void afterThrowing(JoinPoint joinPoint, Exception e) {
	   String methodName = joinPoint.getSignature().getName();
	   if (logger.isDebugEnabled()) {
		logger.info(methodName, e.toString() + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 	   


     	  

  :         spring     ,         ,  spring aop     ,order       ,            sql。                  sql,            ,         ,        。
@Transactional(propagation=Propagation.NOT_SUPPORTED)

좋은 웹페이지 즐겨찾기