Spring AOP vs AspectJ Comparison

Spring AOP vs AspectJ Comparison:

Aspect-Oriented Programming (AOP) is like Object-Oriented Programming (OOP), the key element in OOP is the class, whereas in AOP – key element is the aspect. Aspects enable the modularization of different concerns(cross-cutting concerns) such as transaction management, logging etc. that cut across multiple types and objects.

Spring-AOP Advantages

It is simpler then AspectJ, because you don’t have to use LTW (load-time weaving) or the AspectJ compiler.
You can change from spring AOP to AspectJ AOP when you use @Aspect annotation based Spring AOP.
It is proxy-based, and uses Proxy pattern and Decorator pattern to create AOP proxy

Spring-AOP Disadvantages

It is proxy-based, so only you can use method-execution point-cut.
You can’t apply Aspects when calling another method within the same class.
There can be some runtime overhead.

AspectJ Advantages

It supports all types of point-cuts. This means you can do anything.
There is some runtime overhead.

AspectJ Disadvantages

You have to be more careful to check if your aspects are weaved to only what you wanted to be weaved.
You need extra build process(using AspectJ Compiler or have to setup load-time weavin)

Gopal Das
Follow me

Gopal Das

Founder at GopalDas.Org
He is a technology evangelist, Salesforce trainer, blogger, and working as a Salesforce Technical Lead. After working in Java based project implementation, he jumped to the Salesforce system on a whim and never looked back. He fell in love with Salesforce’s flexibility, scalability, and power. He expanded his knowledge of the platform and became a Certified App Builder, Administrator, Platform Developer I, SalesCloud Consultant while leading the Salesforce implementation and technology needs. He has worked in a wide variety of applications/services like desktop, web and mobile applications.
Gopal Das
Follow me

Leave a Reply

Your email address will not be published. Required fields are marked *