Java Aspect-Oriented Programming with Annotations

后端 未结 5 1632
無奈伤痛
無奈伤痛 2020-11-30 16:57

In a post entitled \"AOP Fundamentals\", I asked for a King\'s English explanation of what AOP is, and what it does. I received some very helpful answers and links

5条回答
  •  再見小時候
    2020-11-30 17:32

    Some months ago I wrote an article with an example on how I implemented a practical case of combining Aspect/J aspects with Java annotations, that you may find useful:

    http://technomilk.wordpress.com/2010/11/06/combining-annotations-and-aspects-part-1/

    I believe aspects applied to annotations make a good combination because they make the aspect more explicit in your code, but in a clean way, and you can use parameters in your annotations for further flexibility.

    BTW the way Aspect/J works is by modifying your classes at compile time, not at run time. You run your sources and aspects through the Aspect/J compiler and it creates the modified class files.

    Spring AOP, as far as I understand it, does the weaving (manipulating the class files to include aspect processing) in a different way, by creating proxy objects, I believe that at instantiation time (but don't take my word for it).

提交回复
热议问题