有哪些网站可以做视频,申请企业邮箱需要什么,网站html下载,酒店网络推广方案连接点
在Spring中用JoinPoint抽象了连接点#xff0c;用它可以获取方法执行时的相关信息#xff0c;如目标类名、方法名、方法参数等 对于Around通知#xff0c;获取连接点信息只能使用 ProceedingJoinPoint对于其它四种通知#xff0c;获取连接点信息只能使用JoinPoint用它可以获取方法执行时的相关信息如目标类名、方法名、方法参数等 对于Around通知获取连接点信息只能使用 ProceedingJoinPoint对于其它四种通知获取连接点信息只能使用JoinPoint它时是ProceedingJoinPoint的父亲类型具体代码如下 package com.example.tlias.AOP;import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
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.annotation.Pointcut;
import org.springframework.stereotype.Component;import java.util.Arrays;Component
Aspect
Slf4j
public class TestJoinPoint {Pointcut(execution(* com.example.tlias.service.DeptLogService.*(..)))public void PointCut() {}Before(PointCut())public void before(JoinPoint joinPoint) {log.info(TestJointPoint...before...);// 1.获取目标对象类名String ClassName joinPoint.getTarget().getClass().getName();log.info(目标对象类名{}, ClassName);// 2.获取目标对象方法名String Methodname joinPoint.getSignature().getName();log.info(目标对象的方法名{}, Methodname);// 3.获取目标方法运行时传入的参数Object[] args joinPoint.getArgs();log.info(目标方法时传入的参数{}, Arrays.toString(args));}Around(PointCut())public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {log.info(TestJointPoint...around...);// 1.获取目标对象类名String ClassName proceedingJoinPoint.getTarget().getClass().getName();log.info(目标对象的类名是{}, ClassName);// 2.获取目标对象方法名String MethodName proceedingJoinPoint.getSignature().getName();log.info(目标对象的方法名{}, MethodName);// 3.获取目标方法运行时传入的参数Object[] args proceedingJoinPoint.getArgs();log.info(目标方法运行时传入的参数{}, Arrays.toString(args));// 4.放行目标方法执行Object result proceedingJoinPoint.proceed();// 5.获取目标方法的返回值log.info(目标方法运行的返回值{}, result);log.info(TestJointPoint around after....);return result;}
}