INT-3749: Get rid of IECA logic
JIRA: https://jira.spring.io/browse/INT-3749 Since `IntegrationEvaluationContextAware` isn't so "context-free" resource like `BeanFactory` and `ApplicationContext`, but just a specific bean in the context, we can't follow with `BeanPostProcessor` logic - bad architecture by level of responsibility. Therefore we should follow with standard Dependency Injection mechanism to retrieve `evaluationContext` for the particular component. Since we can't rely on the `@Autowired` because SI can be used from the raw XML configuration, we use utility method instead. The pattern to get the proper `integrationEvaluationContext` is: ``` @Override protected void onInit() throws Exception { super.onInit(); this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); } ```
This commit is contained in:
committed by
Gary Russell
parent
fe98cbc4e0
commit
3392d4e1ab
@@ -24,10 +24,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -38,7 +34,7 @@ import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.expression.IntegrationEvaluationContextAware;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.handler.AbstractMessageProducingHandler;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
@@ -56,6 +52,10 @@ import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Abstract Message handler that holds a buffer of correlated messages in a
|
||||
* {@link MessageStore}. This class takes care of correlated groups of messages
|
||||
@@ -82,7 +82,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageProducingHandler
|
||||
implements DisposableBean, IntegrationEvaluationContextAware, ApplicationEventPublisherAware {
|
||||
implements DisposableBean, ApplicationEventPublisherAware {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AbstractCorrelatingMessageHandler.class);
|
||||
|
||||
@@ -185,11 +185,6 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
this.forceReleaseAdviceChain = forceReleaseAdviceChain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {
|
||||
this.evaluationContext = evaluationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskScheduler(TaskScheduler taskScheduler) {
|
||||
super.setTaskScheduler(taskScheduler);
|
||||
@@ -229,6 +224,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
((SequenceSizeReleaseStrategy) this.releaseStrategy).setReleasePartialSequences(releasePartialSequences);
|
||||
}
|
||||
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
|
||||
/*
|
||||
* Disallow any further changes to the lock registry
|
||||
* (checked in the setter).
|
||||
|
||||
@@ -23,9 +23,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -47,12 +44,14 @@ import org.springframework.integration.channel.DefaultHeaderChannelRegistry;
|
||||
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.context.IntegrationProperties;
|
||||
import org.springframework.integration.expression.IntegrationEvaluationContextAwareBeanPostProcessor;
|
||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||
import org.springframework.integration.support.converter.DefaultDatatypeChannelMessageConverter;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* {@link ImportBeanDefinitionRegistrar} implementation that configures integration infrastructure.
|
||||
*
|
||||
@@ -87,9 +86,11 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean
|
||||
* to register the messaging annotation post processors (for {@code <int:annotation-config/>}).
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
||||
this.registerImplicitChannelCreator(registry);
|
||||
this.registerIntegrationConfigurationBeanFactoryPostProcessor(registry);
|
||||
//TODO remove this line in the 4.3
|
||||
this.registerIntegrationEvaluationContext(registry);
|
||||
this.registerIntegrationProperties(registry);
|
||||
this.registerHeaderChannelRegistry(registry);
|
||||
@@ -174,9 +175,14 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean
|
||||
|
||||
/**
|
||||
* Register {@link IntegrationEvaluationContextFactoryBean} bean
|
||||
* and {@link IntegrationEvaluationContextAwareBeanPostProcessor}, if necessary.
|
||||
* and {@code IntegrationEvaluationContextAwareBeanPostProcessor}, if necessary.
|
||||
* @param registry The {@link BeanDefinitionRegistry} to register additional {@link BeanDefinition}s.
|
||||
* @deprecated since 4.2 in favor of {@link IntegrationContextUtils#getEvaluationContext}
|
||||
* direct usage from the {@code afterPropertiesSet} implementation.
|
||||
* Will be removed in the next release.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
private void registerIntegrationEvaluationContext(BeanDefinitionRegistry registry) {
|
||||
if (!registry.containsBeanDefinition(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME)) {
|
||||
BeanDefinitionBuilder integrationEvaluationContextBuilder = BeanDefinitionBuilder
|
||||
@@ -191,7 +197,7 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean
|
||||
registry);
|
||||
|
||||
RootBeanDefinition integrationEvalContextBPP =
|
||||
new RootBeanDefinition(IntegrationEvaluationContextAwareBeanPostProcessor.class);
|
||||
new RootBeanDefinition(org.springframework.integration.expression.IntegrationEvaluationContextAwareBeanPostProcessor.class);
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(integrationEvalContextBPP, registry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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. You may obtain a copy of the License at
|
||||
@@ -10,13 +10,13 @@
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.expression.IntegrationEvaluationContextAware;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
* @since 2.1
|
||||
*
|
||||
*/
|
||||
public abstract class ExpressionMessageProducerSupport extends MessageProducerSupport implements IntegrationEvaluationContextAware {
|
||||
public abstract class ExpressionMessageProducerSupport extends MessageProducerSupport {
|
||||
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@@ -56,17 +56,10 @@ public abstract class ExpressionMessageProducerSupport extends MessageProducerSu
|
||||
this.payloadExpression = payloadExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {
|
||||
this.evaluationContext = evaluationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
super.onInit();
|
||||
if (this.evaluationContext == null) {
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
|
||||
}
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
}
|
||||
|
||||
protected Object evaluatePayloadExpression(Object payload){
|
||||
|
||||
@@ -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.
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.integration.expression;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.context.expression.MapAccessor;
|
||||
@@ -28,6 +25,9 @@ import org.springframework.expression.spel.support.StandardTypeConverter;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Utility class with static methods for helping with establishing environments for
|
||||
* SpEL expressions.
|
||||
@@ -76,7 +76,7 @@ public abstract class ExpressionUtils {
|
||||
*/
|
||||
public static StandardEvaluationContext createStandardEvaluationContext(BeanFactory beanFactory) {
|
||||
if (beanFactory == null) {
|
||||
logger.warn("Creating EvaluationContext with no beanFactory", new RuntimeException("No beanfactory"));
|
||||
logger.warn("Creating EvaluationContext with no beanFactory", new RuntimeException("No beanFactory"));
|
||||
}
|
||||
return doCreateContext(beanFactory);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.expression;
|
||||
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by beans that wish to be aware of their
|
||||
@@ -24,7 +25,7 @@ import org.springframework.expression.EvaluationContext;
|
||||
* {@link org.springframework.integration.config.IntegrationEvaluationContextFactoryBean}
|
||||
* <p>
|
||||
* The {@link #setIntegrationEvaluationContext} is invoked from
|
||||
* the {@link IntegrationEvaluationContextAwareBeanPostProcessor#afterSingletonsInstantiated()},
|
||||
* the {@code IntegrationEvaluationContextAwareBeanPostProcessor#afterSingletonsInstantiated()},
|
||||
* not during standard {@code postProcessBefore(After)Initialization} to avoid any
|
||||
* {@code BeanFactory} early access during integration {@link EvaluationContext} retrieval.
|
||||
* Therefore, if it is necessary to use {@link EvaluationContext} in the {@code afterPropertiesSet()},
|
||||
@@ -33,8 +34,11 @@ import org.springframework.expression.EvaluationContext;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @since 3.0
|
||||
* @see IntegrationEvaluationContextAwareBeanPostProcessor
|
||||
* @deprecated since 4.2 in favor of {@link IntegrationContextUtils#getEvaluationContext}
|
||||
* direct usage from the {@code afterPropertiesSet} implementation.
|
||||
* Will be removed in the next release.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IntegrationEvaluationContextAware {
|
||||
|
||||
void setIntegrationEvaluationContext(EvaluationContext evaluationContext);
|
||||
|
||||
@@ -32,7 +32,12 @@ import org.springframework.integration.context.IntegrationContextUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 3.0
|
||||
* @deprecated since 4.2 in favor of {@link IntegrationContextUtils#getEvaluationContext}
|
||||
* direct usage from the {@code afterPropertiesSet} implementation.
|
||||
* Will be removed in the next release.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IntegrationEvaluationContextAwareBeanPostProcessor
|
||||
implements BeanPostProcessor, Ordered, BeanFactoryAware, SmartInitializingSingleton {
|
||||
|
||||
@@ -71,5 +76,5 @@ public class IntegrationEvaluationContextAwareBeanPostProcessor
|
||||
public int getOrder() {
|
||||
return LOWEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -16,11 +16,15 @@
|
||||
|
||||
package org.springframework.integration.routingslip;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.expression.IntegrationEvaluationContextAware;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -57,7 +61,7 @@ import org.springframework.messaging.Message;
|
||||
* @since 4.1
|
||||
*/
|
||||
public class ExpressionEvaluatingRoutingSlipRouteStrategy
|
||||
implements RoutingSlipRouteStrategy, IntegrationEvaluationContextAware {
|
||||
implements RoutingSlipRouteStrategy, BeanFactoryAware, InitializingBean {
|
||||
|
||||
private static final ExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@@ -65,6 +69,8 @@ public class ExpressionEvaluatingRoutingSlipRouteStrategy
|
||||
|
||||
private EvaluationContext evaluationContext;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
public ExpressionEvaluatingRoutingSlipRouteStrategy(String expression) {
|
||||
this(PARSER.parseExpression(expression));
|
||||
}
|
||||
@@ -74,8 +80,13 @@ public class ExpressionEvaluatingRoutingSlipRouteStrategy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {
|
||||
this.evaluationContext = evaluationContext;
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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
|
||||
@@ -24,7 +24,6 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.expression.IntegrationEvaluationContextAware;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
@@ -56,7 +55,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
*/
|
||||
public class ExpressionEvaluatingTransactionSynchronizationProcessor extends IntegrationObjectSupport
|
||||
implements TransactionSynchronizationProcessor, IntegrationEvaluationContextAware {
|
||||
implements TransactionSynchronizationProcessor {
|
||||
|
||||
private volatile EvaluationContext evaluationContext;
|
||||
|
||||
@@ -72,11 +71,6 @@ public class ExpressionEvaluatingTransactionSynchronizationProcessor extends Int
|
||||
|
||||
private volatile MessageChannel afterRollbackChannel = new NullChannel();
|
||||
|
||||
@Override
|
||||
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {
|
||||
this.evaluationContext = evaluationContext;
|
||||
}
|
||||
|
||||
public void setBeforeCommitChannel(MessageChannel beforeCommitChannel) {
|
||||
Assert.notNull(beforeCommitChannel, "'beforeCommitChannel' must not be null");
|
||||
this.beforeCommitChannel = beforeCommitChannel;
|
||||
@@ -107,6 +101,12 @@ public class ExpressionEvaluatingTransactionSynchronizationProcessor extends Int
|
||||
this.afterRollbackExpression = afterRollbackExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
super.onInit();
|
||||
this.evaluationContext = createEvaluationContext();
|
||||
}
|
||||
|
||||
public void processBeforeCommit(IntegrationResourceHolder holder) {
|
||||
this.doProcess(holder, this.beforeCommitExpression, this.beforeCommitChannel, "beforeCommit");
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -28,7 +28,6 @@ import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.expression.IntegrationEvaluationContextAware;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
|
||||
@@ -53,7 +52,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ContentEnricher extends AbstractReplyProducingMessageHandler
|
||||
implements Lifecycle, IntegrationEvaluationContextAware {
|
||||
implements Lifecycle {
|
||||
|
||||
private final SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
|
||||
@@ -245,11 +244,6 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler
|
||||
this.shouldClonePayload = shouldClonePayload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {
|
||||
this.sourceEvaluationContext = evaluationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "enricher";
|
||||
@@ -309,9 +303,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler
|
||||
this.gateway.afterPropertiesSet();
|
||||
}
|
||||
|
||||
if (this.sourceEvaluationContext == null) {
|
||||
this.sourceEvaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
}
|
||||
this.sourceEvaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
|
||||
StandardEvaluationContext targetContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
// bean resolution is NOT allowed for the target of the enrichment
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.util.Map;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.routingslip.ExpressionEvaluatingRoutingSlipRouteStrategy;
|
||||
import org.springframework.integration.routingslip.RoutingSlipRouteStrategy;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -51,8 +49,6 @@ public class RoutingSlipHeaderValueMessageProcessor
|
||||
|
||||
private final List<Object> routingSlipPath;
|
||||
|
||||
private EvaluationContext evaluationContext;
|
||||
|
||||
private volatile Map<List<Object>, Integer> routingSlip;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
@@ -74,9 +70,8 @@ public class RoutingSlipHeaderValueMessageProcessor
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
Assert.notNull(beanFactory, "BeanFactory must not be null");
|
||||
Assert.notNull(beanFactory, "beanFactory must not be null");
|
||||
this.beanFactory = beanFactory;//NOSONAR (inconsistent sync)
|
||||
this.evaluationContext = IntegrationContextUtils.getEvaluationContext(beanFactory);//NOSONAR (inconsistent sync)
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,7 +99,13 @@ public class RoutingSlipHeaderValueMessageProcessor
|
||||
else {
|
||||
ExpressionEvaluatingRoutingSlipRouteStrategy strategy = new
|
||||
ExpressionEvaluatingRoutingSlipRouteStrategy(entry);
|
||||
strategy.setIntegrationEvaluationContext(this.evaluationContext);
|
||||
strategy.setBeanFactory(this.beanFactory);
|
||||
try {
|
||||
strategy.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
routingSlipValues.add(strategy);
|
||||
}
|
||||
}
|
||||
@@ -120,4 +121,5 @@ public class RoutingSlipHeaderValueMessageProcessor
|
||||
}
|
||||
return routingSlip;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -27,12 +27,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
@@ -42,6 +38,9 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
* @author Alex Peters
|
||||
@@ -328,7 +327,6 @@ public class ResequencerTests {
|
||||
@Test
|
||||
public void testTimeoutDefaultExpiry() throws InterruptedException {
|
||||
this.resequencer.setGroupTimeoutExpression(new SpelExpressionParser().parseExpression("100"));
|
||||
this.resequencer.setIntegrationEvaluationContext(new StandardEvaluationContext());
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.afterPropertiesSet();
|
||||
this.resequencer.setTaskScheduler(taskScheduler);
|
||||
@@ -336,6 +334,7 @@ public class ResequencerTests {
|
||||
this.resequencer.setDiscardChannel(discardChannel);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
this.resequencer.setOutputChannel(replyChannel);
|
||||
|
||||
Message<?> message3 = createMessage("789", "ABC", 3, 3, null);
|
||||
Message<?> message2 = createMessage("456", "ABC", 3, 2, null);
|
||||
this.resequencer.handleMessage(message3);
|
||||
@@ -355,7 +354,6 @@ public class ResequencerTests {
|
||||
@Test
|
||||
public void testTimeoutDontExpire() throws InterruptedException {
|
||||
this.resequencer.setGroupTimeoutExpression(new SpelExpressionParser().parseExpression("100"));
|
||||
this.resequencer.setIntegrationEvaluationContext(new StandardEvaluationContext());
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.afterPropertiesSet();
|
||||
this.resequencer.setTaskScheduler(taskScheduler);
|
||||
@@ -364,6 +362,7 @@ public class ResequencerTests {
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
this.resequencer.setOutputChannel(replyChannel);
|
||||
this.resequencer.setExpireGroupsUponTimeout(true);
|
||||
|
||||
Message<?> message3 = createMessage("789", "ABC", 3, 3, null);
|
||||
Message<?> message2 = createMessage("456", "ABC", 3, 2, null);
|
||||
this.resequencer.handleMessage(message3);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -33,9 +33,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
@@ -52,6 +53,9 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
@@ -207,11 +211,18 @@ public class ParentContextTests {
|
||||
parent.close();
|
||||
}
|
||||
|
||||
public static class Foo implements IntegrationEvaluationContextAware {
|
||||
public static class Foo implements BeanFactoryAware, InitializingBean {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {
|
||||
evalContexts.add(evaluationContext);
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
evalContexts.add(ExpressionUtils.createStandardEvaluationContext(this.beanFactory));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user