Enum Class SpelCompilerMode
- All Implemented Interfaces:
Serializable
,Comparable<SpelCompilerMode>
,Constable
Spring provides a basic compiler for SpEL expressions. Expressions are usually interpreted, which provides a lot of dynamic flexibility during evaluation but does not provide optimum performance. For occasional expression usage, this is fine, but when used by other components such as Spring Integration, performance can be very important, and there is no real need for the dynamism.
The SpEL compiler is intended to address this need. During evaluation, the compiler generates a Java class that embodies the expression behavior at runtime and uses that class to achieve much faster expression evaluation. Due to the lack of typing around expressions, the compiler uses information gathered during the interpreted evaluations of an expression when performing compilation. For example, SpEL does not know the type of a property reference purely from the expression, but during the first interpreted evaluation, it finds out what it is. Of course, basing compilation on such derived information can cause trouble later if the types of the various expression elements change over time. For this reason, compilation is best suited to expressions whose type information is not going to change on repeated evaluations.
- Since:
- 4.1
- Author:
- Andy Clement, Sam Brannen
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionIn immediate mode, expressions are compiled as soon as possible, typically after the first interpreted evaluation.In mixed mode, expression evaluation silently switches between interpreted and compiled over time.The compiler is turned off, and all expressions will be evaluated in interpreted mode. -
Method Summary
Modifier and TypeMethodDescriptionstatic SpelCompilerMode
Returns the enum constant of this class with the specified name.static SpelCompilerMode[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
OFF
The compiler is turned off, and all expressions will be evaluated in interpreted mode.This is the default.
-
IMMEDIATE
In immediate mode, expressions are compiled as soon as possible, typically after the first interpreted evaluation.If evaluation of the compiled expression fails (for example, due to a type changing), the caller of the expression evaluation receives an exception.
If the types of various expression elements change over time, consider switching to
MIXED
mode or turning off the compiler. -
MIXED
In mixed mode, expression evaluation silently switches between interpreted and compiled over time.After some number of successful interpreted runs, the expression gets compiled. If evaluation of the compiled expression fails (for example, due to a type changing), that failure will be caught internally, and the system will switch back to interpreted mode for the given expression. Basically, the exception that the caller receives in
IMMEDIATE
mode is instead handled internally. Sometime later, the compiler may generate another compiled form and switch to it. This cycle of switching between interpreted and compiled mode will continue until the system determines that it does not make sense to continue trying — for example, when a certain failure threshold has been reached — at which point the system will permanently switch to interpreted mode for the given expression.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-