OK so I get what your saying. In order for a method to be advised by Spring AOP the method needs to be called from an external class. That explains why the advice on the handleRequestInternal() wasn't being triggered. But that's not the only method that I can't get things to work for. I have also set it to trigger on one of my business delegate methods that is called EXTERNALLY from my controller class.
The controller class and bd class are both defined beans on my mvc-servlet.xml.
Code:
<!-- BMT Beans -->
<bean name="/bmt/agnisForms.htm" class="com.hks.web.controllers.AgnisFormController" />
<bean name="agnisFormBD" class="com.hks.web.business.delegates.AgnisFormsBusinessDelegate" />
<!-- AOP Mapping -->
<!-- Advice classes -->
<bean id="sessionAdvice" class="com.hks.advice.HibernateSessionAdvice"/>
<aop:config>
<aop:aspect ref="sessionAdvice">
<aop:after-returning method="clearSession" pointcut="execution(* *.getAgnisForm(..))"/>
</aop:aspect>
</aop:config>
Code:
public class AgnisFormController extends AbstractController {
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, Exception {
AgnisFormsBusinessDelegate afbd = new AgnisFormsBusinessDelegate();
AgnisFormsUIProxy proxy = new AgnisFormsUIProxy();
proxy.setAgnisForm(
afbd.getAgnisForm("C:\\...",
new Object[]{(Integer)request.getSession().getAttribute("CURR_PATIENT_ID"),
request.getSession().getAttribute("CURRENTUSER_LOGIN_ID")})
);
return new ModelAndView("bmt", "proxy", proxy);
}
}
Code:
public class AgnisFormsBusinessDelegate {
public CADSRForm getAgnisForm(String path, Object[] ids) {
CustomAGNISFormHandler formHandler = new CustomAGNISFormHandler();
CADSRForm form = formHandler.execute(new File(path));
AgnisFormQuestionAnswers afqa = new AgnisFormQuestionAnswers();
return form.getPopulateMethod().equalsIgnoreCase("formName") ? afqa.populateAgnisForm(form, ids) : form;
}
}