Stan Kurilin
Stan Kurilin

Reputation: 15792

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.

Upvotes: 3

Views: 1002

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298838

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

Upvotes: 2

Related Questions