AOP建议未在JOIDS应用程序中触发

时间:2013-06-05 12:17:33

标签: java spring spring-mvc spring-aop

在我的应用程序中,我尝试连接到不同的应用程序并保存数据。在那部分,我成功地保存了这些数据。但问题是,当我保存电子邮件时,它必须触发预定义的电子邮件通知。但它没有发生。这是我在this question中解释的连接代码,而我在其他应用程序中的servlet代码是。

ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());

String uname = request.getParameter("userName");
String pwd = request.getParameter("pwd");
String email = request.getParameter("email");

userDao.insertUser(user);
passDao.insertPassword(password);

User u1 =userDao.getUser(domain, uname);

Email command = new Email();

command.setCreationDate(new Date());
command.setAddress(email);
command.setUser(u1);
command.setLocale(new Locale("en","US"));

log.debug("Upto user adding data");

JosService josService = (JosService)context.getBean("josService");

try {
    log.debug("before adding email data");
    josService.insertEmail(u1,command);
    log.debug("After adding email data");
} catch (Exception e) {
    log.error("Setting and sending email address is failed");
    e.printStackTrace();
}

log.debug("Data saved succesfully");
response.setStatus(200);

在我的applicationcontext.xml中有这样的定义建议

<!-- ================ ADVISOR DEFINITIONS ================ -->
<bean id="emailAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    <property name="advice">
        <ref local="insertEmailAfterReturningAdvice" />
    </property>
    <property name="pattern">
        <value>.*insertEmail</value>
    </property>
</bean>

<!-- ================ ADVICE DEFINITIONS ================ -->
<bean id="insertEmailAfterReturningAdvice" class="cn.net.openid.jos.service.InsertEmailAfterReturningAdvice">
    <constructor-arg>
        <ref local="emailConfirmationInfoSendTaskExecutor" />
    </constructor-arg>
</bean>

<bean id="emailConfirmationInfoSendTaskExecutor" class="cn.net.openid.jos.service.EmailConfirmationInfoSendTaskExecutor">
    <constructor-arg ref="taskExecutor" />
    <property name="mailSender" ref="mailSender" />
    <property name="passwordDao" ref="passwordDao" />
</bean>

0 个答案:

没有答案