Oct 25th, 2011, 05:34 AM
Spring aop interceptor
I build a Spring mvc application.
I want to intercept the call to some controllers on this application.
the problem facing me is that i can't intercept these controllers in the traditionnal way:
ApplicationContext applicationContext = new FileSystemXmlApplicationContext("classpath:./config/my-config.xml");
Object simpleInterface = (Object) applicationContext.getBean(NameBean);
since the spring dispatcher call directely the appropriate controller. (the initialisation of the controller objects is implicite).
is there a why to intercept the call to these controller?
Thank you in advance.
Oct 25th, 2011, 07:04 AM
And why wouldn't that be possible?! Spring does exactly the same as you show in your snippet.. I really suggest you read the aop chapter of the reference guide.
Oct 25th, 2011, 09:12 AM
i already read the aop chapter,
the problem in my case is that as you know the dispatcher call the controller.
there is no need to write the code shown in my snippet to call the controller.
and since i didn't call the controller using such code i can't activated the aop interceptor.
and that's is my problem.
Oct 25th, 2011, 09:19 AM
You are making problems where there are none.. As I stated spring does exactly THAT for you.. So yes you don't call the controller yourself SPRING calls the controller/object/whatever in the EXACTLY THE SAME WAY...
So yes you can activate and use aop in that way.
Oct 25th, 2011, 09:40 AM
Thank you for your response, i will check again!
Tags for this Thread