public class StandardBeanExpressionResolver extends Object implements BeanExpressionResolver
BeanExpressionResolver
interface, parsing and evaluating Spring EL using Spring's expression module.
All beans in the containing BeanFactory
are made available as
predefined variables with their common bean name, including standard context
beans such as "environment", "systemProperties" and "systemEnvironment".
BeanExpressionContext.getBeanFactory()
,
ExpressionParser
,
SpelExpressionParser
,
StandardEvaluationContext
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_EXPRESSION_PREFIX
Default expression prefix: "#{".
|
static String |
DEFAULT_EXPRESSION_SUFFIX
Default expression suffix: "}".
|
Constructor and Description |
---|
StandardBeanExpressionResolver()
Create a new
StandardBeanExpressionResolver with default settings. |
StandardBeanExpressionResolver(ClassLoader beanClassLoader)
Create a new
StandardBeanExpressionResolver with the given bean class loader,
using it as the basis for expression compilation. |
Modifier and Type | Method and Description |
---|---|
protected void |
customizeEvaluationContext(StandardEvaluationContext evalContext)
Template method for customizing the expression evaluation context.
|
Object |
evaluate(String value,
BeanExpressionContext beanExpressionContext)
Evaluate the given value as an expression, if applicable;
return the value as-is otherwise.
|
void |
setExpressionParser(ExpressionParser expressionParser)
Specify the EL parser to use for expression parsing.
|
void |
setExpressionPrefix(String expressionPrefix)
Set the prefix that an expression string starts with.
|
void |
setExpressionSuffix(String expressionSuffix)
Set the suffix that an expression string ends with.
|
public static final String DEFAULT_EXPRESSION_PREFIX
public static final String DEFAULT_EXPRESSION_SUFFIX
public StandardBeanExpressionResolver()
StandardBeanExpressionResolver
with default settings.public StandardBeanExpressionResolver(@Nullable ClassLoader beanClassLoader)
StandardBeanExpressionResolver
with the given bean class loader,
using it as the basis for expression compilation.beanClassLoader
- the factory's bean class loaderpublic void setExpressionPrefix(String expressionPrefix)
DEFAULT_EXPRESSION_PREFIX
public void setExpressionSuffix(String expressionSuffix)
DEFAULT_EXPRESSION_SUFFIX
public void setExpressionParser(ExpressionParser expressionParser)
Default is a SpelExpressionParser
,
compatible with standard Unified EL style expression syntax.
@Nullable public Object evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) throws BeansException
BeanExpressionResolver
evaluate
in interface BeanExpressionResolver
value
- the value to evaluate as an expressionbeanExpressionContext
- the bean expression context to use when
evaluating the expressionBeansException
- if evaluation failedprotected void customizeEvaluationContext(StandardEvaluationContext evalContext)
The default implementation is empty.