Skip to content

Commit 0b760c1

Browse files
committed
Polish AOP chapter in reference manual
1 parent 9e1121f commit 0b760c1

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,16 +1637,16 @@ In many cases, you do this binding anyway (as in the preceding example).
16371637

16381638
What happens when multiple pieces of advice all want to run at the same join point?
16391639
Spring AOP follows the same precedence rules as AspectJ to determine the order of advice
1640-
execution. The highest precedence advice runs first "`on the way in`" (so, given two pieces
1641-
of before advice, the one with highest precedence runs first). "`On the way out`" from a
1640+
execution. The highest precedence advice runs first "on the way in" (so, given two pieces
1641+
of before advice, the one with highest precedence runs first). "On the way out" from a
16421642
join point, the highest precedence advice runs last (so, given two pieces of after
16431643
advice, the one with the highest precedence will run second).
16441644

16451645
When two pieces of advice defined in different aspects both need to run at the same
16461646
join point, unless you specify otherwise, the order of execution is undefined. You can
16471647
control the order of execution by specifying precedence. This is done in the normal
16481648
Spring way by either implementing the `org.springframework.core.Ordered` interface in
1649-
the aspect class or annotating it with the `Order` annotation. Given two aspects, the
1649+
the aspect class or annotating it with the `@Order` annotation. Given two aspects, the
16501650
aspect returning the lower value from `Ordered.getValue()` (or the annotation value) has
16511651
the higher precedence.
16521652

@@ -1950,9 +1950,9 @@ expression so that only `@Idempotent` operations match, as follows:
19501950
== Schema-based AOP Support
19511951

19521952
If you prefer an XML-based format, Spring also offers support for defining aspects
1953-
using the new `aop` namespace tags. The exact same pointcut expressions and advice kinds
1953+
using the `aop` namespace tags. The exact same pointcut expressions and advice kinds
19541954
as when using the @AspectJ style are supported. Hence, in this section we focus on
1955-
the new syntax and refer the reader to the discussion in the previous section
1955+
that syntax and refer the reader to the discussion in the previous section
19561956
(<<aop-ataspectj>>) for an understanding of writing pointcut expressions and the binding
19571957
of advice parameters.
19581958

@@ -1982,7 +1982,7 @@ When you use the schema support, an aspect is a regular Java object defined as a
19821982
your Spring application context. The state and behavior are captured in the fields and
19831983
methods of the object, and the pointcut and advice information are captured in the XML.
19841984

1985-
You can declare an aspect by using the <aop:aspect> element, and reference the backing bean
1985+
You can declare an aspect by using the `<aop:aspect>` element, and reference the backing bean
19861986
by using the `ref` attribute, as the following example shows:
19871987

19881988
[source,xml,indent=0,subs="verbatim,quotes"]
@@ -2069,7 +2069,7 @@ collects the `this` object as the join point context and passes it to the advice
20692069
<aop:aspect id="myAspect" ref="aBean">
20702070
20712071
<aop:pointcut id="businessService"
2072-
expression="execution(* com.xyz.myapp.service.*.*(..)) && this(service)"/>
2072+
expression="execution(* com.xyz.myapp.service.*.*(..)) &amp;&amp; this(service)"/>
20732073
20742074
<aop:before pointcut-ref="businessService" method="monitor"/>
20752075
@@ -2098,9 +2098,10 @@ parameters of the matching names, as follows:
20982098
}
20992099
----
21002100

2101-
When combining pointcut sub-expressions, `&&` is awkward within an XML document, so
2102-
you can use the `and`, `or`, and `not` keywords in place of `&&`, `||`, and `!`,
2103-
respectively. For example, the previous pointcut can be better written as follows:
2101+
When combining pointcut sub-expressions, `+&amp;&amp;+` is awkward within an XML
2102+
document, so you can use the `and`, `or`, and `not` keywords in place of `+&amp;&amp;+`,
2103+
`||`, and `!`, respectively. For example, the previous pointcut can be better written as
2104+
follows:
21042105

21052106
[source,xml,indent=0,subs="verbatim"]
21062107
----
@@ -2136,7 +2137,7 @@ exactly the same semantics.
21362137
==== Before Advice
21372138

21382139
Before advice runs before a matched method execution. It is declared inside an
2139-
`<aop:aspect>` by using the <aop:before> element, as the following example shows:
2140+
`<aop:aspect>` by using the `<aop:before>` element, as the following example shows:
21402141

21412142
[source,xml,indent=0,subs="verbatim,quotes"]
21422143
----
@@ -2198,8 +2199,8 @@ shows how to declare it:
21982199
</aop:aspect>
21992200
----
22002201

2201-
As in the @AspectJ style, you can get the return value within the
2202-
advice body. To do so, use the returning attribute to specify the name of the parameter to which
2202+
As in the @AspectJ style, you can get the return value within the advice body.
2203+
To do so, use the `returning` attribute to specify the name of the parameter to which
22032204
the return value should be passed, as the following example shows:
22042205

22052206
[source,xml,indent=0,subs="verbatim,quotes"]
@@ -2236,7 +2237,7 @@ example, you can declare the method signature as follows:
22362237
==== After Throwing Advice
22372238

22382239
After throwing advice executes when a matched method execution exits by throwing an
2239-
exception. It is declared inside an `<aop:aspect>` by using the after-throwing element,
2240+
exception. It is declared inside an `<aop:aspect>` by using the `after-throwing` element,
22402241
as the following example shows:
22412242

22422243
[source,xml,indent=0,subs="verbatim,quotes"]
@@ -2252,8 +2253,8 @@ as the following example shows:
22522253
</aop:aspect>
22532254
----
22542255

2255-
As in the @AspectJ style, you can get the thrown exception within
2256-
the advice body. To do so, use the throwing attribute to specify the name of the parameter to
2256+
As in the @AspectJ style, you can get the thrown exception within the advice body.
2257+
To do so, use the `throwing` attribute to specify the name of the parameter to
22572258
which the exception should be passed as the following example shows:
22582259

22592260
[source,xml,indent=0,subs="verbatim,quotes"]
@@ -2309,7 +2310,7 @@ by using the `after` element, as the following example shows:
23092310
[[aop-schema-advice-around]]
23102311
==== Around Advice
23112312

2312-
The last kind of advice is around advice. Around advice runs "`around`" a matched method
2313+
The last kind of advice is around advice. Around advice runs "around" a matched method
23132314
execution. It has the opportunity to do work both before and after the method executes
23142315
and to determine when, how, and even if the method actually gets to execute at all.
23152316
Around advice is often used to share state before and after a method
@@ -2548,10 +2549,11 @@ ms % Task name
25482549
[[aop-ordering]]
25492550
==== Advice Ordering
25502551

2551-
When multiple advice needs to execute at the same join point (executing method) the
2552-
ordering rules are as described in <<aop-ataspectj-advice-ordering>>. The precedence
2553-
between aspects is determined by either adding the `Order` annotation to the bean
2554-
that backs the aspect or by having the bean implement the `Ordered` interface.
2552+
When multiple pieces of advice need to execute at the same join point (executing method)
2553+
the ordering rules are as described in <<aop-ataspectj-advice-ordering>>. The precedence
2554+
between aspects is determined via the `order` attribute in the `<aop:aspect>` element or
2555+
by either adding the `@Order` annotation to the bean that backs the aspect or by having
2556+
the bean implement the `Ordered` interface.
25552557

25562558

25572559

0 commit comments

Comments
 (0)