Using Spring AOP in JSF Application
consider a JSF web application with FooBean.java managed bean. I have declared this "FooBean" in my faces-config.xml file. Now if I want to add a Spring AOP tip for FooBean methods, how do I do it?
- Should I add the applicationContext.xml file and declare the managed beans inside it?
- or will it work even if I don't declare the managed beans inside the Spring config file?
Note. I created an Aspect bean and defined a dot like @Pointcut ("inside (dummy.web.reporting .. *)") inside the aspect bean.
source to share
You can load normal spring xml file from your web.xml like this:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring-context.xml</param-value>
</context-param>
Then you can define your managed beans here in regualar spring mode and you can still reference those beans by id in jsps.
You will also be able to use all standard spring AOP facilities in your spring-context.xml
source to share
I am using Spring AOP in a Spring JSF application, I would rather you load your JSF beans through a Spring container and also let Spring manage the beans scope.In such a scenario, all beans will be loaded by the Spring container, so it would be very easy to implement Spring AOP.
More information on this type of Spring-JSF integration http://xebee.xebia.in/2011/10/31/spring-jsf-integration-made-easy-clean-using-spring-annotations/
source to share