Metric | Spring AOP | AspectJ |
Simple/Complex | Spring AOP aims to provide a simple AOP implementation across Spring IoC to solve the most common problems that programmers face | AspectJ is the original AOP technology which aims to provide complete AOP solution. It is more robust but also significantly more complicated than Spring AOP |
Object Scope | It can only be applied to beans that are managed by a Spring container. | AspectJ can be applied across all domain objects. |
Weaving | Spring AOP makes use of runtime weaving.
With runtime weaving, the aspects are woven during the execution of the application using proxies of the targeted object – using either JDK dynamic proxy or CGLIB proxy.
|
AspectJ uses compile time and classload time weaving.
|
Performance | As far as performance is concerned, compile-time weaving is much faster than runtime weaving. Spring AOP is a proxy-based framework, so there is the creation of proxies at the time of application startup. | AspectJ weaves the aspects into the main code before the application executes and thus there’s no additional runtime overhead, unlike Spring AOP.
AspectJ is almost around 8 to 35 times faster than Spring AOP. |
Power | Less Powerful – only supports method level weaving | More Powerful – can weave fields, methods, constructors, static initializers, final class/methods, etc. |
Supported Pointcuts | Supports only method execution pointcuts | Support all pointcuts |