当前位置:网站首页>Proceedingjoinpoint API use

Proceedingjoinpoint API use

2022-07-06 14:21:00 Code siege lion

 @Around("myPointcut()")
    public Integer AroundSave(ProceedingJoinPoint joinPoint) throws Throwable {
    
        /*1、 Get the parameters of the target method :save(new User()), here user Object can get */
        Object[] args = joinPoint.getArgs();
        System.out.println(" This is a joinPoint Of Api Start --------------------");
        System.out.println(" Print target method parameter list args ="+ Arrays.toString(args));
        /*2、 You can get the reflection object of the target method Method*/
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method method = methodSignature.getMethod();
        System.out.println(" Get the object name of the target method :"+method);
        /*2.1、 from method Reflection objects get basic information */

        Class<?> declaringClass = method.getDeclaringClass();
        String className = declaringClass.getName();
        System.out.println(" Get the name of the class "+className);



        System.out.println(" Surround notification begins ");


         Integer result= (Integer) joinPoint.proceed();

        System.out.println(" End of surround notification ");
        return result;
    }

 Insert picture description here

原网站

版权声明
本文为[Code siege lion]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131404131369.html