The "defaultOutputChannelName" property of HandlerEndpoint is now "outputChannelName", and the "defaultOutput" attribute of the @MessageEndpoint annotation is now "output".

This commit is contained in:
Mark Fisher
2008-04-27 06:00:40 +00:00
parent 09333d62cb
commit d252605bdb
22 changed files with 57 additions and 57 deletions

View File

@@ -39,7 +39,7 @@ public @interface MessageEndpoint {
String input() default "";
String defaultOutput() default "";
String output() default "";
int pollPeriod() default 0;

View File

@@ -342,11 +342,11 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry, Applicatio
}
if (endpoint instanceof HandlerEndpoint) {
HandlerEndpoint handlerEndpoint = (HandlerEndpoint) endpoint;
String outputChannelName = handlerEndpoint.getDefaultOutputChannelName();
String outputChannelName = handlerEndpoint.getOutputChannelName();
if (outputChannelName != null && this.lookupChannel(outputChannelName) == null) {
if (!this.autoCreateChannels) {
throw new ConfigurationException("Unknown channel '" + outputChannelName +
"' configured as 'default-output' for endpoint '" + endpoint +
"' configured as output channel for endpoint '" + endpoint +
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
}
this.registerChannel(outputChannelName, new QueueChannel());

View File

@@ -29,11 +29,11 @@ import org.springframework.util.StringUtils;
*
* @author Mark Fisher
*/
public class EndpointParser extends AbstractTargetEndpointParser {
public class HandlerEndpointParser extends AbstractTargetEndpointParser {
private static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel";
private static final String DEFAULT_OUTPUT_CHANNEL_PROPERTY = "defaultOutputChannelName";
private static final String OUTPUT_CHANNEL_PROPERTY = "outputChannelName";
private static final String RETURN_ADDRESS_OVERRIDES_ATTRIBUTE = "return-address-overrides";
@@ -60,7 +60,7 @@ public class EndpointParser extends AbstractTargetEndpointParser {
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
String outputChannel = element.getAttribute(OUTPUT_CHANNEL_ATTRIBUTE);
if (StringUtils.hasText(outputChannel)) {
builder.addPropertyValue(DEFAULT_OUTPUT_CHANNEL_PROPERTY, outputChannel);
builder.addPropertyValue(OUTPUT_CHANNEL_PROPERTY, outputChannel);
}
String returnAddressOverridesAttribute = element.getAttribute(RETURN_ADDRESS_OVERRIDES_ATTRIBUTE);
boolean returnAddressOverrides = "true".equals(returnAddressOverridesAttribute);

View File

@@ -52,7 +52,7 @@ public class IntegrationNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("source-adapter", new MethodInvokingAdapterParser());
registerBeanDefinitionParser("target-adapter", new MethodInvokingAdapterParser());
registerBeanDefinitionParser("source-endpoint", new SourceEndpointParser());
registerBeanDefinitionParser("handler-endpoint", new EndpointParser());
registerBeanDefinitionParser("handler-endpoint", new HandlerEndpointParser());
registerBeanDefinitionParser("target-endpoint", new TargetEndpointParser());
registerBeanDefinitionParser("handler", new HandlerParser());
registerBeanDefinitionParser("handler-chain", new HandlerParser());

View File

@@ -115,18 +115,18 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
if (bean instanceof ChannelRegistryAware) {
((ChannelRegistryAware) bean).setChannelRegistry(this.messageBus);
}
String defaultOutputChannelName = endpointAnnotation.defaultOutput();
MessageHandlerChain handlerChain = this.createHandlerChain(bean, defaultOutputChannelName);
String outputChannelName = endpointAnnotation.output();
MessageHandlerChain handlerChain = this.createHandlerChain(bean, outputChannelName);
if (handlerChain == null) {
throw new ConfigurationException("@MessageEndpoint has no handler method");
}
HandlerEndpoint endpoint = new HandlerEndpoint(handlerChain);
this.configureInput(bean, beanName, endpointAnnotation, endpoint);
if (StringUtils.hasText(defaultOutputChannelName)) {
endpoint.setDefaultOutputChannelName(defaultOutputChannelName);
if (StringUtils.hasText(outputChannelName)) {
endpoint.setOutputChannelName(outputChannelName);
}
else {
this.configureDefaultOutput(bean, beanName, endpoint);
this.configureOutput(bean, beanName, endpoint);
}
Concurrency concurrencyAnnotation = AnnotationUtils.findAnnotation(beanClass, Concurrency.class);
if (concurrencyAnnotation != null) {
@@ -174,13 +174,13 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
});
}
private void configureDefaultOutput(final Object bean, final String beanName, final HandlerEndpoint endpoint) {
private void configureOutput(final Object bean, final String beanName, final HandlerEndpoint endpoint) {
ReflectionUtils.doWithMethods(this.getBeanClass(bean), new ReflectionUtils.MethodCallback() {
boolean foundDefaultOutput = false;
boolean foundOutput = false;
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
Annotation annotation = AnnotationUtils.getAnnotation(method, DefaultOutput.class);
if (annotation != null) {
if (foundDefaultOutput) {
if (foundOutput) {
throw new ConfigurationException("only one @DefaultOutput allowed per endpoint");
}
MethodInvokingTarget target = new MethodInvokingTarget();
@@ -189,7 +189,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
target.afterPropertiesSet();
MessageHandler handler = endpoint.getHandler();
((MessageHandlerChain) handler).add(target);
foundDefaultOutput = true;
foundOutput = true;
return;
}
}
@@ -229,7 +229,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
}
@SuppressWarnings("unchecked")
private MessageHandlerChain createHandlerChain(final Object bean, final String defaultOutputChannelName) {
private MessageHandlerChain createHandlerChain(final Object bean, final String outputChannelName) {
final List<MessageHandler> handlers = new ArrayList<MessageHandler>();
ReflectionUtils.doWithMethods(this.getBeanClass(bean), new ReflectionUtils.MethodCallback() {
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
@@ -237,7 +237,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
for (Annotation annotation : annotations) {
if (isHandlerAnnotation(annotation)) {
Map<String, Object> attributes = AnnotationUtils.getAnnotationAttributes(annotation);
attributes.put(AbstractMessageHandlerAdapter.DEFAULT_OUTPUT_CHANNEL_NAME_KEY, defaultOutputChannelName);
attributes.put(AbstractMessageHandlerAdapter.OUTPUT_CHANNEL_NAME_KEY, outputChannelName);
MessageHandlerCreator handlerCreator = handlerCreators.get(annotation.annotationType());
if (handlerCreator == null) {
if (logger.isWarnEnabled()) {

View File

@@ -43,7 +43,7 @@ public class HandlerEndpoint extends TargetEndpoint {
private volatile long replyTimeout = 1000;
private volatile String defaultOutputChannelName;
private volatile String outputChannelName;
private volatile boolean returnAddressOverrides = false;
@@ -75,14 +75,14 @@ public class HandlerEndpoint extends TargetEndpoint {
/**
* Set the name of the channel to which this endpoint should send reply
* messages by default.
* messages.
*/
public void setDefaultOutputChannelName(String defaultOutputChannelName) {
this.defaultOutputChannelName = defaultOutputChannelName;
public void setOutputChannelName(String outputChannelName) {
this.outputChannelName = outputChannelName;
}
public String getDefaultOutputChannelName() {
return this.defaultOutputChannelName;
public String getOutputChannelName() {
return this.outputChannelName;
}
public void setReturnAddressOverrides(boolean returnAddressOverrides) {
@@ -134,8 +134,8 @@ public class HandlerEndpoint extends TargetEndpoint {
private MessageChannel getOutputChannel() {
ChannelRegistry registry = this.getChannelRegistry();
if (this.defaultOutputChannelName != null && registry != null) {
return registry.lookupChannel(this.defaultOutputChannelName);
if (this.outputChannelName != null && registry != null) {
return registry.lookupChannel(this.outputChannelName);
}
return null;
}
@@ -177,7 +177,7 @@ public class HandlerEndpoint extends TargetEndpoint {
MessageChannel replyChannel = resolveReplyChannel(originalMessageHeader);
if (replyChannel == null) {
throw new MessageHandlingException(replyMessage, "Unable to determine reply channel for message. " +
"Provide a 'returnAddress' in the message header or a 'defaultOutputChannelName' on the message endpoint.");
"Provide an 'outputChannelName' on the message endpoint or a 'returnAddress' in the message header");
}
if (logger.isDebugEnabled()) {
logger.debug("endpoint '" + HandlerEndpoint.this + "' replying to channel '" + replyChannel + "' with message: " + replyMessage);

View File

@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractMessageHandlerAdapter<T> implements MessageHandler, Ordered, InitializingBean {
public static final String DEFAULT_OUTPUT_CHANNEL_NAME_KEY = "defaultOutputChannelName";
public static final String OUTPUT_CHANNEL_NAME_KEY = "outputChannelName";
protected final Log logger = LogFactory.getLog(this.getClass());

View File

@@ -51,12 +51,12 @@ public class SplitterMessageHandlerAdapter<T> extends AbstractMessageHandlerAdap
public SplitterMessageHandlerAdapter(T object, Method method, Map<String, ?> attributes) {
Assert.notNull(object, "'object' must not be null");
Assert.notNull(method, "'method' must not be null");
Assert.isTrue(attributes != null && attributes.get(DEFAULT_OUTPUT_CHANNEL_NAME_KEY) != null,
"The '" + DEFAULT_OUTPUT_CHANNEL_NAME_KEY + "' attribute is required.");
Assert.isTrue(attributes != null && attributes.get(OUTPUT_CHANNEL_NAME_KEY) != null,
"The '" + OUTPUT_CHANNEL_NAME_KEY + "' attribute is required.");
this.setObject(object);
this.setMethodName(method.getName());
this.method = method;
this.outputChannelName = (String) attributes.get(DEFAULT_OUTPUT_CHANNEL_NAME_KEY);
this.outputChannelName = (String) attributes.get(OUTPUT_CHANNEL_NAME_KEY);
}
public void setChannelRegistry(ChannelRegistry channelRegistry) {

View File

@@ -57,7 +57,7 @@ public class SynchronousChannelSubscriptionTests {
public void testSendAndReceiveForRegisteredEndpoint() {
HandlerEndpoint endpoint = new HandlerEndpoint(new TestHandler());
endpoint.setSubscription(new Subscription("sourceChannel"));
endpoint.setDefaultOutputChannelName("targetChannel");
endpoint.setOutputChannelName("targetChannel");
bus.registerEndpoint("testEndpoint", endpoint);
bus.start();
this.sourceChannel.send(new StringMessage("foo"));
@@ -89,7 +89,7 @@ public class SynchronousChannelSubscriptionTests {
}
});
endpoint.setSubscription(new Subscription("sourceChannel"));
endpoint.setDefaultOutputChannelName("targetChannel");
endpoint.setOutputChannelName("targetChannel");
bus.registerEndpoint("testEndpoint", endpoint);
bus.start();
this.sourceChannel.send(new StringMessage("foo"));
@@ -116,7 +116,7 @@ public class SynchronousChannelSubscriptionTests {
}
@MessageEndpoint(input="sourceChannel", defaultOutput="targetChannel")
@MessageEndpoint(input="sourceChannel", output="targetChannel")
public static class TestEndpoint {
@Handler
@@ -126,7 +126,7 @@ public class SynchronousChannelSubscriptionTests {
}
@MessageEndpoint(input="sourceChannel", defaultOutput="targetChannel")
@MessageEndpoint(input="sourceChannel", output="targetChannel")
public static class FailingTestEndpoint {
@Handler

View File

@@ -17,7 +17,7 @@
<constructor-arg ref="sourceChannel"/>
</bean>
</property>
<property name="defaultOutputChannelName" value="targetChannel"/>
<property name="outputChannelName" value="targetChannel"/>
</bean>
<bean id="handler" class="org.springframework.integration.handler.TestHandlers" factory-method="echoHandler"/>

View File

@@ -58,7 +58,7 @@ public class HandlerEndpointTests {
};
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
endpoint.setChannelRegistry(channelRegistry);
endpoint.setDefaultOutputChannelName("replyChannel");
endpoint.setOutputChannelName("replyChannel");
endpoint.start();
endpoint.send(new StringMessage(1, "test"));
endpoint.stop();
@@ -171,7 +171,7 @@ public class HandlerEndpointTests {
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(1, 1));
endpoint.setChannelRegistry(channelRegistry);
endpoint.setDefaultOutputChannelName("replyChannel");
endpoint.setOutputChannelName("replyChannel");
endpoint.start();
endpoint.send(new StringMessage(1, "test"));
latch.await(500, TimeUnit.MILLISECONDS);
@@ -196,7 +196,7 @@ public class HandlerEndpointTests {
};
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
endpoint.setChannelRegistry(channelRegistry);
endpoint.setDefaultOutputChannelName("replyChannel");
endpoint.setOutputChannelName("replyChannel");
endpoint.start();
endpoint.send(new StringMessage(1, "test"));
endpoint.stop();
@@ -221,7 +221,7 @@ public class HandlerEndpointTests {
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(1, 1));
endpoint.setChannelRegistry(channelRegistry);
endpoint.setDefaultOutputChannelName("replyChannel");
endpoint.setOutputChannelName("replyChannel");
endpoint.start();
endpoint.send(new StringMessage(1, "test"));
latch.await(500, TimeUnit.MILLISECONDS);
@@ -273,7 +273,7 @@ public class HandlerEndpointTests {
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
endpoint.setChannelRegistry(channelRegistry);
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(3, 14));
endpoint.setDefaultOutputChannelName("replyChannel");
endpoint.setOutputChannelName("replyChannel");
endpoint.start();
endpoint.send(new StringMessage(1, "test"));
latch.await(500, TimeUnit.MILLISECONDS);
@@ -441,7 +441,7 @@ public class HandlerEndpointTests {
return message;
}
});
endpoint.setDefaultOutputChannelName("output");
endpoint.setOutputChannelName("output");
endpoint.setChannelRegistry(channelRegistry);
TestErrorHandler errorHandler = new TestErrorHandler();
endpoint.setErrorHandler(errorHandler);

View File

@@ -23,7 +23,7 @@ import org.springframework.integration.annotation.Polled;
/**
* @author Mark Fisher
*/
@MessageEndpoint(defaultOutput="outputChannel")
@MessageEndpoint(output="outputChannel")
public class InboundChannelAdapterTestBean {
@Polled(period=100)

View File

@@ -317,7 +317,7 @@ public class MessageEndpointAnnotationPostProcessorTests {
}
@MessageEndpoint(defaultOutput="testChannel")
@MessageEndpoint(output="testChannel")
private static class PolledAnnotationTestBean {
@Polled(period=100)
@@ -396,7 +396,7 @@ public class MessageEndpointAnnotationPostProcessorTests {
}
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=25)
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=25)
private static interface SimpleAnnotatedEndpointInterface {
String test(String input);
}
@@ -411,7 +411,7 @@ public class MessageEndpointAnnotationPostProcessorTests {
}
@MessageEndpoint(input="input", defaultOutput="output")
@MessageEndpoint(input="input", output="output")
private static class SplitterAnnotationTestEndpoint {
@Splitter

View File

@@ -24,7 +24,7 @@ import org.springframework.integration.message.StringMessage;
/**
* @author Mark Fisher
*/
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=10)
public class MessageParameterAnnotatedEndpoint {
@Handler

View File

@@ -22,7 +22,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
/**
* @author Mark Fisher
*/
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=10)
public class SimpleAnnotatedEndpoint implements ITestEndpoint {
@Handler

View File

@@ -22,7 +22,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
/**
* @author Mark Fisher
*/
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=10)
public class TypeConvertingTestEndpoint {
@Handler

View File

@@ -127,7 +127,7 @@ public class CorrelationIdTests {
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
channelRegistry.registerChannel("testChannel", testChannel);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(AbstractMessageHandlerAdapter.DEFAULT_OUTPUT_CHANNEL_NAME_KEY, "testChannel");
attributes.put(AbstractMessageHandlerAdapter.OUTPUT_CHANNEL_NAME_KEY, "testChannel");
SplitterMessageHandlerAdapter<TestBean> splitter = new SplitterMessageHandlerAdapter<TestBean>(
new TestBean(), TestBean.class.getMethod("split", String.class), attributes);
splitter.setChannelRegistry(channelRegistry);

View File

@@ -52,7 +52,7 @@ public class SplitterMessageHandlerAdapterTests {
public SplitterMessageHandlerAdapterTests() {
this.channelRegistry.registerChannel("testChannel", testChannel);
this.attribs.put(AbstractMessageHandlerAdapter.DEFAULT_OUTPUT_CHANNEL_NAME_KEY, "testChannel");
this.attribs.put(AbstractMessageHandlerAdapter.OUTPUT_CHANNEL_NAME_KEY, "testChannel");
}

View File

@@ -142,7 +142,7 @@
a <classname>MessageChannel</classname>, the reply message will be sent to that channel. If it is a
<classname>String</classname>, then the endpoint will attempt to resolve the channel by performing a
lookup in the <interfacename>ChannelRegistry</interfacename>. If the message header does not contain a
'returnAddress' property at all, then it will fallback to its own 'defaultOutputChannelName' property. If
'returnAddress' property at all, then it will fallback to its own 'outputChannelName' property. If
neither is available, then a <classname>MessageHandlingException</classname> will be thrown. To configure the
output channel when using the XML namespace, provide the 'output-channel' attribute:
<programlisting>&lt;handler-endpoint input-channel="exampleChannel"
@@ -315,9 +315,9 @@ public class FooService {
As described in the previous section, when the handler method returns a non-null value, the endpoint will
attempt to send a reply. This is consistent across both configuration options (namespace and annotations) in that
the message header's 'replyChannelName' property will be used if available, and the endpoint's default output is
the fallback. To configure the default output for an annotation-driven endpoint, provide the 'defaultOutput'
the fallback. To configure the default output for an annotation-driven endpoint, provide the 'output'
attribute on the <interfacename>@MessageEndpoint</interfacename>.
<programlisting>@MessageEndpoint(input="exampleChannel", defaultOutput="replyChannel")</programlisting>
<programlisting>@MessageEndpoint(input="exampleChannel", output="replyChannel")</programlisting>
</para>
<para>
Just as the 'schedule' sub-element and its 'period' attribute can be provided for a namespace-based

View File

@@ -24,7 +24,7 @@ import org.springframework.integration.annotation.Splitter;
/**
* @author Mark Fisher
*/
@MessageEndpoint(input="orders", defaultOutput="drinks")
@MessageEndpoint(input="orders", output="drinks")
public class OrderSplitter {
@Splitter

View File

@@ -30,7 +30,7 @@ public class Counter {
private AtomicInteger count = new AtomicInteger();
@Polled(period=3000)
@Polled(initialDelay=1000, period=3000)
public int getNumber() {
return count.incrementAndGet();
}

View File

@@ -27,7 +27,7 @@ import org.springframework.integration.annotation.Polled;
/**
* @author Mark Fisher
*/
@MessageEndpoint(defaultOutput="quotes")
@MessageEndpoint(output="quotes")
public class QuotePublisher {
@Polled(period=300)