Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. How can I do this? Thanks.

like image 260
Stan Kurilin Avatar asked Feb 24 '26 23:02

Stan Kurilin


1 Answers

// 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. 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.

like image 145
Sean Patrick Floyd Avatar answered Feb 26 '26 12:02

Sean Patrick Floyd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!