@@ -25,26 +25,13 @@ target different advice with the same pointcut.
2525The `org.springframework.aop.Pointcut` interface is the central interface, used to
2626target advices to particular classes and methods. The complete interface follows:
2727
28- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
29- .Java
28+ [source,java,indent=0,subs="verbatim,quotes"]
3029----
3130 public interface Pointcut {
3231
3332 ClassFilter getClassFilter();
3433
3534 MethodMatcher getMethodMatcher();
36-
37- }
38- ----
39- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
40- .Kotlin
41- ----
42- interface Pointcut {
43-
44- fun getClassFilter(): ClassFilter
45-
46- fun getMethodMatcher(): MethodMatcher
47-
4835 }
4936----
5037
@@ -56,27 +43,17 @@ The `ClassFilter` interface is used to restrict the pointcut to a given set of t
5643classes. If the `matches()` method always returns true, all target classes are
5744matched. The following listing shows the `ClassFilter` interface definition:
5845
59- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
60- .Java
46+ [source,java,indent=0,subs="verbatim,quotes"]
6147----
6248 public interface ClassFilter {
6349
6450 boolean matches(Class clazz);
6551 }
6652----
67- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
68- .Kotlin
69- ----
70- interface ClassFilter {
71-
72- fun matches(clazz: Class<*>): Boolean
73- }
74- ----
7553
7654The `MethodMatcher` interface is normally more important. The complete interface follows:
7755
78- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
79- .Java
56+ [source,java,indent=0,subs="verbatim,quotes"]
8057----
8158 public interface MethodMatcher {
8259
@@ -87,18 +64,6 @@ The `MethodMatcher` interface is normally more important. The complete interface
8764 boolean matches(Method m, Class targetClass, Object[] args);
8865 }
8966----
90- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
91- .Kotlin
92- ----
93- interface MethodMatcher {
94-
95- val isRuntime: Boolean
96-
97- fun matches(m: Method, targetClass: Class<*>): Boolean
98-
99- fun matches(m: Method, targetClass: Class<*>, args: Array<Any>): Boolean
100- }
101- ----
10267
10368The `matches(Method, Class)` method is used to test whether this pointcut ever
10469matches a given method on a target class. This evaluation can be performed when an AOP
@@ -335,22 +300,13 @@ Spring is compliant with the AOP `Alliance` interface for around advice that use
335300interception. Classes that implement `MethodInterceptor` and that implement around advice should also implement the
336301following interface:
337302
338- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
339- .Java
303+ [source,java,indent=0,subs="verbatim,quotes"]
340304----
341305 public interface MethodInterceptor extends Interceptor {
342306
343307 Object invoke(MethodInvocation invocation) throws Throwable;
344308 }
345309----
346- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
347- .Kotlin
348- ----
349- interface MethodInterceptor : Interceptor {
350-
351- fun invoke(invocation: MethodInvocation) : Any
352- }
353- ----
354310
355311The `MethodInvocation` argument to the `invoke()` method exposes the method being
356312invoked, the target join point, the AOP proxy, and the arguments to the method. The
@@ -413,22 +369,13 @@ interceptor chain.
413369
414370The following listing shows the `MethodBeforeAdvice` interface:
415371
416- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
417- .Java
372+ [source,java,indent=0,subs="verbatim,quotes"]
418373----
419374 public interface MethodBeforeAdvice extends BeforeAdvice {
420375
421376 void before(Method m, Object[] args, Object target) throws Throwable;
422377 }
423378----
424- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
425- .Kotlin
426- ----
427- interface MethodBeforeAdvice : BeforeAdvice {
428-
429- fun before(m: Method, args: Array<Any>, target: Any)
430- }
431- ----
432379
433380(Spring's API design would allow for
434381field before advice, although the usual objects apply to field interception and it is
@@ -591,23 +538,14 @@ TIP: Throws advice can be used with any pointcut.
591538An after returning advice in Spring must implement the
592539`org.springframework.aop.AfterReturningAdvice` interface, which the following listing shows:
593540
594- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
595- .Java
541+ [source,java,indent=0,subs="verbatim,quotes"]
596542----
597543 public interface AfterReturningAdvice extends Advice {
598544
599545 void afterReturning(Object returnValue, Method m, Object[] args, Object target)
600546 throws Throwable;
601547 }
602548----
603- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
604- .Kotlin
605- ----
606- interface AfterReturningAdvice : Advice {
607-
608- fun afterReturning(returnValue: Any, m: Method, args: Array<Any>, target: Any)
609- }
610- ----
611549
612550An after returning advice has access to the return value (which it cannot modify),
613551the invoked method, the method's arguments, and the target.
@@ -660,22 +598,13 @@ Spring treats introduction advice as a special kind of interception advice.
660598Introduction requires an `IntroductionAdvisor` and an `IntroductionInterceptor` that
661599implement the following interface:
662600
663- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
664- .Java
601+ [source,java,indent=0,subs="verbatim,quotes"]
665602----
666603 public interface IntroductionInterceptor extends MethodInterceptor {
667604
668605 boolean implementsInterface(Class intf);
669606 }
670607----
671- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
672- .Kotlin
673- ----
674- interface IntroductionInterceptor : MethodInterceptor {
675-
676- fun implementsInterface(intf: Class<*>): Boolean
677- }
678- ----
679608
680609The `invoke()` method inherited from the AOP Alliance `MethodInterceptor` interface must
681610implement the introduction. That is, if the invoked method is on an introduced
@@ -686,8 +615,7 @@ Introduction advice cannot be used with any pointcut, as it applies only at the
686615rather than the method, level. You can only use introduction advice with the
687616`IntroductionAdvisor`, which has the following methods:
688617
689- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
690- .Java
618+ [source,java,indent=0,subs="verbatim,quotes"]
691619----
692620 public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
693621
@@ -701,22 +629,6 @@ rather than the method, level. You can only use introduction advice with the
701629 Class<?>[] getInterfaces();
702630 }
703631----
704- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
705- .Kotlin
706- ----
707- interface IntroductionAdvisor : Advisor, IntroductionInfo {
708-
709- val classFilter: ClassFilter
710-
711- @Throws(IllegalArgumentException::class)
712- fun validateInterfaces()
713- }
714-
715- interface IntroductionInfo {
716-
717- val interfaces: Array<Class<*>>
718- }
719- ----
720632
721633There is no `MethodMatcher` and, hence, no `Pointcut` associated with introduction
722634advice. Only class filtering is logical.
0 commit comments