Results 1 to 4 of 4

Thread: Superclass injected logicfacade is null

  1. #1
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default Superclass injected logicfacade is null

    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:

    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();
    	}
    			
    }
    The IoC-wiring of AOP....

    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>.*&#40;onSubmit&#41;.*</value>
    			</list>
    		</property>
    	</bean>
    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.

    Anybody heard about this?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Maybe this issue helps.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    It most certainly does. Glad it isn't me who's stupid. :lol: Thanks!
    This issue is very unfortunate. It forces you to make dummy interfaces just to be able to use JDK proxying as the CGLIB-way won't work, interfaces that describe basic Spring controller implementation...hmm.
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I'm sure the bug will be fixed in the future - as far as I see it's about an intialization flag that has to be set in order to prevent overwriting. I am also pro-Cglib as I don't like making dummy interfaces (even though I find them useful and I know they are a recommended way of programming).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Replies: 2
    Last Post: Oct 17th, 2005, 08:41 PM
  2. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  3. Replies: 4
    Last Post: Sep 27th, 2005, 11:31 PM
  4. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  5. Strange Data Access Error
    By webifyit in forum Data
    Replies: 2
    Last Post: Dec 28th, 2004, 11:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •