INT-2433: Get Rid of MessageProcessors wrapping
Previously, provided `MessageProcessor` to create a `MessageHandler` for endpoint was wrapped to `MethodInvokingMessageProcessor`, e.g. `GroovyScriptExecutingMessageProcessor`. Check the type of provided object in the constructor of `MethodInvoking*` strategies and use it directly if it is `MessageProcessor` JIRA: https://jira.springsource.org/browse/INT-2433
This commit is contained in:
committed by
Gary Russell
parent
417c848c0b
commit
4d3bc36ff0
@@ -34,6 +34,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Alexander Peters
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
abstract class AbstractStandardMessageHandlerFactoryBean extends AbstractSimpleMessageHandlerFactoryBean<MessageHandler> {
|
||||
|
||||
@@ -135,7 +136,7 @@ abstract class AbstractStandardMessageHandlerFactoryBean extends AbstractSimpleM
|
||||
}
|
||||
|
||||
<T> MessageHandler createMessageProcessingHandler(MessageProcessor<T> processor) {
|
||||
return this.createMethodInvokingHandler(processor, "processMessage");
|
||||
return this.createMethodInvokingHandler(processor, null);
|
||||
}
|
||||
|
||||
MessageHandler createDefaultHandler() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -20,13 +20,15 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.integration.annotation.Filter;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A method-invoking implementation of {@link MessageSelector}.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingSelector extends AbstractMessageProcessingSelector {
|
||||
|
||||
@@ -42,8 +44,10 @@ public class MethodInvokingSelector extends AbstractMessageProcessingSelector {
|
||||
super(new MethodInvokingMessageProcessor<Boolean>(object, methodName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public MethodInvokingSelector(Object object) {
|
||||
super(new MethodInvokingMessageProcessor<Boolean>(object, Filter.class));
|
||||
super(object instanceof MessageProcessor<?> ? (MessageProcessor<Boolean>) object :
|
||||
new MethodInvokingMessageProcessor<Boolean>(object, Filter.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -28,16 +28,16 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* A base class for Router implementations that delegate to a
|
||||
* {@link MessageProcessor} instance.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter {
|
||||
|
||||
private final MessageProcessor<Object> messageProcessor;
|
||||
private final MessageProcessor<?> messageProcessor;
|
||||
|
||||
|
||||
AbstractMessageProcessingRouter(MessageProcessor<Object> messageProcessor) {
|
||||
AbstractMessageProcessingRouter(MessageProcessor<?> messageProcessor) {
|
||||
Assert.notNull(messageProcessor, "messageProcessor must not be null");
|
||||
this.messageProcessor = messageProcessor;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter {
|
||||
public final void onInit() {
|
||||
super.onInit();
|
||||
if (this.messageProcessor instanceof AbstractMessageProcessor) {
|
||||
((AbstractMessageProcessor<Object>) this.messageProcessor).setConversionService(this.getConversionService());
|
||||
((AbstractMessageProcessor<?>) this.messageProcessor).setConversionService(this.getConversionService());
|
||||
}
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(this.getBeanFactory());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.router;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
import org.springframework.integration.support.channel.ChannelResolver;
|
||||
|
||||
@@ -28,8 +29,9 @@ import org.springframework.integration.support.channel.ChannelResolver;
|
||||
* String to be interpreted as a channel name, or a Collection (or Array) of
|
||||
* either type. If the method returns channel names, then a
|
||||
* {@link ChannelResolver} is required.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingRouter extends AbstractMessageProcessingRouter {
|
||||
|
||||
@@ -42,7 +44,8 @@ public class MethodInvokingRouter extends AbstractMessageProcessingRouter {
|
||||
}
|
||||
|
||||
public MethodInvokingRouter(Object object) {
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, Router.class));
|
||||
super(object instanceof MessageProcessor<?> ? (MessageProcessor<?>) object :
|
||||
new MethodInvokingMessageProcessor<Object>(object, Router.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
|
||||
/**
|
||||
@@ -28,8 +29,9 @@ import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
* is a Collection or Array. If the return value is not a Collection or
|
||||
* Array, then the single Object will be returned as the payload of a
|
||||
* single reply Message.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingSplitter extends AbstractMessageProcessingSplitter {
|
||||
|
||||
@@ -41,8 +43,10 @@ public class MethodInvokingSplitter extends AbstractMessageProcessingSplitter {
|
||||
super(new MethodInvokingMessageProcessor<Collection<?>>(object, methodName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public MethodInvokingSplitter(Object object) {
|
||||
super(new MethodInvokingMessageProcessor<Collection<?>>(object, Splitter.class));
|
||||
super(object instanceof MessageProcessor<?> ? (MessageProcessor<Collection<?>>) object :
|
||||
new MethodInvokingMessageProcessor<Collection<?>>(object, Splitter.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.transformer;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
|
||||
/**
|
||||
@@ -26,8 +27,9 @@ import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
* on the given object. The method's return value will be considered as
|
||||
* the payload of a new Message unless the return value is itself already
|
||||
* a Message.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingTransformer extends AbstractMessageProcessingTransformer {
|
||||
|
||||
@@ -40,7 +42,8 @@ public class MethodInvokingTransformer extends AbstractMessageProcessingTransfor
|
||||
}
|
||||
|
||||
public MethodInvokingTransformer(Object object) {
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, Transformer.class));
|
||||
super(object instanceof MessageProcessor<?> ? (MessageProcessor<?>) object :
|
||||
new MethodInvokingMessageProcessor<Object>(object, Transformer.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user