-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...core/src/main/java/com/sprainkle/spring/cloud/advance/common/core/util/PointCutUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.sprainkle.spring.cloud.advance.common.core.util; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.reflect.MethodSignature; | ||
import org.springframework.core.annotation.AnnotationUtils; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* Spring AOP point cut 工具类 | ||
* | ||
* @author sprainkle | ||
* @date 2021/8/13 | ||
*/ | ||
public class PointCutUtils { | ||
|
||
public static MethodSignature getMethodSignature(JoinPoint joinPoint) { | ||
return (MethodSignature) joinPoint.getSignature(); | ||
} | ||
|
||
public static Method getMethod(JoinPoint joinPoint) { | ||
return getMethodSignature(joinPoint).getMethod(); | ||
} | ||
|
||
public static Object[] getArgs(JoinPoint joinPoint) { | ||
return joinPoint.getArgs(); | ||
} | ||
|
||
public static <T extends Annotation> T getAnnotation(JoinPoint joinPoint, Class<T> annotationClass) { | ||
Method method = getMethod(joinPoint); | ||
return AnnotationUtils.getAnnotation(method, annotationClass); | ||
} | ||
|
||
} |