Greetings!
I would greatly appreciate it if someone would explain why my publishing-interceptor defaultChannel below is getting two of my TestBean messages; i was only expecting to see the echoChannel message that was published due to my interceptor method getting called.
console output:
18:16:58.001 INFO [main][simple.Main] PRE-TEST
18:16:58.353 INFO [main][simple.TestBean] DEFAULT CHANNEL INGORED: groovy.lang.MetaClassImpl@44ac5e[class simple.TestBean]
18:16:58.366 INFO [main][simple.TestBean] DEFAULT CHANNEL INGORED: groovy.lang.MetaClassImpl@44ac5e[class simple.TestBean]
18:16:58.381 INFO [main][simple.TestBean] ECHO CHANNEL RECEIVED: Echoing: Hello!
18:16:58.382 INFO [main][simple.Main] POST-TEST
simple-context.xml:
...
<beans:bean id="testBean" class="simple.TestBean" />
<channel id="defaultChannel"/>
<channel id="echoChannel"/>
<channel id="outputChannel"/>
<aop:aspectj-autoproxy proxy-target-class="true"/>
<aop:config>
<aop:advisor advice-ref="interceptor" pointcut="bean(testBean)" />
</aop:config>
<publishing-interceptor id="interceptor" default-channel="defaultChannel">
<method pattern="echo" payload="'Echoing: ' + #return" channel="echoChannel" />
</publishing-interceptor>
<service-activator input-channel="echoChannel" output-channel="outputChannel" ref="testBean" method="inspect" />
<service-activator input-channel="defaultChannel" output-channel="outputChannel" ref="testBean" method="ignore" />
TestBean.groovy:
...
public class TestBean {
private static final Logger LOGGER = Logger.getLogger(TestBean.class);
public String echo(String str) {
return str;
}
public void inspect(def msg) {
LOGGER.info("ECHO CHANNEL RECEIVED: " + msg);
}
public void ignore(def msg) {
LOGGER.info("DEFAULT CHANNEL INGORED: " + msg);
}
}
Main.groovy:
...
public static void main(final String... args) {
final AbstractApplicationContext context =
new ClassPathXmlApplicationContext("classpath:simple-context.xml");
final TestBean tester = context.getBean("testBean", TestBean.class);
LOGGER.info("PRE-TEST");
tester.echo("Hello!");
LOGGER.info("POST-TEST");
}