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

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s