What is the use of access modifiers in a Spring AOP expression?

From Spring doc :

6.2.3.4. Examples

Spring AOP users are most likely to use the execution pointcut pointer most often. Execution format expression:

execution ( template modifiers? ret-type-pattern declaration of type-model? name-pattern (pair-pattern) throws-pattern?)

Do I see modifiers? where you can publish, close, protect. And the same document says:

6.2.3.1. Supported Pointcut Pointers

Due to the proxy-based nature of the AOP Spring framework, protected methods are, by definition, not intercepted, neither for JDK proxies (where this is not applicable), nor for CGLIB proxies (where this is technically possible, but not recommended for AOP purposes). As a result, any given pointcut will only be mapped to public methods!

I don’t understand what is the point of using modifier templates ?, please give an example?

+5
source share
2 answers

It makes no sense to use access modifiers. They exist because Spring uses AspectJ syntax. The full AspectJ AOP allows access modifiers because it works with bytecode.

+3
source

pointcut, , pointcut .

pointcut , Java:

  • public, pointcut ;
  • default ( ), pointcut ;
  • protected, ;
  • private, pointcut , .
0

All Articles