INT-174 Added ConversionService support for filters.

This commit is contained in:
Mark Fisher
2010-03-11 22:50:08 +00:00
parent 433b76618b
commit e57aa4e80e
2 changed files with 16 additions and 1 deletions

View File

@@ -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,7 +16,9 @@
package org.springframework.integration.filter;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.core.Message;
import org.springframework.integration.handler.AbstractMessageProcessor;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.integration.selector.MessageSelector;
import org.springframework.util.Assert;
@@ -38,6 +40,12 @@ abstract class AbstractMessageProcessingSelector implements MessageSelector {
}
protected void setConversionService(ConversionService conversionService) {
if (this.messageProcessor instanceof AbstractMessageProcessor) {
((AbstractMessageProcessor) this.messageProcessor).setConversionService(conversionService);
}
}
public final boolean accept(Message<?> message) {
Object result = this.messageProcessor.processMessage(message);
Assert.notNull(result, "result must not be null");

View File

@@ -87,6 +87,13 @@ public class MessageFilter extends AbstractReplyProducingMessageHandler {
metadata.setComponentType("filter");
}
@Override
public final void onInit() {
if (this.selector instanceof AbstractMessageProcessingSelector) {
((AbstractMessageProcessingSelector) this.selector).setConversionService(this.getConversionService());
}
}
@Override
protected Object handleRequestMessage(Message<?> message) {
if (this.selector.accept(message)) {