Spring AOP
I was doing some Spring AOP stuff the other day using @AspectJ style annotations. One of the limitations of Spring AOP is that it supports only method level interception. We cannot intercept Constructors or fields. For that we'll have to use AspectJ, and different compilers may be - for load time weaving or compile time weaving. I decided to stick to Spring restrictions though.
Here are a couple of cheatsheets/examples for AspectJ. (Remember Spring AOP has limitations, but AspectJ doesn't).
- An excellent cheat sheet
- A good example by the same guy
- An SO answer
To start off a project just start a new Spring Boot project from STS with Spring AOP ticked. Thats it. Spring Boot handles all the dependencies bootifully. It adds some unnecessary dependencies also. So if you just need AOP, just add AOP dependencies instead of Spring Boot.