Top Description Fields Constructors Methods
org.springframework.context.expression

public Class StandardBeanExpressionResolver

extends Object
implements BeanExpressionResolver
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.config.BeanExpressionResolver
Imports
java.util.Map, java.util.concurrent.ConcurrentHashMap, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanExpressionException, org.springframework.beans.factory.config.BeanExpressionContext, .BeanExpressionResolver, org.springframework.core.SpringProperties, org.springframework.core.convert.ConversionService, org.springframework.core.convert.support.DefaultConversionService, org.springframework.expression.Expression, .ExpressionParser, .ParserContext, org.springframework.expression.spel.SpelParserConfiguration, org.springframework.expression.spel.standard.SpelExpressionParser, org.springframework.expression.spel.support.StandardEvaluationContext, .StandardTypeConverter, .StandardTypeLocator, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

Standard implementation of the org.springframework.beans.factory.config.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".

Authors
Juergen Hoeller, Sam Brannen
Since
3.0
See Also
BeanExpressionContext#getBeanFactory(), org.springframework.expression.ExpressionParser, org.springframework.expression.spel.standard.SpelExpressionParser, org.springframework.expression.spel.support.StandardEvaluationContext

Field Summary

Modifier and TypeField and Description
private final ParserContext
public static final String
DEFAULT_EXPRESSION_PREFIX

Default expression prefix: "#{".

public static final String
DEFAULT_EXPRESSION_SUFFIX

Default expression suffix: "}".

private final Map<BeanExpressionContext, StandardEvaluationContext>
private final Map<String, Expression>
private ExpressionParser
private String
private String
public static final String
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME

System property to configure the maximum length for SpEL expressions: spring.context.expression.maxLength.

Constructor Summary

AccessConstructor and Description
public
StandardBeanExpressionResolver()

Create a new StandardBeanExpressionResolver with default settings.

public
StandardBeanExpressionResolver(ClassLoader
the factory's bean class loader
beanClassLoader
)

Create a new StandardBeanExpressionResolver with the given bean class loader, using it as the basis for expression compilation.

Method Summary

Modifier and TypeMethod and Description
protected void
customizeEvaluationContext(StandardEvaluationContext evalContext)

Template method for customizing the expression evaluation context.

public Object
evaluate(String
the value to evaluate as an expression
value
,
BeanExpressionContext
the bean expression context to use when evaluating the expression
beanExpressionContext
)

Implements org.springframework.beans.factory.config.BeanExpressionResolver.evaluate.

Evaluate the given value as an expression, if applicable; return the value as-is otherwise.
private static int
public void
setExpressionParser(ExpressionParser expressionParser)

Specify the EL parser to use for expression parsing.

public void
setExpressionPrefix(String expressionPrefix)

Set the prefix that an expression string starts with.

public void
setExpressionSuffix(String expressionSuffix)

Set the suffix that an expression string ends with.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanExpressionParserContextback to summary
private final ParserContext beanExpressionParserContext
DEFAULT_EXPRESSION_PREFIXback to summary
public static final String DEFAULT_EXPRESSION_PREFIX

Default expression prefix: "#{".

DEFAULT_EXPRESSION_SUFFIXback to summary
public static final String DEFAULT_EXPRESSION_SUFFIX

Default expression suffix: "}".

evaluationCacheback to summary
private final Map<BeanExpressionContext, StandardEvaluationContext> evaluationCache
expressionCacheback to summary
private final Map<String, Expression> expressionCache
expressionParserback to summary
private ExpressionParser expressionParser
expressionPrefixback to summary
private String expressionPrefix
expressionSuffixback to summary
private String expressionSuffix
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAMEback to summary
public static final String MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME

System property to configure the maximum length for SpEL expressions: spring.context.expression.maxLength.

Can also be configured via the SpringProperties mechanism.

Since
6.1.3
See Also
SpelParserConfiguration#getMaximumExpressionLength()

Constructor Detail

StandardBeanExpressionResolverback to summary
public StandardBeanExpressionResolver()

Create a new StandardBeanExpressionResolver with default settings.

As of Spring Framework 6.1.3, the maximum SpEL expression length can be configured via the MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME property.

StandardBeanExpressionResolverback to summary
public StandardBeanExpressionResolver(ClassLoader beanClassLoader)

Create a new StandardBeanExpressionResolver with the given bean class loader, using it as the basis for expression compilation.

As of Spring Framework 6.1.3, the maximum SpEL expression length can be configured via the MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME property.

Parameters
beanClassLoader:ClassLoader

the factory's bean class loader

Method Detail

customizeEvaluationContextback to summary
protected void customizeEvaluationContext(StandardEvaluationContext evalContext)

Template method for customizing the expression evaluation context.

The default implementation is empty.

evaluateback to summary
public Object evaluate(String value, BeanExpressionContext beanExpressionContext) throws BeansException

Implements org.springframework.beans.factory.config.BeanExpressionResolver.evaluate.

Doc from org.springframework.beans.factory.config.BeanExpressionResolver.evaluate.

Evaluate the given value as an expression, if applicable; return the value as-is otherwise.

Parameters
value:String

the value to evaluate as an expression

beanExpressionContext:BeanExpressionContext

the bean expression context to use when evaluating the expression

Returns:Object

the resolved value (potentially the given value as-is)

Annotations
@Override
@Nullable
Exceptions
BeansException:
if evaluation failed
retrieveMaxExpressionLengthback to summary
private static int retrieveMaxExpressionLength()
setExpressionParserback to summary
public void setExpressionParser(ExpressionParser expressionParser)

Specify the EL parser to use for expression parsing.

Default is a org.springframework.expression.spel.standard.SpelExpressionParser, compatible with standard Unified EL style expression syntax.

setExpressionPrefixback to summary
public void setExpressionPrefix(String expressionPrefix)

Set the prefix that an expression string starts with. The default is "#{".

See Also
DEFAULT_EXPRESSION_PREFIX
setExpressionSuffixback to summary
public void setExpressionSuffix(String expressionSuffix)

Set the suffix that an expression string ends with. The default is "}".

See Also
DEFAULT_EXPRESSION_SUFFIX