AspectJ - why use annotations instead of ajc compiler?

We can use the @AspectJ annotation style to define aspects, as well as the AspectJ Java extension language, which requires us to use the ajc compiler.

What are the reasons to use annotation style instead of ajc? It seems to me that many functions refuse to use the annotation style, but not much (if anything) is obtained, except that you do not need to use ajc (what's wrong with using ajc?)

Can someone please enlighten me on this topic?

+4
source share
2 answers

Both styles ( .aj and @AspectJ ) have functions that others cannot do.

See this post for something that annotations can do that declarative AspectJ cannot: What is the declarative AspectJ syntax for rewriting an argument

.Aj files for the most part (other than those mentioned above) can do more. The most noteworthy they can do is ITD (Inter-Type-Definitions aka adding methods and properties to classes).

The biggest reason you would like to use @AspectJ is that even if you use WOP Spring proxy AOP support, it doesn't even require compilation of time (CTW) or even load time (LTW). Spring will mimic @AspectJ, but at runtime, creating a proxy.

I noticed that Spring, Eclipse (and I) seem to encourage greater use of true AspectJ. I believe this is because the Eclipse plugin has become so good. Also with true AspectJ and @Configurable annotation you can get Spring wiring to beans instance. Here's how Spring Roo works.

With the Eclipse AspectJ IDE plugin, you can see pointcut links for both styles (@ and aj) and get a very clear idea of ​​what the β€œmagic” is about.

+4
source

Adding an extra step to the build process is not the easiest and most convenient way. Especially when you have a big project. You walk away from all java tools and IDE support that may not support * .aj syntax.

+2
source

All Articles