麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

Spring 的幾種AOP通知

2019-11-10 20:26:51
字體:
來源:轉載
供稿:網友

 

package com.carry.sPRing.beans.aop;

 

import java.awt.List;

import java.util.Arrays;

 

import org.aspectj.lang.JoinPoint;

import org.aspectj.lang.annotation.After;

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.springframework.stereotype.Component;

 

 

@Component  //是個bean

@Aspect           //是個切面

public classLogging {

       

        /**

         * 在包 com.carry.spring.beans.aop.ArithmeticInterface接口的每一個實現類的每一個方法之前打印一句日志

         *

         * */

       

        @Before("execution(public intcom.carry.spring.beans.aop.ArithmeticInterface.*(..))")

        public void beforeMethod(JoinPoint joinpoint){

                StringmethodName=joinpoint.getSignature().getName();    //得到當前方法的名字 

                Object[] args=joinpoint.getArgs();                        //得到方法的參數

                System.out.println("The Method:"+methodName+" begin "+Arrays.asList(args));

        }

       

       

        /**

         * 在包 com.carry.spring.beans.aop.ArithmeticInterface接口的每一個實現類的每一個方法之后打印一句日志,無論是否異常出錯

         *

         * */

       

        @After("execution(public intcom.carry.spring.beans.aop.ArithmeticInterface.*(..))")

        public void afterMethod(){

               

                System.out.println("The Method end");

        }

 

/**

 * 返回通知,在方法正常結束后執行的代碼,有異常不顯示

 * 可以訪問方法的返回值

 *

 * */

       

        @AfterReturning(value="execution(public intcom.carry.spring.beans.aop.ArithmeticInterface.*(..))",

                        returning="res")

        public void returnMethod(JoinPoint joinPoint,Objectres){

                String  mathodName=joinPoint.getSignature().getName();

                System.out.println("The Method returnMethod"+".."+mathodName+".."+res);

        }

        /**

         * 異常通知

         *

         *

         * */

               

                @AfterThrowing(value="execution(public intcom.carry.spring.beans.aop.ArithmeticInterface.*(..))",

                                throwing="thr")

                publicvoid returnMethod(JoinPoint joinPoint,Exception thr){

                        String  mathodName=joinPoint.getSignature().getName();

                        System.out.println("The Method returnMethod"+".."+mathodName+".."+thr);

                }

       

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产毛片毛片毛片 | 久久亚洲精品国产一区 | av电影网在线观看 | 成人性视频欧美一区二区三区 | 91精品国产综合久久婷婷香蕉 | 国产91精品亚洲精品日韩已满 | 91av亚洲| 成人h视频在线 | 中日韩免费视频 | 国产精品爆操 | 全免费午夜一级毛片真人 | 日韩精品中文字幕一区二区 | 少妇一级淫片免费放正片 | 欧美一级淫片a免费播放口 91九色蝌蚪国产 | 日本一区二区视频在线观看 | 久久久久久免费 | 中国国语毛片免费观看视频 | 精品国产91久久久久久浪潮蜜月 | 粉嫩蜜桃麻豆免费大片 | 中文字幕观看 | 欧美爱爱一区二区 | 国产宾馆3p国语对白 | 91美女视频在线观看 | 欧美一级高潮 | 中文字幕一区久久 | 亚洲成人精品区 | 在线成人免费观看www | 欧美一级爱爱 | 中文字幕观看 | 国产精品视频成人 | 国产亚洲自拍一区 | 欧美激情第一区 | 性欧美一区二区 | 久久精品视频一区 | 国产精品久久久久久影视 | 黄色网址免费进入 | 久久99久久98精品免观看软件 | 国人精品视频在线观看 | 黄色片网站在线免费观看 | 色啪综合 | 成人性生活视频在线观看 |