简体   繁体   English

Spring AOP不会在Spring集成中触发Bean

[英]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. 我试图在我的Spring集成服务中的其中一个bean被调用之前获得一个方面来触发并做一些事情。 Here's my code so far.. 到目前为止,这是我的代码。

global-context.xml global-context.xml

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

Here's my bean in my spring integration pipeline 这是我的Spring集成管道中的bean

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 另外,我正在使用Spring 3.2.3和Spring Integration 2.2.4的旧版应用程序

Interesting; 有趣; it works if the transformer is a POJO (ie remove extends AbstractPayloadTransformer<Object,Object> ). 如果转换器是POJO,则可以正常工作(例如,删除extends AbstractPayloadTransformer<Object,Object> )。

We generally recommend using POJOs but if you want to extend AbstractPayloadTransformer , then... 我们通常建议使用POJO,但如果要扩展AbstractPayloadTransformer ,则...

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

...works. ...作品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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