티스토리 뷰
Spring AOP users are likely to use the execution
pointcut designator the most often. The format of an execution expression is:
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern)
throws-pattern?)
All parts except the returning type pattern (ret-type-pattern in the snippet above), name pattern, and parameters pattern are optional. The returning type pattern determines what the return type of the method must be in order for a join point to be matched. Most frequently you will use *
as the returning type pattern, which matches any return type. A fully-qualified type name will match only when the method returns the given type. The name pattern matches the method name. You can use the *
wildcard as all or part of a name pattern. If specifying a declaring type pattern then include a trailing .
to join it to the name pattern component. The parameters pattern is slightly more complex: ()
matches a method that takes no parameters, whereas (..)
matches any number of parameters (zero or more). The pattern (*)
matches a method taking one parameter of any type, (*,String)
matches a method taking two parameters, the first can be of any type, the second must be a String. Consult the Language Semantics section of the AspectJ Programming Guide for more information.
Some examples of common pointcut expressions are given below.
- the execution of any public method:
execution(public * *(..))
- the execution of any method with a name beginning with "set":
execution(* set*(..))
- the execution of any method defined by the
AccountService
interface:
execution(* com.xyz.service.AccountService.*(..))
- the execution of any method defined in the service package:
execution(* com.xyz.service.*.*(..))
- the execution of any method defined in the service package or a sub-package:
execution(* com.xyz.service..*.*(..))
- any join point (method execution only in Spring AOP) within the service package:
within(com.xyz.service.*)
- any join point (method execution only in Spring AOP) within the service package or a sub-package:
within(com.xyz.service..*)
- any join point (method execution only in Spring AOP) where the proxy implements the
AccountService
interface:
this(com.xyz.service.AccountService)
'this' is more commonly used in a binding form :- see the following section on advice for how to make the proxy object available in the advice body. |
- any join point (method execution only in Spring AOP) where the target object implements the
AccountService
interface:
target(com.xyz.service.AccountService)
'target' is more commonly used in a binding form :- see the following section on advice for how to make the target object available in the advice body. |
- any join point (method execution only in Spring AOP) which takes a single parameter, and where the argument passed at runtime is
Serializable
:
args(java.io.Serializable)
'args' is more commonly used in a binding form :- see the following section on advice for how to make the method arguments available in the advice body. |
Note that the pointcut given in this example is different to execution(* *(java.io.Serializable))
: the args version matches if the argument passed at runtime is Serializable, the execution version matches if the method signature declares a single parameter of type Serializable
.
- any join point (method execution only in Spring AOP) where the target object has an
@Transactional
annotation:
@target(org.springframework.transaction.annotation.Transactional)
'@target' can also be used in a binding form :- see the following section on advice for how to make the annotation object available in the advice body. |
- any join point (method execution only in Spring AOP) where the declared type of the target object has an
@Transactional
annotation:
@within(org.springframework.transaction.annotation.Transactional)
'@within' can also be used in a binding form :- see the following section on advice for how to make the annotation object available in the advice body. |
- any join point (method execution only in Spring AOP) where the executing method has an
@Transactional
annotation:
@annotation(org.springframework.transaction.annotation.Transactional)
'@annotation' can also be used in a binding form :- see the following section on advice for how to make the annotation object available in the advice body. |
- any join point (method execution only in Spring AOP) which takes a single parameter, and where the runtime type of the argument passed has the
@Classified
annotation:
@args(com.xyz.security.Classified)
'@args' can also be used in a binding form :- see the following section on advice for how to make the annotation object(s) available in the advice body. |
- any join point (method execution only in Spring AOP) on a Spring bean named
tradeService
:
bean(tradeService)
- any join point (method execution only in Spring AOP) on Spring beans having names that match the wildcard expression
*Service
:
bean(*Service)
'BackEnd > Spring' 카테고리의 다른 글
Jpa + MyBatis를 세팅할때 Transaction처리는 어떻게 할까? (0) | 2017.05.26 |
---|---|
MyBatis를 작업하다가.... 삽질한 경험담.. (0) | 2017.05.23 |
Spring Annotation 기본 (0) | 2017.05.09 |
스프링에서 @Async로 비동기처리하기 @Async in Spring [퍼옴] (0) | 2017.04.25 |
태스크(Task) 실행과 스케줄링 [퍼옴] (0) | 2017.04.25 |
- Java
- Configuration
- spark
- mysql
- Maven
- javascript
- 텐서플로우
- Error
- tensorflow
- 파이썬
- AI
- executor
- 머신러닝
- spring
- Docker
- AWS
- 점프투파이썬
- API
- TDD
- mybatis
- NIO
- web
- ML
- serverless
- BigData
- python
- 모두의딥러닝
- memory
- Gradle
- 중앙정보처리학원
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |