Merge branch '5.3.x'
This commit is contained in:
		
						commit
						d11389e783
					
				| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright 2002-2017 the original author or authors.
 | 
					 * Copyright 2002-2022 the original author or authors.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 * you may not use this file except in compliance with the License.
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
| 
						 | 
					@ -20,8 +20,8 @@ import org.springframework.beans.BeansException;
 | 
				
			||||||
import org.springframework.lang.Nullable;
 | 
					import org.springframework.lang.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Strategy interface for resolving a value through evaluating it
 | 
					 * Strategy interface for resolving a value by evaluating it as an expression,
 | 
				
			||||||
 * as an expression, if applicable.
 | 
					 * if applicable.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * <p>A raw {@link org.springframework.beans.factory.BeanFactory} does not
 | 
					 * <p>A raw {@link org.springframework.beans.factory.BeanFactory} does not
 | 
				
			||||||
 * contain a default implementation of this strategy. However,
 | 
					 * contain a default implementation of this strategy. However,
 | 
				
			||||||
| 
						 | 
					@ -36,12 +36,13 @@ public interface BeanExpressionResolver {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Evaluate the given value as an expression, if applicable;
 | 
						 * Evaluate the given value as an expression, if applicable;
 | 
				
			||||||
	 * return the value as-is otherwise.
 | 
						 * return the value as-is otherwise.
 | 
				
			||||||
	 * @param value the value to check
 | 
						 * @param value the value to evaluate as an expression
 | 
				
			||||||
	 * @param evalContext the evaluation context
 | 
						 * @param beanExpressionContext the bean expression context to use when
 | 
				
			||||||
 | 
						 * evaluating the expression
 | 
				
			||||||
	 * @return the resolved value (potentially the given value as-is)
 | 
						 * @return the resolved value (potentially the given value as-is)
 | 
				
			||||||
	 * @throws BeansException if evaluation failed
 | 
						 * @throws BeansException if evaluation failed
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	@Nullable
 | 
						@Nullable
 | 
				
			||||||
	Object evaluate(@Nullable String value, BeanExpressionContext evalContext) throws BeansException;
 | 
						Object evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) throws BeansException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,7 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	@Nullable
 | 
						@Nullable
 | 
				
			||||||
	public Object evaluate(@Nullable String value, BeanExpressionContext evalContext) throws BeansException {
 | 
						public Object evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) throws BeansException {
 | 
				
			||||||
		if (!StringUtils.hasLength(value)) {
 | 
							if (!StringUtils.hasLength(value)) {
 | 
				
			||||||
			return value;
 | 
								return value;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -148,21 +148,21 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
 | 
				
			||||||
				expr = this.expressionParser.parseExpression(value, this.beanExpressionParserContext);
 | 
									expr = this.expressionParser.parseExpression(value, this.beanExpressionParserContext);
 | 
				
			||||||
				this.expressionCache.put(value, expr);
 | 
									this.expressionCache.put(value, expr);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			StandardEvaluationContext sec = this.evaluationCache.get(evalContext);
 | 
								StandardEvaluationContext sec = this.evaluationCache.get(beanExpressionContext);
 | 
				
			||||||
			if (sec == null) {
 | 
								if (sec == null) {
 | 
				
			||||||
				sec = new StandardEvaluationContext(evalContext);
 | 
									sec = new StandardEvaluationContext(beanExpressionContext);
 | 
				
			||||||
				sec.addPropertyAccessor(new BeanExpressionContextAccessor());
 | 
									sec.addPropertyAccessor(new BeanExpressionContextAccessor());
 | 
				
			||||||
				sec.addPropertyAccessor(new BeanFactoryAccessor());
 | 
									sec.addPropertyAccessor(new BeanFactoryAccessor());
 | 
				
			||||||
				sec.addPropertyAccessor(new MapAccessor());
 | 
									sec.addPropertyAccessor(new MapAccessor());
 | 
				
			||||||
				sec.addPropertyAccessor(new EnvironmentAccessor());
 | 
									sec.addPropertyAccessor(new EnvironmentAccessor());
 | 
				
			||||||
				sec.setBeanResolver(new BeanFactoryResolver(evalContext.getBeanFactory()));
 | 
									sec.setBeanResolver(new BeanFactoryResolver(beanExpressionContext.getBeanFactory()));
 | 
				
			||||||
				sec.setTypeLocator(new StandardTypeLocator(evalContext.getBeanFactory().getBeanClassLoader()));
 | 
									sec.setTypeLocator(new StandardTypeLocator(beanExpressionContext.getBeanFactory().getBeanClassLoader()));
 | 
				
			||||||
				sec.setTypeConverter(new StandardTypeConverter(() -> {
 | 
									sec.setTypeConverter(new StandardTypeConverter(() -> {
 | 
				
			||||||
					ConversionService cs = evalContext.getBeanFactory().getConversionService();
 | 
										ConversionService cs = beanExpressionContext.getBeanFactory().getConversionService();
 | 
				
			||||||
					return (cs != null ? cs : DefaultConversionService.getSharedInstance());
 | 
										return (cs != null ? cs : DefaultConversionService.getSharedInstance());
 | 
				
			||||||
				}));
 | 
									}));
 | 
				
			||||||
				customizeEvaluationContext(sec);
 | 
									customizeEvaluationContext(sec);
 | 
				
			||||||
				this.evaluationCache.put(evalContext, sec);
 | 
									this.evaluationCache.put(beanExpressionContext, sec);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			return expr.getValue(sec);
 | 
								return expr.getValue(sec);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue