diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java
index bb65c12ce1..7d5a2b7ced 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java
@@ -19,9 +19,11 @@ package org.springframework.integration.config.xml;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
/**
* Parser for the <annotation-config> element of the integration namespace.
@@ -42,6 +44,10 @@ public class AnnotationConfigParser implements BeanDefinitionParser {
RootBeanDefinition publisherAnnotationPostProcessorDef = new RootBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".aop.PublisherAnnotationBeanPostProcessor");
publisherAnnotationPostProcessorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
+ String defaultPublisherChannel = element.getAttribute("default-publisher-channel");
+ if (StringUtils.hasText(defaultPublisherChannel)) {
+ publisherAnnotationPostProcessorDef.getPropertyValues().add("defaultChannel", new RuntimeBeanReference(defaultPublisherChannel));
+ }
String publisherAnnotationPostProcessorName = IntegrationNamespaceUtils.BASE_PACKAGE + ".internalPublisherAnnotationBeanPostProcessor";
parserContext.getRegistry().registerBeanDefinition(publisherAnnotationPostProcessorName, publisherAnnotationPostProcessorDef);
return null;
diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd
index 7422cd8bde..e30d5e945b 100644
--- a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd
+++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd
@@ -19,6 +19,20 @@
Enables annotation support for Message Endpoints.
+
+
+
+
+ Default output channel for the @Publisher annotation support.
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests-context.xml
index dee54a59d6..f930fa1335 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests-context.xml
+++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests-context.xml
@@ -13,6 +13,10 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests.java
index d47c966292..af069fe8cb 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/AnnotationConfigRegistrationTests.java
@@ -39,26 +39,44 @@ public class AnnotationConfigRegistrationTests {
private TestBean testBean;
@Autowired
- private QueueChannel channel;
+ private QueueChannel testChannel;
+
+ @Autowired
+ private QueueChannel defaultChannel;
@Test // INT-1200
public void verifyInterception() {
String name = testBean.setName("John", "Doe");
Assert.assertNotNull(name);
- Message> message = channel.receive(0);
+ Message> message = testChannel.receive(0);
Assert.assertNotNull(message);
- Assert.assertEquals("John Doe", message.getPayload());
+ Assert.assertEquals("John DoeDoe", message.getPayload());
Assert.assertEquals("123", message.getHeaders().get("x"));
}
+ @Test
+ public void defaultChannel() {
+ String result = testBean.exclaim("hello");
+ Assert.assertNotNull(result);
+ Assert.assertEquals("HELLO!!!", result);
+ Message> message = defaultChannel.receive(0);
+ Assert.assertNotNull(message);
+ Assert.assertEquals("HELLO!!!", message.getPayload());
+ }
+
public static class TestBean {
- @Publisher(channel="testChannel", payload="#return", headers="x='123'")
+ @Publisher(channel="testChannel", payload="#return + #args.lname", headers="x='123'")
public String setName(String fname, String lname){
return fname + " " + lname;
}
+
+ @Publisher
+ public String exclaim(String s) {
+ return s.toUpperCase() + "!!!";
+ }
}
}