Package org.springframework.context.expression

# Class StandardBeanExpressionResolver

java.lang.Object
org.springframework.context.expression.StandardBeanExpressionResolver

All Implemented Interfaces:
  `org.springframework.beans.factory.config.BeanExpressionResolver`

public class StandardBeanExpressionResolver extends Object implements org.springframework.beans.factory.config.BeanExpressionResolver
Standard implementation of the `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".

Since:
  3.0
Author:
  Juergen Hoeller, Sam Brannen
See Also:
  - `BeanExpressionContext.getBeanFactory()`
  - `ExpressionParser`
  - `SpelExpressionParser`
  - `StandardEvaluationContext`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_EXPRESSION_PREFIX`
Default expression prefix: "#{".
`static final String`
`DEFAULT_EXPRESSION_SUFFIX`
Default expression suffix: "}".
`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

Constructors
Constructor
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.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`customizeEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext evalContext)`
Template method for customizing the expression evaluation context.
`Object`
`evaluate(String value, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext)`
`void`
`setExpressionParser(org.springframework.expression.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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME

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()`
  - Constant Field Values

### DEFAULT_EXPRESSION_PREFIX

public static final String DEFAULT_EXPRESSION_PREFIX
Default expression prefix: "#{".

See Also:
  - Constant Field Values

### DEFAULT_EXPRESSION_SUFFIX

public static final String DEFAULT_EXPRESSION_SUFFIX
Default expression suffix: "}".

See Also:
  - Constant Field Values

## Constructor Details

### StandardBeanExpressionResolver

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.

### StandardBeanExpressionResolver

public StandardBeanExpressionResolver(@Nullable 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` - the factory's bean class loader

## Method Details

### setExpressionPrefix

public void setExpressionPrefix(String expressionPrefix)
Set the prefix that an expression string starts with. The default is "#{".

See Also:
  - `DEFAULT_EXPRESSION_PREFIX`

### setExpressionSuffix

public void setExpressionSuffix(String expressionSuffix)
Set the suffix that an expression string ends with. The default is "}".

See Also:
  - `DEFAULT_EXPRESSION_SUFFIX`

### setExpressionParser

public void setExpressionParser(org.springframework.expression.ExpressionParser expressionParser)
Specify the EL parser to use for expression parsing.

Default is a `SpelExpressionParser`, compatible with standard Unified EL style expression syntax.

### evaluate

@Nullable public Object evaluate(@Nullable String value, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext) throws org.springframework.beans.BeansException

Specified by:
  `evaluate` in interface `org.springframework.beans.factory.config.BeanExpressionResolver`
Throws:
  `org.springframework.beans.BeansException`

### customizeEvaluationContext

protected void customizeEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext evalContext)
Template method for customizing the expression evaluation context.

The default implementation is empty.