Using Spring 2.0-m3.
I have an advice that is called twice but I (of course) only would like to have it called once. The problem is that it's called when the proxy is called too.
XML:
and the class for the advice:Code:<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="${mail.host}" /> <property name="username" value="${mail.user}" /> <property name="password" value="${mail.password}" /> </bean> <bean id="emailUserAdvice" class="com.foo.RegisterUserEmailAdvice"> <property name="mailSender" ref="mailSender" /> <property name="mailFrom" value="${mail.from}" /> <property name="subject" value="${mail.subject}" /> </bean> <aop:config> <aop:advisor pointcut="execution(* *..UserMgr.createUser(*..User))" advice-ref="emailUserAdvice" /> </aop:config> <bean id="abstractMgrTarget" abstract="true"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <bean id="userMgr" class="org.springframework.aop.framework.ProxyFactoryBean" parent="abstractMgr"> <property name="target" ref="userMgrTarget" /> </bean> <bean id="userMgrTarget" class="com.foo.impl.UserMgrJpa" parent="abstractMgrTarget"> </bean>
I debugged my app and I discovered that emailUserAdvice is called twice, first for the implementation and then for the proxy.Code:public class RegisterUserEmailAdminAdvice implements AfterReturningAdvice, InitializingBean { ... public void afterReturning(Object returnValue, Method m, Object[] args, Object target) throws Throwable { ... }
Any ideas how to solve this?Code:First call: target: java.lang.Object = {se.wesslan.shoppinglist.business.session.impl.UserMgrJpa@3834} Second call: target: java.lang.Object = {$Proxy57@3842}"se.wesslan.shoppinglist.business.session.impl.UserMgrJpa@3f9ad"
Regards


Reply With Quote
ointcut id="myPointcut" expression="execution(* *..UserMgr.createUser(*..User))"/>
