I have the following problem:
Controller A has a onSubmit(...)-method which is intercepted with a class that is supposed to send mail.
A also inherits B which exposes getLogic() and setLogic(..). the 'logic' property is wired in ordinary fashion using IoC. When unintercepted, the class works great, bu when the interceptor is put in action, getLogic() suddenly returns null.
As a result of A not implementing any interface that declares 'onSubmit(..)', I've found out that you can make CGLIB proxy the class intercepted.
(well, at least if you deside to break the 'protected'-scheme of the method that should fire the aspect and change it to 'public')
Has anyone heard of sudden null-propertys when a CGLIB-proxy is used?
The inetrceptor in its trial state:
The IoC-wiring of AOP....Code:public class AfterSubmitNotificationInterceptor implements MethodInterceptor { public static Logger log = Logger.getLogger(AfterSubmitNotificationInterceptor.class.getName()); private SimpleMimeMailHandler mailer; public SimpleMimeMailHandler getMailer() { return (this.mailer); } public void setMailer(SimpleMimeMailHandler mailer) { this.mailer = mailer; } public Object invoke(MethodInvocation i) throws Throwable{ log.debug("AfterSubmitNotificationInterceptor invoked"); return i.proceed(); } }
I've also tried to put getLogic() etc. as local members of A, but this still leaves 'logic' as null. Its superclass implements initializingBean, and no trouble there. Also everything works ok when I remove interception above on A:s onSubmit(...)-call.Code:<bean id="notificationInjectorProxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <!--property name="proxyInterfaces"><value>org.springframework.web.servlet.mvc.Controller</value></property--> <property name="proxyTargetClass"><value>true</value></property> <property name="target"><ref local="newReportForm"/></property> <property name="interceptorNames"> <list> <value>notificationInjector</value> </list> </property> </bean> <bean id="notificationInjector" class="ks.rah.avik2.web.form.support.AfterSubmitNotificationInterceptor"> <property name="mailer"><ref local="notificationMimeMailer"/></property> </bean> <bean id="notificationMimeMailer" class="ks.rah.avik2.logic.mail.SimpleMimeMailHandlerImpl"> <property name="sender"><ref local="sender"/></property> <property name="preparator"><ref local="simpleMailPreparator"/></property> <!--property name="message"><ref local="notificationMessage"/></property--> </bean> <bean id="notificationInjectorPointcut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice"><ref local="notificationInjector"/></property> <property name="patterns"> <list> <value>.*(onSubmit).*</value> </list> </property> </bean>
Anybody heard about this?


Reply With Quote