简体   繁体   English

带有匿名内部类的Spring AOP

[英]Spring AOP with anonymous inner classes

I use some anonymous inner classes like 我使用了一些匿名的内部类

foo(){
      A a = new A(arg1){   //it isn't spring bean yet
           public Smt bar(){
                return new Smt();
           }
      }
 }

And now I want add some AOP wrapping for this class. 现在我想为这个类添加一些AOP包装。 How can I do this? 我怎样才能做到这一点? Thanks. 谢谢。

// it isn't spring bean yet //它还不是春豆

I guess that implies that it will at some time be a spring bean? 我想这意味着它在某个时候会成为一个春豆? Then just use Spring AOP . 然后只使用Spring AOP It should work equally well on anonymous inner classes. 它应该在匿名内部类上同样有效。 After all they have names and packages just like any other class. 毕竟他们的名字和包就像任何其他类一样。

If not, you will probably have to use aspectj compiling or loadtime weaving. 如果没有,您可能必须使用aspectj编译或加载时编织。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM