zoukankan      html  css  js  c++  java
  • Java spring aop Around

    package com.hh.aop;

    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Around;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Before;
    import org.aspectj.lang.reflect.MethodSignature;
    import org.springframework.stereotype.Component;

    @Aspect
    @Component
    public class LogAop {

    // private EntityManager entityManager;

    @Around("execution(* com.hh.controller..*.*(..))")
    public Object aopController(ProceedingJoinPoint joinPoint) throws Throwable {

    System.out.println("around");
    //获取方法参数值数组
    Object[] args = joinPoint.getArgs();
    //得到其方法签名
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    //获取方法参数类型数组
    Class[] paramTypeArray = methodSignature.getParameterTypes();
    System.out.println(methodSignature.getParameterNames());
    System.out.println(paramTypeArray);
    Object result = joinPoint.proceed(args);
    System.out.println("=====checkSecurity====");

    for (int i = 0; i < joinPoint.getArgs().length; i++) {
    System.out.println(joinPoint.getArgs()[i]);
    }
    System.out.println(joinPoint.getSignature().getName());



    return result;
    }
    }
  • 相关阅读:
    2017普及组D1T3 洛谷P3956 棋盘
    2017提高组D1T1 洛谷P3951 小凯的疑惑
    Title
    Title
    Title
    Title
    Title
    Title
    Title
    Title
  • 原文地址:https://www.cnblogs.com/honghong75042/p/14274344.html
Copyright © 2011-2022 走看看