@@ -33,7 +33,7 @@ arbitrary advice types. This section describes the basic concepts and standard a
33
33
[[aop-api-advice-around]]
34
34
=== Interception Around Advice
35
35
36
- The most fundamental advice type in Spring is interception around advice .
36
+ The most fundamental advice type in Spring is _interception around advice_ .
37
37
38
38
Spring is compliant with the AOP `Alliance` interface for around advice that uses method
39
39
interception. Classes that implement `MethodInterceptor` and that implement around advice should also implement the
@@ -49,8 +49,8 @@ following interface:
49
49
50
50
The `MethodInvocation` argument to the `invoke()` method exposes the method being
51
51
invoked, the target join point, the AOP proxy, and the arguments to the method. The
52
- `invoke()` method should return the invocation's result: the return value of the join
53
- point.
52
+ `invoke()` method should return the invocation's result: typically the return value of
53
+ the join point.
54
54
55
55
The following example shows a simple `MethodInterceptor` implementation:
56
56
64
64
65
65
public Object invoke(MethodInvocation invocation) throws Throwable {
66
66
System.out.println("Before: invocation=[" + invocation + "]");
67
- Object rval = invocation.proceed();
67
+ Object result = invocation.proceed();
68
68
System.out.println("Invocation returned");
69
- return rval ;
69
+ return result ;
70
70
}
71
71
}
72
72
----
@@ -79,9 +79,9 @@ Kotlin::
79
79
80
80
override fun invoke(invocation: MethodInvocation): Any {
81
81
println("Before: invocation=[$invocation]")
82
- val rval = invocation.proceed()
82
+ val result = invocation.proceed()
83
83
println("Invocation returned")
84
- return rval
84
+ return result
85
85
}
86
86
}
87
87
----
@@ -105,7 +105,7 @@ currently define pointcut interfaces.
105
105
[[aop-api-advice-before]]
106
106
=== Before Advice
107
107
108
- A simpler advice type is a before advice . This does not need a `MethodInvocation`
108
+ A simpler advice type is a _before advice_ . This does not need a `MethodInvocation`
109
109
object, since it is called only before entering the method.
110
110
111
111
The main advantage of a before advice is that there is no need to invoke the `proceed()`
@@ -122,10 +122,6 @@ The following listing shows the `MethodBeforeAdvice` interface:
122
122
}
123
123
----
124
124
125
- (Spring's API design would allow for
126
- field before advice, although the usual objects apply to field interception and it is
127
- unlikely for Spring to ever implement it.)
128
-
129
125
Note that the return type is `void`. Before advice can insert custom behavior before the join
130
126
point runs but cannot change the return value. If a before advice throws an
131
127
exception, it stops further execution of the interceptor chain. The exception
@@ -176,10 +172,10 @@ TIP: Before advice can be used with any pointcut.
176
172
[[aop-api-advice-throws]]
177
173
=== Throws Advice
178
174
179
- Throws advice is invoked after the return of the join point if the join point threw
175
+ _Throws advice_ is invoked after the return of the join point if the join point threw
180
176
an exception. Spring offers typed throws advice. Note that this means that the
181
177
`org.springframework.aop.ThrowsAdvice` interface does not contain any methods. It is a
182
- tag interface identifying that the given object implements one or more typed throws
178
+ marker interface identifying that the given object implements one or more typed throws
183
179
advice methods. These should be in the following form:
184
180
185
181
[source,java,indent=0,subs="verbatim,quotes"]
@@ -189,9 +185,10 @@ advice methods. These should be in the following form:
189
185
190
186
Only the last argument is required. The method signatures may have either one or four
191
187
arguments, depending on whether the advice method is interested in the method and
192
- arguments. The next two listing show classes that are examples of throws advice.
188
+ arguments. The next two listings show classes that are examples of throws advice.
193
189
194
- The following advice is invoked if a `RemoteException` is thrown (including from subclasses):
190
+ The following advice is invoked if a `RemoteException` is thrown (including subclasses of
191
+ `RemoteException`):
195
192
196
193
[tabs]
197
194
======
@@ -220,9 +217,9 @@ Kotlin::
220
217
----
221
218
======
222
219
223
- Unlike the preceding
224
- advice, the next example declares four arguments, so that it has access to the invoked method, method
225
- arguments, and target object. The following advice is invoked if a `ServletException` is thrown:
220
+ Unlike the preceding advice, the next example declares four arguments, so that it has
221
+ access to the invoked method, method arguments, and target object. The following advice
222
+ is invoked if a `ServletException` is thrown:
226
223
227
224
[tabs]
228
225
======
@@ -304,7 +301,7 @@ TIP: Throws advice can be used with any pointcut.
304
301
[[aop-api-advice-after-returning]]
305
302
=== After Returning Advice
306
303
307
- An after returning advice in Spring must implement the
304
+ An _after returning advice_ in Spring must implement the
308
305
`org.springframework.aop.AfterReturningAdvice` interface, which the following listing shows:
309
306
310
307
[source,java,indent=0,subs="verbatim,quotes"]
@@ -368,7 +365,7 @@ TIP: After returning advice can be used with any pointcut.
368
365
[[aop-api-advice-introduction]]
369
366
=== Introduction Advice
370
367
371
- Spring treats introduction advice as a special kind of interception advice.
368
+ Spring treats _introduction advice_ as a special kind of interception advice.
372
369
373
370
Introduction requires an `IntroductionAdvisor` and an `IntroductionInterceptor` that
374
371
implement the following interface:
0 commit comments