TogetherOS / cicada

🚀 Fast lightweight HTTP service framework.
https://crossoverjie.top/categories/cicada/
Apache License 2.0
953 stars 212 forks source link

一直不明白没用aop 如何实现拦截注解实现功能 #1

Closed leetomlee123 closed 6 years ago

leetomlee123 commented 6 years ago

飞机

crossoverJie commented 6 years ago

@leetomlee123 可以看看 Cicada 的实现。

https://github.com/crossoverJie/cicada/blob/0f1023859a09f76a0266db7f8fe47672105fbff9/cicada-core/src/main/java/top/crossoverjie/cicada/server/handle/HttpHandle.java#L62-L70

不过当前只实现了拦截默认 action。

Spring 这样的是根据 动态代理 实现的,Cicada 后续也会加入这样的特性,请持续关注。

chenshun00 commented 6 years ago

@leetomlee123 Spring aop 也只是在方法的执行前添加了一个 List 列表而已,原理还是一致的,增加拦截器列表应该也有同样的效果,我也根据Spring的aop写了一个小小的动态代理