INT-2594 added BF support to ExpressionEvaluatingCorrelationStrategy

This commit is contained in:
Oleg Zhurakousky
2012-06-12 12:27:08 -04:00
committed by Gary Russell
parent 8a4698d7cf
commit 8758aec3d1
3 changed files with 69 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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,6 +16,10 @@
package org.springframework.integration.aggregator;
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.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
@@ -28,11 +32,13 @@ import org.springframework.util.Assert;
* {@link CorrelationStrategy} implementation that evaluates an expression.
*
* @author Dave Syer
* @author Oleg Zhurakousky
*/
public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrategy {
public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrategy, BeanFactoryAware, InitializingBean{
private static final ExpressionParser expressionParser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
private volatile BeanFactory beanFactory;
private final ExpressionEvaluatingMessageProcessor<Object> processor;
@@ -48,8 +54,21 @@ public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrat
}
@Override
public Object getCorrelationKey(Message<?> message) {
return processor.processMessage(message);
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@Override
public void afterPropertiesSet() throws Exception {
if (this.beanFactory != null){
this.processor.setBeanFactory(this.beanFactory);
}
}
}