Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top