AOP Introduction理解

一、基本使用

Introduction引入:可以为某个或某些bean 动态实现某个接口。

@Aspect
class SingerIntroducer {           
     @DeclareParents(value="com.mengxiang.concert.Performance+", defaultImpl = BackSinger.class) public static Singer singer; }

这样所有实现Performance接口的Bean ,代理对象都实现了Singer接口
使用时强制转换下即可 (Singer)bean

二、场景?

参考:

https://www.jianshu.com/p/d1363a376ae8

https://my.oschina.net/zudajun/blog/663962

猜你喜欢

转载自www.cnblogs.com/yangfei629/p/13382200.html