refactored ServiceActivatorHandler configuration for the expression-evaluation case

This commit is contained in:
Mark Fisher
2010-06-16 21:02:13 +00:00
parent 0fe776d607
commit 40f05047d2
3 changed files with 10 additions and 10 deletions

View File

@@ -80,6 +80,10 @@ abstract class AbstractMessageHandlerFactoryBean implements FactoryBean<MessageH
this.beanFactory = beanFactory;
}
protected BeanFactory getBeanFactory() {
return this.beanFactory;
}
public MessageHandler getObject() throws Exception {
if (this.handler == null) {
this.initializeHandler();

View File

@@ -16,6 +16,7 @@
package org.springframework.integration.config;
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.integration.message.MessageHandler;
import org.springframework.util.StringUtils;
@@ -44,8 +45,9 @@ public class ServiceActivatorFactoryBean extends AbstractMessageHandlerFactoryBe
@Override
MessageHandler createExpressionEvaluatingHandler(String expression) {
Class<?> expectedType = null;
return this.configureHandler(new ServiceActivatingHandler(expression, expectedType));
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
processor.setBeanFactory(this.getBeanFactory());
return this.configureHandler(new ServiceActivatingHandler(processor));
}
private ServiceActivatingHandler configureHandler(ServiceActivatingHandler handler) {

View File

@@ -18,7 +18,6 @@ package org.springframework.integration.handler;
import java.lang.reflect.Method;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageHandlingException;
@@ -43,10 +42,8 @@ public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandl
this.processor = new MethodInvokingMessageProcessor(object, methodName);
}
public ServiceActivatingHandler(String expression, Class<?> expectedType) {
ExpressionEvaluatingMessageProcessor eemp = new ExpressionEvaluatingMessageProcessor(expression);
eemp.setExpectedType(expectedType);
this.processor = eemp;
public ServiceActivatingHandler(AbstractMessageProcessor processor) {
this.processor = processor;
}
@@ -58,9 +55,6 @@ public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandl
@Override
public final void onInit() {
this.processor.setConversionService(this.getConversionService());
if (this.processor instanceof BeanFactoryAware) {
((BeanFactoryAware) this.processor).setBeanFactory(this.getBeanFactory());
}
}
@Override