Get the App
SLTechnology News&Howtos  ›  Development  › 

Introduction of SpringBoot how to use aspect-oriented programming AOP and execution expression

Shulou Source: shulou.com Published: 2022-06-03 08:52:10 11月15日 Update

SpringBoot how to use aspect-oriented programming AOP and execution expression introduction, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

What we use most is the execution representation. Let's start with the execution expression.

Execution (modifiers-pattern? Ret-type-pattern declaring-type-pattern?name-pattern (param-pattern) throws-pattern?)

What execution matches is the Joinpoint. See the expression execution above is fixed, the modifier of the method is optional, the return type is required, the defined full type is optional, the name is required, the parameters are required, all of these can use wildcards.

Any public method

Execution (public * *)

The way to start with set

Execution (* set* (..))

Methods defined in the cn.freemethod.business.pack.Say interface

Execution (* cn.freemethod.business.pack.Say.* (..))

Methods in any cn.freemethod.business package

Execution (* cn.freemethod.business.*.* (..))

Any method defined in the com.xyz.service package or its subpackages

Execution (* cn.freemethod.business..*.* (..))

Any method in the com.xyz.service package

Within (com.xyz.service.*)

Any method defined in the com.xyz.service package or its subpackages

Within (com.xyz.service..*)

Any method that implements the com.xyz.service.AccountService interface

This (com.xyz.service.AccountService)

Any target object implements the method of com.xyz.service.AccountService

Target (com.xyz.service.AccountService)

In general, the proxy class (Proxy) and the target class (Target) implement the same interface, so the above two are basically equivalent.

A method with one and only one Serializable parameter

Args (java.io.Serializable)

As long as this parameter implements the java.io.Serializable interface, whether it is java.io.Serializable, Integer, or String.

The target (target) uses the @ Transactional annotation method

@ target (org.springframework.transaction.annotation.Transactional)

Target class (target) if there are all the methods in the Transactional annotation

@ within (org.springframework.transaction.annotation.Transactional)

Any method that has Transactional annotations

@ annotation (org.springframework.transaction.annotation.Transactional)

There is one and only one parameter and there are Transactional comments on the type of the parameter

@ args (org.springframework.transaction.annotation.Transactional)

Note that there are Transactional comments on the parameter types, not comments on the parameters of the method.

The name of bean is the method in tradeService

Bean (simpleSay)

The bean name is all methods in simpleSay.

Bean names can match.

Bean (* Impl)

The bean name matches all the methods in the bean of * Impl.

After reading the above, have you mastered how SpringBoot uses the introduction to aspect-oriented programming AOP and execution expressions? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Methods parameters annotations expressions names interfaces goals types aspects programming content that is more or problems faces identical helpless for this reason Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL Apple Docker vpn