INT-1227 parameterized MessageProcessor
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -26,10 +26,10 @@ import org.springframework.integration.handler.ExpressionEvaluatingMessageProces
|
||||
*/
|
||||
public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrategy {
|
||||
|
||||
private final ExpressionEvaluatingMessageProcessor processor;
|
||||
private final ExpressionEvaluatingMessageProcessor<Object> processor;
|
||||
|
||||
public ExpressionEvaluatingCorrelationStrategy(String expression) {
|
||||
this.processor = new ExpressionEvaluatingMessageProcessor(expression);
|
||||
this.processor = new ExpressionEvaluatingMessageProcessor<Object>(expression, Object.class);
|
||||
}
|
||||
|
||||
public Object getCorrelationKey(Message<?> message) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -30,17 +30,17 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MethodInvokingCorrelationStrategy implements CorrelationStrategy {
|
||||
|
||||
private final MethodInvokingMessageProcessor processor;
|
||||
private final MethodInvokingMessageProcessor<Object> processor;
|
||||
|
||||
public MethodInvokingCorrelationStrategy(Object object, String methodName) {
|
||||
this.processor = new MethodInvokingMessageProcessor(object, methodName, true);
|
||||
this.processor = new MethodInvokingMessageProcessor<Object>(object, methodName, true);
|
||||
}
|
||||
|
||||
public MethodInvokingCorrelationStrategy(Object object, Method method) {
|
||||
Assert.notNull(object, "'object' must not be null");
|
||||
Assert.notNull(method, "'method' must not be null");
|
||||
Assert.isTrue(!Void.TYPE.equals(method.getReturnType()), "Method return type must not be void");
|
||||
this.processor = new MethodInvokingMessageProcessor(object, method);
|
||||
this.processor = new MethodInvokingMessageProcessor<Object>(object, method);
|
||||
}
|
||||
|
||||
public Object getCorrelationKey(Message<?> message) {
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.integration.store.MessageGroup;
|
||||
*/
|
||||
public class MethodInvokingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor {
|
||||
|
||||
private final MethodInvokingMessageListProcessor processor;
|
||||
private final MethodInvokingMessageListProcessor<Object> processor;
|
||||
|
||||
/**
|
||||
* Creates a wrapper around the object passed in. This constructor will look for a method that can process
|
||||
@@ -45,7 +45,7 @@ public class MethodInvokingMessageGroupProcessor extends AbstractAggregatingMess
|
||||
* @param target the object to wrap
|
||||
*/
|
||||
public MethodInvokingMessageGroupProcessor(Object target) {
|
||||
this.processor = new MethodInvokingMessageListProcessor(target, Aggregator.class);
|
||||
this.processor = new MethodInvokingMessageListProcessor<Object>(target, Aggregator.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ public class MethodInvokingMessageGroupProcessor extends AbstractAggregatingMess
|
||||
* @param methodName the name of the method to invoke
|
||||
*/
|
||||
public MethodInvokingMessageGroupProcessor(Object target, String methodName) {
|
||||
this.processor = new MethodInvokingMessageListProcessor(target, methodName);
|
||||
this.processor = new MethodInvokingMessageListProcessor<Object>(target, methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class MethodInvokingMessageGroupProcessor extends AbstractAggregatingMess
|
||||
* @param method the method to invoke
|
||||
*/
|
||||
public MethodInvokingMessageGroupProcessor(Object target, Method method) {
|
||||
this.processor = new MethodInvokingMessageListProcessor(target, method);
|
||||
this.processor = new MethodInvokingMessageListProcessor<Object>(target, method);
|
||||
}
|
||||
|
||||
public void setConversionService(ConversionService conversionService) {
|
||||
@@ -80,8 +80,7 @@ public class MethodInvokingMessageGroupProcessor extends AbstractAggregatingMess
|
||||
@Override
|
||||
protected final Object aggregatePayloads(MessageGroup group, Map<String, Object> headers) {
|
||||
final Collection<Message<?>> messagesUpForProcessing = group.getUnmarked();
|
||||
Object result = this.processor.process(messagesUpForProcessing, headers);
|
||||
return result;
|
||||
return this.processor.process(messagesUpForProcessing, headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,36 +32,36 @@ import org.springframework.integration.util.MessagingMethodInvokerHelper;
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvokingMessageListProcessor extends AbstractExpressionEvaluator {
|
||||
public class MethodInvokingMessageListProcessor<T> extends AbstractExpressionEvaluator {
|
||||
|
||||
private final MessagingMethodInvokerHelper delegate;
|
||||
private final MessagingMethodInvokerHelper<T> delegate;
|
||||
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, Method method, Class<?> expectedType) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, method, expectedType, true);
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, Method method, Class<T> expectedType) {
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, method, expectedType, true);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, Method method) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, method, true);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, method, true);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, String methodName, Class<?> expectedType) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, methodName,
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, String methodName, Class<T> expectedType) {
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, methodName,
|
||||
expectedType, true);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, String methodName) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, methodName, true);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, methodName, true);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageListProcessor(Object targetObject, Class<? extends Annotation> annotationType) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, annotationType, Object.class, true);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, annotationType, Object.class, true);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
public Object process(Collection<? extends Message<?>> messages, Map<String, Object> aggregateHeaders) {
|
||||
public T process(Collection<? extends Message<?>> messages, Map<String, Object> aggregateHeaders) {
|
||||
try {
|
||||
return delegate.process(new ArrayList<Message<?>>(messages), aggregateHeaders);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -30,26 +30,28 @@ import org.springframework.integration.store.MessageGroup;
|
||||
*/
|
||||
public class MethodInvokingReleaseStrategy implements ReleaseStrategy {
|
||||
|
||||
private final MethodInvokingMessageListProcessor adapter;
|
||||
private final MethodInvokingMessageListProcessor<Boolean> adapter;
|
||||
|
||||
|
||||
public MethodInvokingReleaseStrategy(Object object, Method method) {
|
||||
adapter = new MethodInvokingMessageListProcessor(object, method, Boolean.class);
|
||||
this.adapter = new MethodInvokingMessageListProcessor<Boolean>(object, method, Boolean.class);
|
||||
}
|
||||
|
||||
public MethodInvokingReleaseStrategy(Object object, String methodName) {
|
||||
adapter = new MethodInvokingMessageListProcessor(object, methodName, Boolean.class);
|
||||
this.adapter = new MethodInvokingMessageListProcessor<Boolean>(object, methodName, Boolean.class);
|
||||
}
|
||||
|
||||
|
||||
public void setConversionService(ConversionService conversionService) {
|
||||
this.adapter.setConversionService(conversionService);
|
||||
}
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
adapter.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
public void setConversionService(ConversionService conversionService) {
|
||||
adapter.setConversionService(conversionService);
|
||||
this.adapter.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
public boolean canRelease(MessageGroup messages) {
|
||||
return (Boolean) adapter.process(messages.getUnmarked(), null);
|
||||
return this.adapter.process(messages.getUnmarked(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ abstract class AbstractMessageHandlerFactoryBean implements FactoryBean<MessageH
|
||||
Assert.state(this.expression == null,
|
||||
"The 'targetObject' and 'expression' properties are mutually exclusive.");
|
||||
if (this.targetObject instanceof MessageProcessor) {
|
||||
this.handler = this.createMessageProcessingHandler((MessageProcessor) this.targetObject);
|
||||
this.handler = this.createMessageProcessingHandler((MessageProcessor<?>) this.targetObject);
|
||||
}
|
||||
else {
|
||||
this.handler = this.createMethodInvokingHandler(this.targetObject, this.targetMethodName);
|
||||
@@ -162,7 +162,7 @@ abstract class AbstractMessageHandlerFactoryBean implements FactoryBean<MessageH
|
||||
throw new UnsupportedOperationException(this.getClass().getName() + " does not support expressions.");
|
||||
}
|
||||
|
||||
MessageHandler createMessageProcessingHandler(MessageProcessor processor) {
|
||||
<T> MessageHandler createMessageProcessingHandler(MessageProcessor<T> processor) {
|
||||
return this.createMethodInvokingHandler(processor, "processMessage");
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,13 @@ public class ServiceActivatorFactoryBean extends AbstractMessageHandlerFactoryBe
|
||||
|
||||
@Override
|
||||
MessageHandler createExpressionEvaluatingHandler(String expression) {
|
||||
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
|
||||
ExpressionEvaluatingMessageProcessor<Object> processor = new ExpressionEvaluatingMessageProcessor<Object>(expression);
|
||||
processor.setBeanFactory(this.getBeanFactory());
|
||||
return this.configureHandler(new ServiceActivatingHandler(processor));
|
||||
}
|
||||
|
||||
@Override
|
||||
MessageHandler createMessageProcessingHandler(MessageProcessor processor) {
|
||||
<T> MessageHandler createMessageProcessingHandler(MessageProcessor<T> processor) {
|
||||
return this.configureHandler(new ServiceActivatingHandler(processor));
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
|
||||
parserContext.getReaderContext().error(
|
||||
"Exactly one of the 'ref', 'value', or 'expression' attributes is required.", element);
|
||||
}
|
||||
Object headerSource = parserContext.extractSource(headerElement);
|
||||
BeanDefinitionBuilder valueProcessorBuilder = null;
|
||||
if (isValue) {
|
||||
if (hasMethod) {
|
||||
@@ -160,9 +159,6 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
|
||||
valueProcessorBuilder.addConstructorArgReference(ref);
|
||||
}
|
||||
}
|
||||
if (valueProcessorBuilder == null) {
|
||||
parserContext.getReaderContext().error("failed to parse header sub-element", headerSource);
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(valueProcessorBuilder, headerElement, "overwrite");
|
||||
headers.put(headerName, valueProcessorBuilder.getBeanDefinition());
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
abstract class AbstractMessageProcessingSelector implements MessageSelector, BeanFactoryAware {
|
||||
|
||||
private final MessageProcessor messageProcessor;
|
||||
private final MessageProcessor<Boolean> messageProcessor;
|
||||
|
||||
|
||||
public AbstractMessageProcessingSelector(MessageProcessor messageProcessor) {
|
||||
public AbstractMessageProcessingSelector(MessageProcessor<Boolean> messageProcessor) {
|
||||
Assert.notNull(messageProcessor, "messageProcessor must not be null");
|
||||
this.messageProcessor = messageProcessor;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ abstract class AbstractMessageProcessingSelector implements MessageSelector, Bea
|
||||
|
||||
protected void setConversionService(ConversionService conversionService) {
|
||||
if (this.messageProcessor instanceof AbstractMessageProcessor) {
|
||||
((AbstractMessageProcessor) this.messageProcessor).setConversionService(conversionService);
|
||||
((AbstractMessageProcessor<Boolean>) this.messageProcessor).setConversionService(conversionService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.integration.handler.ExpressionEvaluatingMessageProces
|
||||
public class ExpressionEvaluatingSelector extends AbstractMessageProcessingSelector {
|
||||
|
||||
public ExpressionEvaluatingSelector(String expression) {
|
||||
super(new ExpressionEvaluatingMessageProcessor(expression));
|
||||
super(new ExpressionEvaluatingMessageProcessor<Boolean>(expression, Boolean.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
|
||||
public class MethodInvokingSelector extends AbstractMessageProcessingSelector {
|
||||
|
||||
public MethodInvokingSelector(Object object, Method method) {
|
||||
super(new MethodInvokingMessageProcessor(object, method));
|
||||
super(new MethodInvokingMessageProcessor<Boolean>(object, method));
|
||||
Class<?> returnType = method.getReturnType();
|
||||
Assert.isTrue(boolean.class.isAssignableFrom(returnType)
|
||||
|| Boolean.class.isAssignableFrom(returnType),
|
||||
@@ -39,11 +39,11 @@ public class MethodInvokingSelector extends AbstractMessageProcessingSelector {
|
||||
}
|
||||
|
||||
public MethodInvokingSelector(Object object, String methodName) {
|
||||
super(new MethodInvokingMessageProcessor(object, methodName));
|
||||
super(new MethodInvokingMessageProcessor<Boolean>(object, methodName));
|
||||
}
|
||||
|
||||
public MethodInvokingSelector(Object object) {
|
||||
super(new MethodInvokingMessageProcessor(object, Filter.class));
|
||||
super(new MethodInvokingMessageProcessor<Boolean>(object, Filter.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractMessageProcessor extends AbstractExpressionEvaluator implements MessageProcessor {
|
||||
public abstract class AbstractMessageProcessor<T> extends AbstractExpressionEvaluator implements MessageProcessor<T> {
|
||||
|
||||
abstract public Object processMessage(Message<?> message);
|
||||
abstract public T processMessage(Message<?> message);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractScriptExecutingMessageProcessor implements MessageProcessor {
|
||||
public abstract class AbstractScriptExecutingMessageProcessor<T> implements MessageProcessor<T> {
|
||||
|
||||
private final ScriptSource scriptSource;
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class AbstractScriptExecutingMessageProcessor implements Message
|
||||
/**
|
||||
* Executes the script and returns the result.
|
||||
*/
|
||||
public final Object processMessage(Message<?> message) {
|
||||
public final T processMessage(Message<?> message) {
|
||||
try {
|
||||
return this.executeScript(this.scriptSource, message);
|
||||
}
|
||||
@@ -57,6 +57,6 @@ public abstract class AbstractScriptExecutingMessageProcessor implements Message
|
||||
* Subclasses must implement this method. In doing so, the execution context for the
|
||||
* script should be populated with the Message's 'payload' and 'headers' as variables.
|
||||
*/
|
||||
protected abstract Object executeScript(ScriptSource scriptSource, Message<?> message) throws Exception;
|
||||
protected abstract T executeScript(ScriptSource scriptSource, Message<?> message) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,23 +32,28 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ExpressionEvaluatingMessageProcessor extends AbstractMessageProcessor {
|
||||
public class ExpressionEvaluatingMessageProcessor<T> extends AbstractMessageProcessor<T> {
|
||||
|
||||
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
|
||||
private final Expression expression;
|
||||
|
||||
private volatile Class<?> expectedType = null;
|
||||
private final Class<T> expectedType;
|
||||
|
||||
|
||||
public ExpressionEvaluatingMessageProcessor(String expression) {
|
||||
this(expression, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link ExpressionEvaluatingMessageProcessor} for the given expression String.
|
||||
*/
|
||||
public ExpressionEvaluatingMessageProcessor(String expression) {
|
||||
public ExpressionEvaluatingMessageProcessor(String expression, Class<T> expectedType) {
|
||||
Assert.hasLength(expression, "The expression must be non empty");
|
||||
try {
|
||||
this.expression = parser.parseExpression(expression);
|
||||
this.getEvaluationContext().addPropertyAccessor(new MapAccessor());
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
catch (ParseException e) {
|
||||
throw new IllegalArgumentException("Failed to parse expression.", e);
|
||||
@@ -59,15 +64,15 @@ public class ExpressionEvaluatingMessageProcessor extends AbstractMessageProcess
|
||||
/**
|
||||
* Set the result type expected from evaluation of the expression.
|
||||
*/
|
||||
public void setExpectedType(Class<?> expectedType) {
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
// public void setExpectedType(Class<?> expectedType) {
|
||||
// this.expectedType = expectedType;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Processes the Message by evaluating the expression with that Message as the
|
||||
* root object. The expression evaluation result Object will be returned.
|
||||
*/
|
||||
public Object processMessage(Message<?> message) {
|
||||
public T processMessage(Message<?> message) {
|
||||
return this.evaluateExpression(this.expression, message, this.expectedType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -39,11 +39,11 @@ import org.springframework.integration.Message;
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface MessageProcessor {
|
||||
public interface MessageProcessor<T> {
|
||||
|
||||
/**
|
||||
* Process the Message and return a value (or null).
|
||||
*/
|
||||
Object processMessage(Message<?> message);
|
||||
T processMessage(Message<?> message);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MethodInvokingMessageHandler extends MethodInvokingMessageProcessor implements MessageHandler, Ordered {
|
||||
public class MethodInvokingMessageHandler extends MethodInvokingMessageProcessor<Object> implements MessageHandler, Ordered {
|
||||
|
||||
private volatile int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
|
||||
@@ -36,24 +36,24 @@ import org.springframework.integration.util.MessagingMethodInvokerHelper;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvokingMessageProcessor extends AbstractMessageProcessor {
|
||||
public class MethodInvokingMessageProcessor<T> extends AbstractMessageProcessor<T> {
|
||||
|
||||
private final MessagingMethodInvokerHelper delegate;
|
||||
private final MessagingMethodInvokerHelper<T> delegate;
|
||||
|
||||
public MethodInvokingMessageProcessor(Object targetObject, Method method) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, method, false);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, method, false);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageProcessor(Object targetObject, String methodName) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, methodName, false);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, methodName, false);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageProcessor(Object targetObject, String methodName, boolean requiresReply) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, methodName, Object.class, false);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, methodName, Object.class, false);
|
||||
}
|
||||
|
||||
public MethodInvokingMessageProcessor(Object targetObject, Class<? extends Annotation> annotationType) {
|
||||
delegate = new MessagingMethodInvokerHelper(targetObject, annotationType, false);
|
||||
delegate = new MessagingMethodInvokerHelper<T>(targetObject, annotationType, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,10 +68,11 @@ public class MethodInvokingMessageProcessor extends AbstractMessageProcessor {
|
||||
delegate.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
public Object processMessage(Message<?> message) {
|
||||
public T processMessage(Message<?> message) {
|
||||
try {
|
||||
return delegate.process(message);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MessageHandlingException(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,22 +27,22 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
*/
|
||||
public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
private final AbstractMessageProcessor processor;
|
||||
private final AbstractMessageProcessor<Object> processor;
|
||||
|
||||
|
||||
public ServiceActivatingHandler(final Object object) {
|
||||
this(new MethodInvokingMessageProcessor(object, ServiceActivator.class));
|
||||
this(new MethodInvokingMessageProcessor<Object>(object, ServiceActivator.class));
|
||||
}
|
||||
|
||||
public ServiceActivatingHandler(Object object, Method method) {
|
||||
this(new MethodInvokingMessageProcessor(object, method));
|
||||
this(new MethodInvokingMessageProcessor<Object>(object, method));
|
||||
}
|
||||
|
||||
public ServiceActivatingHandler(Object object, String methodName) {
|
||||
this(new MethodInvokingMessageProcessor(object, methodName));
|
||||
this(new MethodInvokingMessageProcessor<Object>(object, methodName));
|
||||
}
|
||||
|
||||
public ServiceActivatingHandler(AbstractMessageProcessor processor) {
|
||||
public ServiceActivatingHandler(AbstractMessageProcessor<Object> processor) {
|
||||
this.processor = processor;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class AbstractMessageProcessingRouter extends AbstractChannelNameResolvingMessageRouter {
|
||||
|
||||
private final MessageProcessor messageProcessor;
|
||||
private final MessageProcessor<Object> messageProcessor;
|
||||
|
||||
|
||||
AbstractMessageProcessingRouter(MessageProcessor messageProcessor) {
|
||||
AbstractMessageProcessingRouter(MessageProcessor<Object> messageProcessor) {
|
||||
Assert.notNull(messageProcessor, "messageProcessor must not be null");
|
||||
this.messageProcessor = messageProcessor;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class AbstractMessageProcessingRouter extends AbstractChannelNameResolvingMessag
|
||||
public final void onInit() {
|
||||
super.onInit();
|
||||
if (this.messageProcessor instanceof AbstractMessageProcessor) {
|
||||
((AbstractMessageProcessor) this.messageProcessor).setConversionService(this.getConversionService());
|
||||
((AbstractMessageProcessor<Object>) this.messageProcessor).setConversionService(this.getConversionService());
|
||||
}
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(this.getBeanFactory());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.integration.handler.ExpressionEvaluatingMessageProces
|
||||
public class ExpressionEvaluatingRouter extends AbstractMessageProcessingRouter {
|
||||
|
||||
public ExpressionEvaluatingRouter(String expression) {
|
||||
super(new ExpressionEvaluatingMessageProcessor(expression));
|
||||
super(new ExpressionEvaluatingMessageProcessor<Object>(expression));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -34,15 +34,15 @@ import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
public class MethodInvokingRouter extends AbstractMessageProcessingRouter {
|
||||
|
||||
public MethodInvokingRouter(Object object, Method method) {
|
||||
super(new MethodInvokingMessageProcessor(object, method));
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, method));
|
||||
}
|
||||
|
||||
public MethodInvokingRouter(Object object, String methodName) {
|
||||
super(new MethodInvokingMessageProcessor(object, methodName));
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, methodName));
|
||||
}
|
||||
|
||||
public MethodInvokingRouter(Object object) {
|
||||
super(new MethodInvokingMessageProcessor(object, Router.class));
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, Router.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.splitter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.Message;
|
||||
@@ -32,12 +34,12 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
abstract class AbstractMessageProcessingSplitter extends AbstractMessageSplitter {
|
||||
|
||||
private final MessageProcessor messageProcessor;
|
||||
private final MessageProcessor<Collection<?>> messageProcessor;
|
||||
|
||||
|
||||
protected AbstractMessageProcessingSplitter(MessageProcessor messageProcessor) {
|
||||
Assert.notNull(messageProcessor, "messageProcessor must not be null");
|
||||
this.messageProcessor = messageProcessor;
|
||||
protected AbstractMessageProcessingSplitter(MessageProcessor<Collection<?>> expressionEvaluatingMessageProcessor) {
|
||||
Assert.notNull(expressionEvaluatingMessageProcessor, "messageProcessor must not be null");
|
||||
this.messageProcessor = expressionEvaluatingMessageProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +47,7 @@ abstract class AbstractMessageProcessingSplitter extends AbstractMessageSplitter
|
||||
super.onInit();
|
||||
ConversionService conversionService = this.getConversionService();
|
||||
if (conversionService != null && this.messageProcessor instanceof AbstractMessageProcessor) {
|
||||
((AbstractMessageProcessor) this.messageProcessor).setConversionService(conversionService);
|
||||
((AbstractMessageProcessor<?>) this.messageProcessor).setConversionService(conversionService);
|
||||
}
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(this.getBeanFactory());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.splitter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
|
||||
|
||||
/**
|
||||
@@ -29,8 +31,9 @@ import org.springframework.integration.handler.ExpressionEvaluatingMessageProces
|
||||
*/
|
||||
public class ExpressionEvaluatingSplitter extends AbstractMessageProcessingSplitter {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public ExpressionEvaluatingSplitter(String expression) {
|
||||
super(new ExpressionEvaluatingMessageProcessor(expression));
|
||||
super(new ExpressionEvaluatingMessageProcessor(expression, Collection.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.splitter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
@@ -33,15 +34,15 @@ import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
public class MethodInvokingSplitter extends AbstractMessageProcessingSplitter {
|
||||
|
||||
public MethodInvokingSplitter(Object object, Method method) {
|
||||
super(new MethodInvokingMessageProcessor(object, method));
|
||||
super(new MethodInvokingMessageProcessor<Collection<?>>(object, method));
|
||||
}
|
||||
|
||||
public MethodInvokingSplitter(Object object, String methodName) {
|
||||
super(new MethodInvokingMessageProcessor(object, methodName));
|
||||
super(new MethodInvokingMessageProcessor<Collection<?>>(object, methodName));
|
||||
}
|
||||
|
||||
public MethodInvokingSplitter(Object object) {
|
||||
super(new MethodInvokingMessageProcessor(object, Splitter.class));
|
||||
super(new MethodInvokingMessageProcessor<Collection<?>>(object, Splitter.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingTransformer implements Transformer, BeanFactoryAware {
|
||||
|
||||
private final MessageProcessor messageProcessor;
|
||||
private final MessageProcessor<?> messageProcessor;
|
||||
|
||||
|
||||
protected AbstractMessageProcessingTransformer(MessageProcessor messageProcessor) {
|
||||
protected AbstractMessageProcessingTransformer(MessageProcessor<?> messageProcessor) {
|
||||
Assert.notNull(messageProcessor, "messageProcessor must not be null");
|
||||
this.messageProcessor = messageProcessor;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractMessageProcessingTransformer implements Transforme
|
||||
}
|
||||
ConversionService conversionService = IntegrationContextUtils.getConversionService(beanFactory);
|
||||
if (conversionService != null && this.messageProcessor instanceof AbstractMessageProcessor) {
|
||||
((AbstractMessageProcessor) this.messageProcessor).setConversionService(conversionService);
|
||||
((AbstractMessageProcessor<?>) this.messageProcessor).setConversionService(conversionService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.integration.handler.ExpressionEvaluatingMessageProces
|
||||
public class ExpressionEvaluatingTransformer extends AbstractMessageProcessingTransformer {
|
||||
|
||||
public ExpressionEvaluatingTransformer(String expression) {
|
||||
super(new ExpressionEvaluatingMessageProcessor(expression));
|
||||
super(new ExpressionEvaluatingMessageProcessor<Object>(expression));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ public class HeaderEnricher implements Transformer {
|
||||
private static final Log logger = LogFactory.getLog(HeaderEnricher.class);
|
||||
|
||||
|
||||
private final Map<String, ? extends HeaderValueMessageProcessor> headersToAdd;
|
||||
private final Map<String, ? extends HeaderValueMessageProcessor<?>> headersToAdd;
|
||||
|
||||
private volatile MessageProcessor messageProcessor;
|
||||
private volatile MessageProcessor<?> messageProcessor;
|
||||
|
||||
private volatile boolean defaultOverwrite = false;
|
||||
|
||||
@@ -60,12 +60,12 @@ public class HeaderEnricher implements Transformer {
|
||||
/**
|
||||
* Create a HeaderEnricher with the given map of headers.
|
||||
*/
|
||||
public HeaderEnricher(Map<String, ? extends HeaderValueMessageProcessor> headersToAdd) {
|
||||
this.headersToAdd = (headersToAdd != null) ? headersToAdd : new HashMap<String, HeaderValueMessageProcessor>();
|
||||
public HeaderEnricher(Map<String, ? extends HeaderValueMessageProcessor<?>> headersToAdd) {
|
||||
this.headersToAdd = (headersToAdd != null) ? headersToAdd : new HashMap<String, HeaderValueMessageProcessor<Object>>();
|
||||
}
|
||||
|
||||
|
||||
public void setMessageProcessor(MessageProcessor messageProcessor) {
|
||||
public <T> void setMessageProcessor(MessageProcessor<T> messageProcessor) {
|
||||
this.messageProcessor = messageProcessor;
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ public class HeaderEnricher implements Transformer {
|
||||
try {
|
||||
Map<String, Object> headerMap = new HashMap<String, Object>(message.getHeaders());
|
||||
this.addHeadersFromMessageProcessor(message, headerMap);
|
||||
for (Map.Entry<String, ? extends HeaderValueMessageProcessor> entry : this.headersToAdd.entrySet()) {
|
||||
for (Map.Entry<String, ? extends HeaderValueMessageProcessor<?>> entry : this.headersToAdd.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
HeaderValueMessageProcessor valueProcessor = entry.getValue();
|
||||
HeaderValueMessageProcessor<?> valueProcessor = entry.getValue();
|
||||
Boolean shouldOverwrite = valueProcessor.isOverwrite();
|
||||
if (shouldOverwrite == null) {
|
||||
shouldOverwrite = this.defaultOverwrite;
|
||||
@@ -129,14 +129,14 @@ public class HeaderEnricher implements Transformer {
|
||||
}
|
||||
|
||||
|
||||
public static interface HeaderValueMessageProcessor extends MessageProcessor {
|
||||
public static interface HeaderValueMessageProcessor<T> extends MessageProcessor<T> {
|
||||
|
||||
Boolean isOverwrite();
|
||||
|
||||
}
|
||||
|
||||
|
||||
static abstract class AbstractHeaderValueMessageProcessor implements HeaderValueMessageProcessor {
|
||||
static abstract class AbstractHeaderValueMessageProcessor<T> implements HeaderValueMessageProcessor<T> {
|
||||
|
||||
// null indicates no explicit setting; use header-enricher's 'default-overwrite' value
|
||||
private volatile Boolean overwrite = null;
|
||||
@@ -152,50 +152,50 @@ public class HeaderEnricher implements Transformer {
|
||||
}
|
||||
|
||||
|
||||
static class StaticHeaderValueMessageProcessor extends AbstractHeaderValueMessageProcessor {
|
||||
static class StaticHeaderValueMessageProcessor<T> extends AbstractHeaderValueMessageProcessor<T> {
|
||||
|
||||
private final Object value;
|
||||
private final T value;
|
||||
|
||||
public StaticHeaderValueMessageProcessor(Object value) {
|
||||
public StaticHeaderValueMessageProcessor(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object processMessage(Message<?> message) {
|
||||
public T processMessage(Message<?> message) {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class ExpressionEvaluatingHeaderValueMessageProcessor extends AbstractHeaderValueMessageProcessor implements BeanFactoryAware {
|
||||
static class ExpressionEvaluatingHeaderValueMessageProcessor<T> extends AbstractHeaderValueMessageProcessor<T> implements BeanFactoryAware {
|
||||
|
||||
private final ExpressionEvaluatingMessageProcessor targetProcessor;
|
||||
private final ExpressionEvaluatingMessageProcessor<T> targetProcessor;
|
||||
|
||||
/**
|
||||
* Create a header value processor for the given expression String and the expected type
|
||||
* of the expression evaluation result. The expectedType may be null if unknown.
|
||||
*/
|
||||
public ExpressionEvaluatingHeaderValueMessageProcessor(String expressionString, Class<?> expectedType) {
|
||||
this.targetProcessor = new ExpressionEvaluatingMessageProcessor(expressionString);
|
||||
this.targetProcessor.setExpectedType(expectedType);
|
||||
public ExpressionEvaluatingHeaderValueMessageProcessor(String expressionString, Class<T> expectedType) {
|
||||
this.targetProcessor = new ExpressionEvaluatingMessageProcessor<T>(expressionString, expectedType);
|
||||
//this.targetProcessor.setExpectedType(expectedType);
|
||||
}
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.targetProcessor.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
public Object processMessage(Message<?> message) {
|
||||
public T processMessage(Message<?> message) {
|
||||
return this.targetProcessor.processMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static class MethodInvokingHeaderValueMessageProcessor extends AbstractHeaderValueMessageProcessor {
|
||||
static class MethodInvokingHeaderValueMessageProcessor extends AbstractHeaderValueMessageProcessor<Object> {
|
||||
|
||||
private final MethodInvokingMessageProcessor targetProcessor;
|
||||
private final MethodInvokingMessageProcessor<Object> targetProcessor;
|
||||
|
||||
public MethodInvokingHeaderValueMessageProcessor(Object targetObject, String method) {
|
||||
this.targetProcessor = new MethodInvokingMessageProcessor(targetObject, method);
|
||||
this.targetProcessor = new MethodInvokingMessageProcessor<Object>(targetObject, method);
|
||||
}
|
||||
|
||||
public Object processMessage(Message<?> message) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -32,15 +32,15 @@ import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
public class MethodInvokingTransformer extends AbstractMessageProcessingTransformer {
|
||||
|
||||
public MethodInvokingTransformer(Object object, Method method) {
|
||||
super(new MethodInvokingMessageProcessor(object, method));
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, method));
|
||||
}
|
||||
|
||||
public MethodInvokingTransformer(Object object, String methodName) {
|
||||
super(new MethodInvokingMessageProcessor(object, methodName));
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, methodName));
|
||||
}
|
||||
|
||||
public MethodInvokingTransformer(Object object) {
|
||||
super(new MethodInvokingMessageProcessor(object, Transformer.class));
|
||||
super(new MethodInvokingMessageProcessor<Object>(object, Transformer.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware {
|
||||
return this.evaluationContext;
|
||||
}
|
||||
|
||||
protected Object evaluateExpression(Expression expression, Message<?> message, Class<?> expectedType) {
|
||||
protected <T> T evaluateExpression(Expression expression, Message<?> message, Class<T> expectedType) {
|
||||
try {
|
||||
return evaluateExpression(expression, (Object) message, expectedType);
|
||||
}
|
||||
@@ -76,9 +76,8 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware {
|
||||
}
|
||||
}
|
||||
|
||||
protected Object evaluateExpression(Expression expression, Object message, Class<?> expectedType) {
|
||||
return (expectedType != null) ? expression.getValue(this.evaluationContext, message, expectedType) : expression
|
||||
.getValue(this.evaluationContext, message);
|
||||
protected <T> T evaluateExpression(Expression expression, Object message, Class<T> expectedType) {
|
||||
return expression.getValue(this.evaluationContext, message, expectedType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ import org.springframework.util.ReflectionUtils.MethodFilter;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator {
|
||||
public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -115,12 +115,12 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator {
|
||||
this(targetObject, annotationType, (String) null, expectedType, canProcessMessageList);
|
||||
}
|
||||
|
||||
public Object process(Message<?> message) throws Exception {
|
||||
public T process(Message<?> message) throws Exception {
|
||||
ParametersWrapper parameters = new ParametersWrapper(message);
|
||||
return processInternal(parameters);
|
||||
}
|
||||
|
||||
public Object process(Collection<Message<?>> messages, Map<String, ?> headers) throws Exception {
|
||||
public T process(Collection<Message<?>> messages, Map<String, ?> headers) throws Exception {
|
||||
ParametersWrapper parameters = new ParametersWrapper(messages, headers);
|
||||
return processInternal(parameters);
|
||||
}
|
||||
@@ -209,21 +209,20 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Object processInternal(ParametersWrapper parameters) throws Exception {
|
||||
private T processInternal(ParametersWrapper parameters) throws Exception {
|
||||
Throwable evaluationException = null;
|
||||
List<HandlerMethod> candidates = this.findHandlerMethodsForParameters(parameters);
|
||||
Assert.state(!candidates.isEmpty(), "No candidate methods found for messages.");
|
||||
for (HandlerMethod candidate : candidates) {
|
||||
try {
|
||||
Expression expression = candidate.getExpression();
|
||||
Class<?> expectedType = this.expectedType != null ? this.expectedType : candidate.method
|
||||
.getReturnType();
|
||||
Class<?> expectedType = this.expectedType != null ? this.expectedType : candidate.method.getReturnType();
|
||||
Object result = this.evaluateExpression(expression, parameters, expectedType);
|
||||
if (this.requiresReply) {
|
||||
Assert.notNull(result,
|
||||
"Expression evaluation result was null, but this processor requires a reply.");
|
||||
}
|
||||
return result;
|
||||
return (T) result;
|
||||
}
|
||||
// keep the first exception
|
||||
catch (EvaluationException e) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecutingMessageProcessor {
|
||||
public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecutingMessageProcessor<Object> {
|
||||
|
||||
private final GroovyScriptFactory scriptFactory;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class XPathHeaderEnricher extends HeaderEnricher {
|
||||
}
|
||||
|
||||
|
||||
public static class XPathExpressionEvaluatingHeaderValueMessageProcessor implements HeaderValueMessageProcessor {
|
||||
public static class XPathExpressionEvaluatingHeaderValueMessageProcessor implements HeaderValueMessageProcessor<Object> {
|
||||
|
||||
private final XPathExpression expression;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user