October 10th, 2012, 02:15 PM
Spring AOP Help
I am using Spring AOP to implement the auditing use case, which is by nature a cross cutting concern. I have the following scenario:
UI Action Class:
public class UIControllerClass
private CityDao cityDao;
public void setCityDao(CityDao cityDao)
this.cityDao = cityDao;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView add(@RequestParam("city") String city)
ModelAndView modelAndView = new ModelAndView("city");
public class CityDao
public void add(String cityName)
City city = new City();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
I have the following advice class:
public class AuditLoggingAspect
private void createAuditEvent(Method method, Object args, Object target) throws Throwable
When the UIControllerClass.add method gets invoked as a result of the User selecting 'Add' through the UI, the aspect class intercepts the UIControllerClass.add method, but does not intercept CityDao.add method? I should add that I'm not the original creator of the AOP code in our application so I am trying to both get my head around Spring AOP and understand the existing implementation.
Given I have written a generic pointcut expression, it seems as though there is something that is either restricting the scope to only certain packages (config outside of the aspect class??) or the default Spring AOP config only allows one method to be matched per flow of execution??
Appreciate advise and help on this matter.