Skip to content

Commit 3767119

Browse files
committed
SpEL documentation refinements (backported from 5.1.x)
1 parent 4229e22 commit 3767119

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/docs/asciidoc/core/core-expressions.adoc

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ as shown below.
119119
byte[] bytes = (byte[]) exp.getValue();
120120
----
121121

122-
SpEL also supports nested properties using the standard _dot_ notation, i.e.
123-
`prop1.prop2.prop3` and also the corresponding setting of property values.
124-
122+
SpEL also supports nested properties by using the standard dot notation (such as
123+
`prop1.prop2.prop3`) and also the corresponding setting of property values.
125124
Public fields may also be accessed.
126125

126+
The following example shows how to use dot notation to get the length of a literal:
127+
127128
[source,java,indent=0]
128129
[subs="verbatim,quotes"]
129130
----
@@ -287,22 +288,21 @@ It is also possible to configure the behaviour of the SpEL expression compiler.
287288
=== SpEL compilation
288289

289290
Spring Framework 4.1 includes a basic expression compiler. Expressions are usually
290-
interpreted which provides a lot of dynamic flexibility during evaluation but
291-
does not provide optimum performance. For occasional expression usage
292-
this is fine, but when used by other components like Spring Integration,
293-
performance can be very important and there is no real need for the dynamism.
294-
295-
The SpEL compiler is intended to address this need. The compiler will generate a
296-
real Java class on the fly during evaluation that embodies the expression behavior
297-
and use that to achieve much faster expression evaluation. Due to the lack of
298-
typing around expressions the compiler uses information gathered during the
299-
interpreted evaluations of an expression when performing compilation. For example,
300-
it does not know the type of a property reference purely from the expression but
301-
during the first interpreted evaluation it will find out what it is. Of course,
302-
basing the compilation on this information could cause trouble later if the types
303-
of the various expression elements change over time. For this reason compilation
304-
is best suited to expressions whose type information is not going to change on
305-
repeated evaluations.
291+
interpreted, which provides a lot of dynamic flexibility during evaluation but
292+
does not provide optimum performance. For occasional expression usage,
293+
this is fine, but, when used by other components such as Spring Integration,
294+
performance can be very important, and there is no real need for the dynamism.
295+
296+
The SpEL compiler is intended to address this need. During evaluation, the compiler
297+
generates a Java class that embodies the expression behavior at runtime and uses that
298+
class to achieve much faster expression evaluation. Due to the lack of typing around
299+
expressions, the compiler uses information gathered during the interpreted evaluations
300+
of an expression when performing compilation. For example, it does not know the type
301+
of a property reference purely from the expression, but during the first interpreted
302+
evaluation, it finds out what it is. Of course, basing compilation on such derived
303+
information can cause trouble later if the types of the various expression elements
304+
change over time. For this reason, compilation is best suited to expressions whose
305+
type information is not going to change on repeated evaluations.
306306

307307
For a basic expression like this:
308308

@@ -360,24 +360,24 @@ After selecting a mode, use the `SpelParserConfiguration` to configure the parse
360360
Object payload = expr.getValue(message);
361361
----
362362

363-
When specifying the compiler mode it is also possible to specify a classloader (passing null is allowed).
364-
Compiled expressions will be defined in a child classloader created under any that is supplied.
365-
It is important to ensure if a classloader is specified it can see all the types involved in
366-
the expression evaluation process. If none is specified then a default classloader will be used
363+
When you specify the compiler mode, you can also specify a classloader (passing null is allowed).
364+
Compiled expressions are defined in a child classloader created under any that is supplied.
365+
It is important to ensure that, if a classloader is specified, it can see all the types involved in
366+
the expression evaluation process. If you do not specify a classloader, a default classloader is used
367367
(typically the context classloader for the thread that is running during expression evaluation).
368368

369369
The second way to configure the compiler is for use when SpEL is embedded inside some other
370-
component and it may not be possible to configure via a configuration object. In these cases
371-
it is possible to use a system property. The property `spring.expression.compiler.mode` can be
372-
set to one of the `SpelCompilerMode` enum values (`off`, `immediate`, or `mixed`).
370+
component and it may not be possible to configure it through a configuration object. In these
371+
cases, it is possible to use a system property. You can set the `spring.expression.compiler.mode`
372+
property to one of the `SpelCompilerMode` enum values (`off`, `immediate`, or `mixed`).
373373

374374

375375
[[expressions-compiler-limitations]]
376376
==== Compiler limitations
377377

378-
Since Spring Framework 4.1 the basic compilation framework is in place. However, the framework
378+
Since Spring Framework 4.1, the basic compilation framework is in place. However, the framework
379379
does not yet support compiling every kind of expression. The initial focus has been on the
380-
common expressions that are likely to be used in performance critical contexts. The following
380+
common expressions that are likely to be used in performance-critical contexts. The following
381381
kinds of expression cannot be compiled at the moment:
382382

383383
- expressions involving assignment

0 commit comments

Comments
 (0)