Refactored PublisherAnnotationBeanPostProcessor to implement BeanClassLoaderAware and to use AopUtils.canApply() since the advisor is a pointcut-advisor.

This commit is contained in:
Mark Fisher
2009-10-10 19:21:27 +00:00
parent 3767fddb33
commit 611b2fc325
5 changed files with 92 additions and 76 deletions

View File

@@ -6,9 +6,9 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd"
xmlns:si="http://www.springframework.org/schema/integration">
<bean id="testBean"
class="org.springframework.integration.aop.MessagePublishingAnnotationUsageTest$TestBean" />
class="org.springframework.integration.aop.MessagePublishingAnnotationUsageTests$TestBean" />
<si:channel id="testChannel">
<si:queue />

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aop;
import junit.framework.Assert;
@@ -31,26 +32,31 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class MessagePublishingAnnotationUsageTest {
public class MessagePublishingAnnotationUsageTests {
@Autowired
private TestBean testBean;
@Autowired
private QueueChannel channel;
@Test
public void demoMessagePublishingInterceptor(){
public void demoMessagePublishingInterceptor() {
String name = testBean.setName("John", "Doe");
Assert.assertNotNull(name);
Message<?> message = channel.receive();
Message<?> message = channel.receive(1000);
Assert.assertNotNull(message);
Assert.assertEquals("John Doe", message.getPayload());
Assert.assertEquals("123", message.getHeaders().get("bar"));
}
public static class TestBean{
public static class TestBean {
@Publisher(value="#return", channel="testChannel", headers="bar='123'")
public String setName(String fname, String lname){
return fname + " " + lname;
}
}
}

View File

@@ -8,7 +8,7 @@
xmlns:si="http://www.springframework.org/schema/integration">
<bean id="testBean"
class="org.springframework.integration.aop.MessagePublishingInterceptorUsageTest$TestBean" />
class="org.springframework.integration.aop.MessagePublishingInterceptorUsageTests$TestBean" />
<si:channel id="testChannel">
<si:queue />

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aop;
import junit.framework.Assert;
@@ -28,29 +29,33 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Oleg Zhurakousky
* @since 2.0
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class MessagePublishingInterceptorUsageTest {
public class MessagePublishingInterceptorUsageTests {
@Autowired
private TestBean testBean;
@Autowired
private QueueChannel channel;
@Test
public void demoMessagePublishingInterceptor(){
String name = testBean.setName("John", "Doe");
Assert.assertNotNull(name);
Message<?> message = channel.receive();
Message<?> message = channel.receive(1000);
Assert.assertNotNull(message);
Assert.assertEquals("John Doe", message.getPayload());
Assert.assertEquals("bar", message.getHeaders().get("foo"));
}
public static class TestBean{
public static class TestBean {
public String setName(String fname, String lname){
return fname + " " + lname;
}
}
}