zoukankan      html  css  js  c++  java
  • springboot最简单的AOP

    package com.yitiantec.ecommerce.admin.config;


    import java.lang.reflect.Method;
    import org.aspectj.lang.JoinPoint;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Before;
    import org.aspectj.lang.annotation.Pointcut;
    import org.aspectj.lang.reflect.MethodSignature;
    import org.springframework.context.annotation.Configuration;

    import com.yitiantec.ecommerce.admin.util.XinyuanJSONUtil;

    import lombok.extern.slf4j.Slf4j;

    @Aspect //一个切面
    @Configuration // spring boot 配置类
    @Slf4j
    public class RequestParamValidAspect {

    @Pointcut("execution(* com.yitiantec.demo.pay.controller.*.*(..))")
    public void soaServiceBefore(){}

    /* * 通过连接点切入 */
    @Before("soaServiceBefore()")
    public void twiceAsOld1(JoinPoint point) {
    // 获得切入目标对象
    Object target = point.getThis();
    // 获得切入方法参数
    Object [] args = point.getArgs();
    // 获得切入的方法
    Method method = ((MethodSignature)point.getSignature()).getMethod();

    log.info("AOP 进入方法"+method);
    log.info("APO 收到参数="+XinyuanJSONUtil.gSonString(args));
    }
    }

  • 相关阅读:
    Vivian's Problem UVA
    Prime k-tuple UVA
    M
    Make a Crystal UVA
    Cryptography Reloaded UVALive
    Gauss Prime UVA
    Discrete Square Roots UVALive
    The Bells are Ringing UVALive
    Huge Mods UVA
    指数循环节
  • 原文地址:https://www.cnblogs.com/laixin09/p/10109191.html
Copyright © 2011-2022 走看看