INT-174 Added ConversionService support for filters.
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.
|
||||
@@ -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");
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user