简体   繁体   中英

Spring AOP not triggering on bean in spring integration

I'm trying to get an aspect to trigger and do something before one of the beans in my spring integration service is called. Here's my code so far..

global-context.xml

<aop:aspectj-autoproxy/>
...
<bean class="com.ryanstull.spring.integration.DebugAdvice"/>

Here's my bean in my spring integration pipeline

package com.ryanstull.spring.integration;

import org.springframework.integration.annotation.Transformer;

public class DebugTransformer{

    @Transformer
    public Object transformPayload(Object arg0) throws Exception{
        System.out.println("In debug transformer");
        return arg0;
    }
}

My aspect

@Aspect
public class DebugAdvice{

    public DebugAdvice(){
    }

    @Before("within(com.ryanstull.spring.integration..*) && execution(public * *(..))")
    public void tester(){
        System.out.println("Before Debug Transformer advice.");
    }
}

Yet for some reason whenever I run my application I only ever see "In debug transformer" and it seems like my advice is never triggered.

Also, I'm working on a legacy application that is using spring 3.2.3 and spring integration 2.2.4

Interesting; it works if the transformer is a POJO (ie remove extends AbstractPayloadTransformer<Object,Object> ).

We generally recommend using POJOs but if you want to extend AbstractPayloadTransformer , then...

<aop:aspectj-autoproxy proxy-target-class="true" />

...works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM