org.springframework.context.expression
Class StandardBeanExpressionResolver

java.lang.Object
  extended by org.springframework.context.expression.StandardBeanExpressionResolver
All Implemented Interfaces:
BeanExpressionResolver

public class StandardBeanExpressionResolver
extends java.lang.Object
implements BeanExpressionResolver

Standard implementation of the BeanExpressionResolver interface, parsing and evaluating Spring EL using Spring's expression module.

Since:
3.0
Author:
Juergen Hoeller
See Also:
ExpressionParser, SpelExpressionParser, StandardEvaluationContext

Field Summary
private  ParserContext beanExpressionParserContext
           
static java.lang.String DEFAULT_EXPRESSION_PREFIX
          Default expression prefix: "#{"
static java.lang.String DEFAULT_EXPRESSION_SUFFIX
          Default expression suffix: "}"
private  java.util.Map<BeanExpressionContext,StandardEvaluationContext> evaluationCache
           
private  java.util.Map<java.lang.String,Expression> expressionCache
           
private  ExpressionParser expressionParser
           
private  java.lang.String expressionPrefix
           
private  java.lang.String expressionSuffix
           
 
Constructor Summary
StandardBeanExpressionResolver()
           
 
Method Summary
protected  void customizeEvaluationContext(StandardEvaluationContext evalContext)
          Template method for customizing the expression evaluation context.
 java.lang.Object evaluate(java.lang.String value, BeanExpressionContext evalContext)
          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(java.lang.String expressionPrefix)
          Set the prefix that an expression string starts with.
 void setExpressionSuffix(java.lang.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 Detail

DEFAULT_EXPRESSION_PREFIX

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

See Also:
Constant Field Values

DEFAULT_EXPRESSION_SUFFIX

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

See Also:
Constant Field Values

expressionPrefix

private java.lang.String expressionPrefix

expressionSuffix

private java.lang.String expressionSuffix

expressionParser

private ExpressionParser expressionParser

expressionCache

private final java.util.Map<java.lang.String,Expression> expressionCache

evaluationCache

private final java.util.Map<BeanExpressionContext,StandardEvaluationContext> evaluationCache

beanExpressionParserContext

private final ParserContext beanExpressionParserContext
Constructor Detail

StandardBeanExpressionResolver

public StandardBeanExpressionResolver()
Method Detail

setExpressionPrefix

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

See Also:
DEFAULT_EXPRESSION_PREFIX

setExpressionSuffix

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

See Also:
DEFAULT_EXPRESSION_SUFFIX

setExpressionParser

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

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


evaluate

public java.lang.Object evaluate(java.lang.String value,
                                 BeanExpressionContext evalContext)
                          throws BeansException
Description copied from interface: BeanExpressionResolver
Evaluate the given value as an expression, if applicable; return the value as-is otherwise.

Specified by:
evaluate in interface BeanExpressionResolver
Parameters:
value - the value to check
evalContext - the evaluation context
Returns:
the resolved value (potentially the given value as-is)
Throws:
BeansException - if evaluation failed

customizeEvaluationContext

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

The default implementation is empty.