Reputation: 3085
I have an existing project built on spring.
I would like to catch calls to HibernateTemplate.save() so I define a pointcut on exec(save()), and log the time in an around advice.
I could define the aspects using spring AOP, but I can see the spring AOP only works if the object in the pointcut is a bean, but in my case, the HibernateTemplate could be created in a new() directly in existing client code.
so I have to use aspectj compiler, through maven plugin. I wonder if there are any potential conflicts for mixing spring AOP and aspectj ? ---- previous developers of this project may have already used Spring AOP somewhere
Thanks Yang
Upvotes: 3
Views: 1372
Reputation: 10745
That will work fine. I have done it many times. I always starts with Spring AOP because it is simple and only starts to use AspectJ if I need some functionality not provided by Spring AOP.
My only tips is to use @AspectJ
style as much as possible, so you can easily change with minor configuration changes.
If you are new to the annotation style, you can find more information about it on Espen Berntsen's blog, @AspectJ cheat sheet
Upvotes: 0
Reputation: 120771
I normaly use AspectJ instead of Spring-Proxy-AOP for all my Spring Apps. To do this, you need to set some spring configruation, mostly set something like mode="AspectJ"
. Once I forgot this for some of that configurations, that mean the application used AspectJ for some Aspects and Spring-Proxy-AOP for the others, and yes the application worked correct (except the cases where I really needed AspectJ instead of pring-Proxy-AOP).
So from my point of view: If you have enough test cases, then give them a try.
Upvotes: 1