INT-847 Upgraded to Spring 3.0.0.RELEASE
This commit is contained in:
@@ -29,8 +29,8 @@ import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.ParseException;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParserConfiguration;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
@@ -55,9 +55,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor {
|
||||
|
||||
private final ExpressionSource expressionSource;
|
||||
|
||||
private final ExpressionParser parser = new SpelExpressionParser(
|
||||
SpelExpressionParserConfiguration.CreateObjectIfAttemptToReferenceNull |
|
||||
SpelExpressionParserConfiguration.GrowListsOnIndexBeyondSize);
|
||||
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
|
||||
private volatile ChannelResolver channelResolver;
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterRegistry;
|
||||
import org.springframework.core.convert.support.ConversionServiceFactory;
|
||||
@@ -331,7 +330,6 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper<Object[]
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object getValueFromMessageBasedOnEL(Message message, Class targetType, boolean rethrowException, String... expressions) {
|
||||
Object value = null;
|
||||
targetType = new TypeDescriptor(targetType).getObjectType(); //converts primitives to Object wrappers
|
||||
for (String expression : expressions) {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(message);
|
||||
context.setTypeConverter(new StandardTypeConverter(conversionService));
|
||||
@@ -339,7 +337,7 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper<Object[]
|
||||
Expression exp = expressionParser.parseExpression(expression);
|
||||
context.addPropertyAccessor(new MapAccessor());
|
||||
value = exp.getValue(context);
|
||||
if (value != null && this.canConvertToType(value, targetType)) {
|
||||
if (value != null && conversionService.canConvert(value.getClass(), targetType)) {
|
||||
// to accommodate Map->Properties conversion
|
||||
value = expression.equals("headers") ? conversionService.convert(value, targetType) : value;
|
||||
break;
|
||||
@@ -369,15 +367,6 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper<Object[]
|
||||
return parameterList;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean canConvertToType(Object value, Class targetType) {
|
||||
if (value instanceof String && Map.class.isAssignableFrom(targetType)) {
|
||||
// to address payload String "foo=bar" mapping to Properties/Map
|
||||
return ((String) value).indexOf("=") > 0;
|
||||
}
|
||||
return conversionService.canConvert(value.getClass(), targetType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void validateMessageMapppings(Message<?> message) {
|
||||
// Validate against a Map with no annotations
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.ParseException;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParserConfiguration;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
@@ -36,19 +36,13 @@ import org.springframework.integration.message.MessageHandlingException;
|
||||
*/
|
||||
public class ExpressionEvaluatingMessageProcessor implements MessageProcessor {
|
||||
|
||||
/*private final ExpressionParser parser = new SpelExpressionParser(
|
||||
SpelExpressionParserConfiguration.CreateObjectIfAttemptToReferenceNull |
|
||||
SpelExpressionParserConfiguration.GrowListsOnIndexBeyondSize);
|
||||
*/
|
||||
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
|
||||
private final Expression expression;
|
||||
|
||||
|
||||
public ExpressionEvaluatingMessageProcessor(String expression) {
|
||||
try {
|
||||
ExpressionParser parser = new SpelExpressionParser(
|
||||
SpelExpressionParserConfiguration.CreateObjectIfAttemptToReferenceNull |
|
||||
SpelExpressionParserConfiguration.GrowListsOnIndexBeyondSize);
|
||||
this.expression = parser.parseExpression(expression);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
@@ -56,6 +50,7 @@ public class ExpressionEvaluatingMessageProcessor implements MessageProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Object processMessage(Message<?> message) {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(message);
|
||||
context.addPropertyAccessor(new MapAccessor());
|
||||
|
||||
Reference in New Issue
Block a user