一、自定义注解
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface AroundInterceptor {
String value() default "";
}
二、切面方法
@RestController
public class MyController(){
@AroundInterceptor
public void mythod(){
}
}
三、业务处理
@Component
@Aspect
public class MyAspect(){
@Pointcut("@annotation(com.mollen.demo.interceptors.AroundInterceptor )")
public void sendMsgAfterReturnAdvice() {
}
@Around("sendMsgAfterReturnAdvice()")
public void aspectService(JoinPoint jp){
MethodSignature signature = (MethodSignature) jp.getSignature();
AroundInterceptor annotation = signature.getMethod().getAnnotation(AroundInterceptor .class);
String value = annotation.value();
Object[] args = jp.getArgs();
}