INT-1829 refactored MethodInvokingMessageHandler by adding setter to set 'componentType' value instead of hardcoding it
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.config.xml;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -23,7 +25,6 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for the <outbound-channel-adapter/> element.
|
||||
@@ -53,6 +54,8 @@ public class MethodInvokingOutboundChannelAdapterParser extends AbstractOutbound
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder invokerBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
IntegrationNamespaceUtils.BASE_PACKAGE + ".handler.MethodInvokingMessageHandler");
|
||||
|
||||
invokerBuilder.addPropertyValue("componentType", "outbound-channel-adapter");
|
||||
BeanComponentDefinition innerHandlerDefinition =
|
||||
IntegrationNamespaceUtils.parseInnerHandlerDefinition(element, parserContext);
|
||||
if (innerHandlerDefinition == null){
|
||||
|
||||
@@ -32,6 +32,8 @@ import org.springframework.util.Assert;
|
||||
public class MethodInvokingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
private volatile MethodInvokingMessageProcessor<Object> processor;
|
||||
|
||||
private volatile String componentType;
|
||||
|
||||
public MethodInvokingMessageHandler(Object object, Method method) {
|
||||
Assert.isTrue(method.getReturnType().equals(void.class),
|
||||
@@ -42,6 +44,10 @@ public class MethodInvokingMessageHandler extends AbstractMessageHandler {
|
||||
public MethodInvokingMessageHandler(Object object, String methodName) {
|
||||
processor = new MethodInvokingMessageProcessor<Object>(object, methodName);
|
||||
}
|
||||
|
||||
public void setComponentType(String componentType) {
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMessageInternal(Message<?> message) throws Exception {
|
||||
@@ -52,7 +58,8 @@ public class MethodInvokingMessageHandler extends AbstractMessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getComponentType() {
|
||||
return "outbound-channel-adapter";
|
||||
return this.componentType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user