ThreadLocal<StandardEvaluationContext> evaluationContext = new ThreadLocal<StandardEvaluationContext>() {
@Override
protected StandardEvaluationContext initialValue() {
StandardEvaluationContext ec = new StandardEvaluationContext();
if (useMapAccessor) {
ec.addPropertyAccessor(new MapAccessor());
}
if (useBeanAccessor) {
ec.addPropertyAccessor(new BeanFactoryAccessor());
ec.setRootObject(applicationContext);
}
if (useBeanResolver) {
ec.setBeanResolver(new BeanFactoryResolver(applicationContext));
}
if (defaultRootObject != null) {
ec.setRootObject(defaultRootObject);
if (!useMapAccessor && defaultRootObject instanceof Map)
ec.addPropertyAccessor(new MapAccessor());
}
return ec;
}
};
ThreadLocal<Expression> expression = new ThreadLocal<Expression>();
@Override
public SpelEvaluator setVariables(Map<String, Object> variables) {
evaluationContext.get().setVariables(variables);
evaluationContext.get().addPropertyAccessor(new MapAccessor());
return this;
}
@Override
public SpelEvaluator setVariable(String name, Object value) {
evaluationContext.get().setVariable(name, value);
return this;
}
@Override
public SpelEvaluator setRootObject(Object rootObject) {
evaluationContext.get().setRootObject(rootObject);
if (!useMapAccessor && rootObject instanceof Map) {
evaluationContext.get().addPropertyAccessor(new MapAccessor());
}
return this;
}
private boolean isExpression(String expressionString) {