V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
wangsilence
V2EX  ›  程序员

Spring Cache、Async AOP 实现疑问

  •  
  •   wangsilence · Jan 14, 2021 · 1738 views
    This topic created in 1929 days ago, the information mentioned may be changed or developed.

    为什么 Spring Cache 、Async AOP 实现都自己实现了 Advisor 、Advice 、Pointcut, 为什么不直接用 @Aspect 表达式,直接拦截注解,剩了很多代码,Advisor 、Pointcut 都不用写。 更简单的方式不用,为什么要这么复杂实现?

    @Aspect
    @Component
    public class Aspect {
    
        @Pointcut("@annotation(com.xxx.Cache)")
        public void pointcut() {
        }
    
        @Around(value = "pointcut() && @annotation(cache)")
        public Object imMonitorAround(ProceedingJoinPoint pjp, Cache cache) throws Throwable {
            String methodKey = imMonitor.value();
            return pjp.proceed();
        }
    }
    
    1 replies    2021-01-15 09:23:21 +08:00
    ychost
        1
    ychost  
       Jan 15, 2021
    Aspect 表达式必须强制要求启动的时候指定 Aspect 的 Processor 吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1137 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 23:07 · PVG 07:07 · LAX 16:07 · JFK 19:07
    ♥ Do have faith in what you're doing.