From e57aa4e80ed393e0a4d132b54626a451402253c1 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 11 Mar 2010 22:50:08 +0000 Subject: [PATCH] INT-174 Added ConversionService support for filters. --- .../filter/AbstractMessageProcessingSelector.java | 10 +++++++++- .../integration/filter/MessageFilter.java | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/filter/AbstractMessageProcessingSelector.java b/org.springframework.integration/src/main/java/org/springframework/integration/filter/AbstractMessageProcessingSelector.java index b083a2d28d..07aba7ce12 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/filter/AbstractMessageProcessingSelector.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/filter/AbstractMessageProcessingSelector.java @@ -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"); diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java b/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java index 3e280af701..913dd3f86c 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java @@ -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)) {