From 56374212d10932f5a503ce7acad3df31d9c68cb5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 15 Oct 2015 19:02:08 -0400 Subject: [PATCH] INT-3853: Fix `${}` resolution for Ann & XML mix JIRA: https://jira.spring.io/browse/INT-3853 Previously the placeholder definitions for the Messaging Annotation weren't be resolved if we use `` instead of `@PropertySource`. Fix `MessagingAnnotationPostProcessor` and its "kindergarten" to use `beanFactory.resolveEmbeddedValue()` instead of `environment.resolvePlaceholders()`. --- ...AbstractMethodAnnotationPostProcessor.java | 26 ++++------ .../AggregatorAnnotationPostProcessor.java | 9 ++-- .../BridgeFromAnnotationPostProcessor.java | 9 ++-- .../BridgeToAnnotationPostProcessor.java | 9 ++-- .../FilterAnnotationPostProcessor.java | 13 +++-- ...ChannelAdapterAnnotationPostProcessor.java | 7 ++- .../MessagingAnnotationPostProcessor.java | 47 +++++++------------ .../RouterAnnotationPostProcessor.java | 19 ++++---- ...rviceActivatorAnnotationPostProcessor.java | 9 ++-- .../SplitterAnnotationPostProcessor.java | 11 ++--- .../TransformerAnnotationPostProcessor.java | 9 ++-- .../FilterAnnotationPostProcessorTests.java | 8 ++-- .../EnableIntegrationTests-context.xml | 12 +++-- .../configuration/EnableIntegrationTests.java | 6 ++- .../configuration/EnableMBeanExportTests.java | 7 +-- 15 files changed, 89 insertions(+), 112 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java index 524bd08c5e..bdee48558f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java @@ -32,7 +32,6 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor; import org.springframework.aop.support.NameMatchMethodPointcut; -import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionValidationException; @@ -43,7 +42,6 @@ import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.Order; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.core.env.Environment; import org.springframework.core.task.TaskExecutor; import org.springframework.integration.annotation.IdempotentReceiver; import org.springframework.integration.annotation.Poller; @@ -82,7 +80,8 @@ import org.springframework.util.StringUtils; * @author Artem Bilan * @author Gary Russell */ -public abstract class AbstractMethodAnnotationPostProcessor implements MethodAnnotationPostProcessor { +public abstract class AbstractMethodAnnotationPostProcessor + implements MethodAnnotationPostProcessor { private static final String INPUT_CHANNEL_ATTRIBUTE = "inputChannel"; @@ -98,19 +97,15 @@ public abstract class AbstractMethodAnnotationPostProcessor channelResolver; protected final Class annotationType; @SuppressWarnings("unchecked") - public AbstractMethodAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { + public AbstractMethodAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { Assert.notNull(beanFactory, "'beanFactory' must not be null"); - Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory, - "'beanFactory' must be instanceOf ConfigurableListableBeanFactory"); this.messageHandlerAttributes.add(SEND_TIMEOUT_ATTRIBUTE); - this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; + this.beanFactory = beanFactory; ConversionService conversionService = this.beanFactory.getConversionService(); if (conversionService != null) { this.conversionService = conversionService; @@ -118,7 +113,6 @@ public abstract class AbstractMethodAnnotationPostProcessor) GenericTypeResolver.resolveTypeArgument(this.getClass(), MethodAnnotationPostProcessor.class); @@ -151,7 +145,7 @@ public abstract class AbstractMethodAnnotationPostProcessor { - public AggregatorAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public AggregatorAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); } @@ -81,7 +80,7 @@ public class AggregatorAnnotationPostProcessor extends AbstractMethodAnnotationP "sendPartialResultsOnExpiry", String.class); if (sendPartialResultsOnExpiry != null) { handler.setSendPartialResultOnExpiry( - Boolean.parseBoolean(this.environment.resolvePlaceholders(sendPartialResultsOnExpiry))); + Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(sendPartialResultsOnExpiry))); } handler.setBeanFactory(this.beanFactory); return handler; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeFromAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeFromAnnotationPostProcessor.java index 693991889a..f87ac3bac4 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeFromAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeFromAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 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. @@ -20,11 +20,10 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.BridgeFrom; import org.springframework.integration.annotation.BridgeTo; import org.springframework.integration.handler.BridgeHandler; @@ -42,8 +41,8 @@ import org.springframework.util.StringUtils; */ public class BridgeFromAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public BridgeFromAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public BridgeFromAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeToAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeToAnnotationPostProcessor.java index 36027856b4..b252b47d90 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeToAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/BridgeToAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 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. @@ -20,10 +20,9 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.BridgeFrom; import org.springframework.integration.annotation.BridgeTo; import org.springframework.integration.endpoint.AbstractEndpoint; @@ -42,8 +41,8 @@ import org.springframework.util.StringUtils; */ public class BridgeToAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public BridgeToAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public BridgeToAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessor.java index 22726bdde6..b3eadd5660 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -21,10 +21,9 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.Filter; import org.springframework.integration.core.MessageSelector; import org.springframework.integration.filter.MessageFilter; @@ -44,8 +43,8 @@ import org.springframework.util.StringUtils; */ public class FilterAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public FilterAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public FilterAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); this.messageHandlerAttributes.addAll(Arrays.asList("discardChannel", "throwExceptionOnRejection", "adviceChain", "discardWithinAdvice")); } @@ -78,7 +77,7 @@ public class FilterAnnotationPostProcessor extends AbstractMethodAnnotationPostP String discardWithinAdvice = MessagingAnnotationUtils.resolveAttribute(annotations, "discardWithinAdvice", String.class); if (StringUtils.hasText(discardWithinAdvice)) { - discardWithinAdvice = this.environment.resolvePlaceholders(discardWithinAdvice); + discardWithinAdvice = this.beanFactory.resolveEmbeddedValue(discardWithinAdvice); if (StringUtils.hasText(discardWithinAdvice)) { filter.setDiscardWithinAdvice(Boolean.parseBoolean(discardWithinAdvice)); } @@ -88,7 +87,7 @@ public class FilterAnnotationPostProcessor extends AbstractMethodAnnotationPostP String throwExceptionOnRejection = MessagingAnnotationUtils.resolveAttribute(annotations, "throwExceptionOnRejection", String.class); if (StringUtils.hasText(throwExceptionOnRejection)) { - String throwExceptionOnRejectionValue = this.environment.resolvePlaceholders(throwExceptionOnRejection); + String throwExceptionOnRejectionValue = this.beanFactory.resolveEmbeddedValue(throwExceptionOnRejection); if (StringUtils.hasText(throwExceptionOnRejectionValue)) { filter.setThrowExceptionOnRejection(Boolean.parseBoolean(throwExceptionOnRejectionValue)); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/InboundChannelAdapterAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/InboundChannelAdapterAnnotationPostProcessor.java index 2810b64291..39b12f41f1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/InboundChannelAdapterAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/InboundChannelAdapterAnnotationPostProcessor.java @@ -20,12 +20,11 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.InboundChannelAdapter; import org.springframework.integration.config.IntegrationConfigUtils; import org.springframework.integration.core.MessageSource; @@ -46,8 +45,8 @@ import org.springframework.util.Assert; public class InboundChannelAdapterAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public InboundChannelAdapterAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public InboundChannelAdapterAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java index 89f8daadb7..490c293b85 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java @@ -39,10 +39,8 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.SmartInitializingSingleton; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.EnvironmentAware; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.Aggregator; import org.springframework.integration.annotation.BridgeFrom; import org.springframework.integration.annotation.BridgeTo; @@ -75,18 +73,16 @@ import org.springframework.util.StringUtils; * @author Gary Russell */ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, BeanFactoryAware, - InitializingBean, EnvironmentAware, SmartInitializingSingleton { + InitializingBean, SmartInitializingSingleton { private final Log logger = LogFactory.getLog(this.getClass()); - private volatile ConfigurableListableBeanFactory beanFactory; - - private Environment environment; - private final Map, MethodAnnotationPostProcessor> postProcessors = new HashMap, MethodAnnotationPostProcessor>(); - private final MultiValueMap lazyLifecyleRoles = new LinkedMultiValueMap(); + private final MultiValueMap lazyLifecycleRoles = new LinkedMultiValueMap(); + + private ConfigurableListableBeanFactory beanFactory; @Override public void setBeanFactory(BeanFactory beanFactory) { @@ -95,23 +91,18 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; } - @Override - public void setEnvironment(Environment environment) { - this.environment = environment; - } - @Override public void afterPropertiesSet() { Assert.notNull(this.beanFactory, "BeanFactory must not be null"); - postProcessors.put(Filter.class, new FilterAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(Router.class, new RouterAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(Transformer.class, new TransformerAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(ServiceActivator.class, new ServiceActivatorAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(Splitter.class, new SplitterAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(Aggregator.class, new AggregatorAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(InboundChannelAdapter.class, new InboundChannelAdapterAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(BridgeFrom.class, new BridgeFromAnnotationPostProcessor(this.beanFactory, this.environment)); - postProcessors.put(BridgeTo.class, new BridgeToAnnotationPostProcessor(this.beanFactory, this.environment)); + postProcessors.put(Filter.class, new FilterAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(Router.class, new RouterAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(Transformer.class, new TransformerAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(ServiceActivator.class, new ServiceActivatorAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(Splitter.class, new SplitterAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(Aggregator.class, new AggregatorAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(InboundChannelAdapter.class, new InboundChannelAdapterAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(BridgeFrom.class, new BridgeFromAnnotationPostProcessor(this.beanFactory)); + postProcessors.put(BridgeTo.class, new BridgeToAnnotationPostProcessor(this.beanFactory)); } @Override @@ -125,7 +116,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean try { roleController = beanFactory.getBean(IntegrationContextUtils.INTEGRATION_LIFECYCLE_ROLE_CONTROLLER, SmartLifecycleRoleController.class); - for (Entry> entry : this.lazyLifecyleRoles.entrySet()) { + for (Entry> entry : this.lazyLifecycleRoles.entrySet()) { roleController.addLifecyclesToRole(entry.getKey(), entry.getValue()); } } @@ -180,9 +171,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean String autoStartup = MessagingAnnotationUtils.resolveAttribute(annotations, "autoStartup", String.class); if (StringUtils.hasText(autoStartup)) { - if (environment != null) { - autoStartup = environment.resolvePlaceholders(autoStartup); - } + autoStartup = beanFactory.resolveEmbeddedValue(autoStartup); if (StringUtils.hasText(autoStartup)) { endpoint.setAutoStartup(Boolean.parseBoolean(autoStartup)); } @@ -190,9 +179,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean String phase = MessagingAnnotationUtils.resolveAttribute(annotations, "phase", String.class); if (StringUtils.hasText(phase)) { - if (environment != null) { - phase = environment.resolvePlaceholders(phase); - } + phase = beanFactory.resolveEmbeddedValue(phase); if (StringUtils.hasText(phase)) { endpoint.setPhase(Integer.parseInt(phase)); } @@ -205,7 +192,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean Role role = AnnotationUtils.findAnnotation(method, Role.class); if (role != null) { - lazyLifecyleRoles.add(role.value(), endpointBeanName); + lazyLifecycleRoles.add(role.value(), endpointBeanName); } } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/RouterAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/RouterAnnotationPostProcessor.java index 755e905d63..0a90902bdf 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/RouterAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/RouterAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -22,11 +22,10 @@ import java.util.Arrays; import java.util.List; import java.util.Properties; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.convert.TypeDescriptor; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.Router; import org.springframework.integration.router.AbstractMessageRouter; import org.springframework.integration.router.MethodInvokingRouter; @@ -45,8 +44,8 @@ import org.springframework.util.StringUtils; */ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public RouterAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public RouterAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); this.messageHandlerAttributes.addAll(Arrays.asList("defaultOutputChannel", "applySequence", "ignoreSendFailures", "resolutionRequired", "channelMappings", "prefix", "suffix")); } @@ -85,13 +84,13 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP String applySequence = MessagingAnnotationUtils.resolveAttribute(annotations, "applySequence", String.class); if (StringUtils.hasText(applySequence)) { - router.setApplySequence(Boolean.parseBoolean(this.environment.resolvePlaceholders(applySequence))); + router.setApplySequence(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(applySequence))); } String ignoreSendFailures = MessagingAnnotationUtils.resolveAttribute(annotations, "ignoreSendFailures", String.class); if (StringUtils.hasText(ignoreSendFailures)) { - router.setIgnoreSendFailures(Boolean.parseBoolean(this.environment.resolvePlaceholders(ignoreSendFailures))); + router.setIgnoreSendFailures(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(ignoreSendFailures))); } if (this.routerAttributesProvided(annotations)) { @@ -101,7 +100,7 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP String resolutionRequired = MessagingAnnotationUtils.resolveAttribute(annotations, "resolutionRequired", String.class); if (StringUtils.hasText(resolutionRequired)) { - String resolutionRequiredValue = this.environment.resolvePlaceholders(resolutionRequired); + String resolutionRequiredValue = this.beanFactory.resolveEmbeddedValue(resolutionRequired); if (StringUtils.hasText(resolutionRequiredValue)) { methodInvokingRouter.setResolutionRequired(Boolean.parseBoolean(resolutionRequiredValue)); } @@ -109,12 +108,12 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP String prefix = MessagingAnnotationUtils.resolveAttribute(annotations, "prefix", String.class); if (StringUtils.hasText(prefix)) { - methodInvokingRouter.setPrefix(this.environment.resolvePlaceholders(prefix)); + methodInvokingRouter.setPrefix(this.beanFactory.resolveEmbeddedValue(prefix)); } String suffix = MessagingAnnotationUtils.resolveAttribute(annotations, "suffix", String.class); if (StringUtils.hasText(suffix)) { - methodInvokingRouter.setSuffix(this.environment.resolvePlaceholders(suffix)); + methodInvokingRouter.setSuffix(this.beanFactory.resolveEmbeddedValue(suffix)); } String[] channelMappings = MessagingAnnotationUtils.resolveAttribute(annotations, "channelMappings", diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/ServiceActivatorAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/ServiceActivatorAnnotationPostProcessor.java index 4663505c40..c853dbcbf6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/ServiceActivatorAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/ServiceActivatorAnnotationPostProcessor.java @@ -21,11 +21,10 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.Lifecycle; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.handler.ServiceActivatingHandler; @@ -43,8 +42,8 @@ import org.springframework.util.StringUtils; */ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public ServiceActivatorAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public ServiceActivatorAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); this.messageHandlerAttributes.addAll(Arrays.asList("outputChannel", "requiresReply", "adviceChain")); } @@ -78,7 +77,7 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot String requiresReply = MessagingAnnotationUtils.resolveAttribute(annotations, "requiresReply", String.class); if (StringUtils.hasText(requiresReply)) { - serviceActivator.setRequiresReply(Boolean.parseBoolean(this.environment.resolvePlaceholders(requiresReply))); + serviceActivator.setRequiresReply(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(requiresReply))); } this.setOutputChannelIfPresent(annotations, serviceActivator); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/SplitterAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/SplitterAnnotationPostProcessor.java index ce565ea956..a4ce097011 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/SplitterAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/SplitterAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -21,10 +21,9 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.Splitter; import org.springframework.integration.splitter.AbstractMessageSplitter; import org.springframework.integration.splitter.MethodInvokingSplitter; @@ -42,8 +41,8 @@ import org.springframework.util.StringUtils; */ public class SplitterAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public SplitterAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public SplitterAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); this.messageHandlerAttributes.addAll(Arrays.asList("outputChannel", "applySequence", "adviceChain")); } @@ -75,7 +74,7 @@ public class SplitterAnnotationPostProcessor extends AbstractMethodAnnotationPos } if (StringUtils.hasText(applySequence)) { - String applySequenceValue = this.environment.resolvePlaceholders(applySequence); + String applySequenceValue = this.beanFactory.resolveEmbeddedValue(applySequence); if (StringUtils.hasText(applySequenceValue)) { splitter.setApplySequence(Boolean.parseBoolean(applySequenceValue)); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/TransformerAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/TransformerAnnotationPostProcessor.java index cd93963700..7c6719e8ea 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/TransformerAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/TransformerAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -21,10 +21,9 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; -import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.env.Environment; import org.springframework.integration.annotation.Transformer; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.transformer.MessageTransformingHandler; @@ -40,8 +39,8 @@ import org.springframework.messaging.MessageHandler; */ public class TransformerAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor { - public TransformerAnnotationPostProcessor(ListableBeanFactory beanFactory, Environment environment) { - super(beanFactory, environment); + public TransformerAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) { + super(beanFactory); this.messageHandlerAttributes.addAll(Arrays.asList("outputChannel", "adviceChain")); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessorTests.java index 7fad4cba82..eed8baedd9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/FilterAnnotationPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -29,17 +29,16 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import org.springframework.messaging.Message; import org.springframework.integration.annotation.Filter; import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice; -import org.springframework.messaging.support.GenericMessage; import org.springframework.integration.test.util.TestUtils; import org.springframework.integration.test.util.TestUtils.TestApplicationContext; -import org.springframework.mock.env.MockEnvironment; +import org.springframework.messaging.Message; +import org.springframework.messaging.support.GenericMessage; /** * @author Mark Fisher @@ -62,7 +61,6 @@ public class FilterAnnotationPostProcessorTests { context.registerChannel("input", inputChannel); context.registerChannel("output", outputChannel); postProcessor.setBeanFactory(context.getBeanFactory()); - postProcessor.setEnvironment(new MockEnvironment()); postProcessor.afterPropertiesSet(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests-context.xml index 0acd6e489d..8f990e3264 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests-context.xml @@ -1,10 +1,16 @@ + http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java index dd1e879784..2abd995bd4 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java @@ -618,7 +618,7 @@ public class EnableIntegrationTests { @ComponentScan @IntegrationComponentScan @EnableIntegration - @PropertySource("classpath:org/springframework/integration/configuration/EnableIntegrationTests.properties") +// INT-3853 @PropertySource("classpath:org/springframework/integration/configuration/EnableIntegrationTests.properties") @EnableMessageHistory({"input", "publishedChannel", "annotationTestService*"}) public static class ContextConfiguration { @@ -853,10 +853,12 @@ public class EnableIntegrationTests { @EnableReactor public static class ContextConfiguration2 { + /* + INT-3853 @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); - } + }*/ @Bean public MessageChannel sendAsyncChannel() { diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java index d9c6095e78..cbddcbd07d 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java @@ -89,8 +89,8 @@ public class EnableMBeanExportTests { assertThat(componentNamePatterns, arrayContaining("input", "inputX", "in*")); String[] enabledCounts = TestUtils.getPropertyValue(this.configurer, "enabledCountsPatterns", String[].class); assertThat(enabledCounts, arrayContaining("foo", "bar", "baz")); - String[] enabledStatts = TestUtils.getPropertyValue(this.configurer, "enabledStatsPatterns", String[].class); - assertThat(enabledStatts, arrayContaining("qux", "!*")); + String[] enabledStats = TestUtils.getPropertyValue(this.configurer, "enabledStatsPatterns", String[].class); + assertThat(enabledStats, arrayContaining("qux", "!*")); assertFalse(TestUtils.getPropertyValue(this.configurer, "defaultLoggingEnabled", Boolean.class)); assertTrue(TestUtils.getPropertyValue(this.configurer, "defaultCountsEnabled", Boolean.class)); assertTrue(TestUtils.getPropertyValue(this.configurer, "defaultStatsEnabled", Boolean.class)); @@ -153,7 +153,8 @@ public class EnableMBeanExportTests { } - public static class EnvironmentApplicationContextInitializer implements ApplicationContextInitializer { + public static class EnvironmentApplicationContextInitializer + implements ApplicationContextInitializer { @Override public void initialize(GenericApplicationContext applicationContext) {