put back 'channel-resolver' attribute with deprecation warnings

INT-2299 polishing

INT-2299 added XPATH test
This commit is contained in:
Oleg Zhurakousky
2011-12-14 16:18:41 -05:00
committed by Mark Fisher
parent 052c325dfa
commit 0a8b348c98
8 changed files with 53 additions and 4 deletions

View File

@@ -15,12 +15,16 @@ package org.springframework.integration.config;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.expression.Expression;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.router.AbstractMappingMessageRouter;
import org.springframework.integration.router.ExpressionEvaluatingRouter;
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -33,6 +37,8 @@ import org.springframework.util.StringUtils;
* @author Dave Syer
*/
public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean {
private final Log logger = LogFactory.getLog(this.getClass());
private volatile Map<String, String> channelMappings;
@@ -45,8 +51,14 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
private volatile Boolean applySequence;
private volatile Boolean ignoreSendFailures;
private volatile ChannelResolver channelResolver;
public void setChannelResolver(ChannelResolver channelResolver) {
this.channelResolver = channelResolver;
}
public void setDefaultOutputChannel(MessageChannel defaultOutputChannel) {
this.defaultOutputChannel = defaultOutputChannel;
}
@@ -75,6 +87,10 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
MessageHandler createMethodInvokingHandler(Object targetObject, String targetMethodName) {
Assert.notNull(targetObject, "target object must not be null");
AbstractMappingMessageRouter router = this.extractTypeIfPossible(targetObject, AbstractMappingMessageRouter.class);
if (this.channelResolver != null){
logger.warn("'channel-resolver' attribute has been deprecated in favor of using SpEL via 'expression' attribute");
router.setChannelResolver(this.channelResolver);
}
if (router == null) {
router = this.createMethodInvokingRouter(targetObject, targetMethodName);
this.configureRouter(router);

View File

@@ -43,6 +43,7 @@ public abstract class AbstractRouterParser extends AbstractConsumerEndpointParse
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "resolution-required");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "apply-sequence");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "ignore-send-failures");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel-resolver");
BeanDefinition targetRouterBeanDefinition = this.parseRouter(element, parserContext);
builder.addPropertyValue("targetObject", targetRouterBeanDefinition);
return builder;

View File

@@ -68,9 +68,12 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
}
/**
* @deprecated - since 2.1 in favor of using SpEL via 'expression' attribute
*
* Specify the {@link ChannelResolver} strategy to use.
* The default is a BeanFactoryChannelResolver.
*/
@Deprecated
public void setChannelResolver(ChannelResolver channelResolver) {
Assert.notNull(channelResolver, "'channelResolver' must not be null");
this.channelResolver = channelResolver;

View File

@@ -2869,6 +2869,20 @@ endpoint itself is a Polling Consumer for a channel with a queue.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="channel-resolver" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
[DEPRECATED]Provides a reference to a ChannelResolver that resolves the return value
to the name of a MessageChannel within the application context. If none
is provided, the return value is expected to match a channel name exactly.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.core.ChannelResolver" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="ignore-send-failures" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[