Skip to content

Commit 4229e22

Browse files
committed
SpEL documentation refinements
1 parent 2e1b9be commit 4229e22

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

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

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

122-
SpEL also supports nested properties using standard _dot_ notation, i.e.
123-
`prop1.prop2.prop3` and the setting of property values
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.
124124

125125
Public fields may also be accessed.
126126

@@ -292,18 +292,17 @@ does not provide optimum performance. For occasional expression usage
292292
this is fine, but when used by other components like Spring Integration,
293293
performance can be very important and there is no real need for the dynamism.
294294

295-
The SpEL compiler is intended to address this need. The
296-
compiler will generate a real Java class on the fly during evaluation that embodies the
297-
expression behavior and use that to achieve much faster expression
298-
evaluation. Due to the lack of typing around expressions the compiler
299-
uses information gathered during the interpreted evaluations of an
300-
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
302-
interpreted evaluation it will find out what it is. Of course, basing the
303-
compilation on this information could cause trouble later if the types of
304-
the various expression elements change over time. For this reason compilation
305-
is best suited to expressions whose type information is not going to change
306-
on repeated evaluations.
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.
307306

308307
For a basic expression like this:
309308

@@ -364,24 +363,22 @@ After selecting a mode, use the `SpelParserConfiguration` to configure the parse
364363
When specifying the compiler mode it is also possible to specify a classloader (passing null is allowed).
365364
Compiled expressions will be defined in a child classloader created under any that is supplied.
366365
It is important to ensure if a classloader is specified it can see all the types involved in
367-
the expression evaluation process.
368-
If none is specified then a default classloader will be used (typically the context classloader for
369-
the thread that is running during expression evaluation).
366+
the expression evaluation process. If none is specified then a default classloader will be used
367+
(typically the context classloader for the thread that is running during expression evaluation).
370368

371369
The second way to configure the compiler is for use when SpEL is embedded inside some other
372-
component and it may not be possible to configure via a configuration object.
373-
In these cases it is possible to use a system property. The property
374-
`spring.expression.compiler.mode` can be set to one of the `SpelCompilerMode`
375-
enum values (`off`, `immediate`, or `mixed`).
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`).
376373

377374

378375
[[expressions-compiler-limitations]]
379376
==== Compiler limitations
380377

381-
Since Spring Framework 4.1 the basic compilation framework is in place. However, the framework does not
382-
yet support compiling every kind of expression. The initial focus has been on the common expressions that are
383-
likely to be used in performance critical contexts. The following kinds of expression cannot be compiled
384-
at the moment:
378+
Since Spring Framework 4.1 the basic compilation framework is in place. However, the framework
379+
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
381+
kinds of expression cannot be compiled at the moment:
385382

386383
- expressions involving assignment
387384
- expressions relying on the conversion service
@@ -1240,9 +1237,9 @@ first or the last value. To obtain the first entry matching the selection the sy
12401237
=== Collection Projection
12411238

12421239
Projection allows a collection to drive the evaluation of a sub-expression and the
1243-
result is a new collection. The syntax for projection is `.![projectionExpression]`. Most
1244-
easily understood by example, suppose we have a list of inventors but want the list of
1245-
cities where they were born. Effectively we want to evaluate 'placeOfBirth.city' for
1240+
result is a new collection. The syntax for projection is `.![projectionExpression]`.
1241+
Most easily understood by example, suppose we have a list of inventors but want the list
1242+
of cities where they were born. Effectively we want to evaluate 'placeOfBirth.city' for
12461243
every entry in the inventor list. Using projection:
12471244

12481245
[source,java,indent=0]

0 commit comments

Comments
 (0)