-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from buession/2.3.x
Release 2.3.2
- Loading branch information
Showing
276 changed files
with
6,780 additions
and
3,059 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -19,12 +19,13 @@ | |
* +-------------------------------------------------------------------------------------------------------+ | ||
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt | | ||
* | Author: Yong.Teng <[email protected]> | | ||
* | Copyright @ 2013-2022 Buession.com Inc. | | ||
* | Copyright @ 2013-2023 Buession.com Inc. | | ||
* +-------------------------------------------------------------------------------------------------------+ | ||
*/ | ||
package com.buession.aop.handler; | ||
|
||
import com.buession.core.utils.Assert; | ||
import org.springframework.util.StringValueResolver; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
|
@@ -43,23 +44,46 @@ public abstract class AbstractAnnotationHandler<A extends Annotation> implements | |
*/ | ||
protected Class<A> annotationClass; | ||
|
||
/** | ||
* 占位符解析器 | ||
* | ||
* @since 2.3.2 | ||
*/ | ||
protected StringValueResolver stringValueResolver; | ||
|
||
/** | ||
* 构造函数 | ||
* | ||
* @param annotationClass | ||
* 注解类 | ||
*/ | ||
@Deprecated | ||
public AbstractAnnotationHandler(Class<A> annotationClass) { | ||
setAnnotationClass(annotationClass); | ||
} | ||
|
||
/** | ||
* 构造函数 | ||
* | ||
* @param annotationClass | ||
* 注解类 | ||
* @param stringValueResolver | ||
* 占位符解析器 | ||
* | ||
* @since 2.3.2 | ||
*/ | ||
public AbstractAnnotationHandler(Class<A> annotationClass){ | ||
public AbstractAnnotationHandler(Class<A> annotationClass, StringValueResolver stringValueResolver) { | ||
setAnnotationClass(annotationClass); | ||
this.stringValueResolver = stringValueResolver; | ||
} | ||
|
||
@Override | ||
public Class<A> getAnnotationClass(){ | ||
public Class<A> getAnnotationClass() { | ||
return annotationClass; | ||
} | ||
|
||
@Override | ||
public void setAnnotationClass(Class<A> annotationClass){ | ||
public void setAnnotationClass(Class<A> annotationClass) { | ||
Assert.isNull(annotationClass, "Annotation class argument could not be null"); | ||
this.annotationClass = annotationClass; | ||
} | ||
|
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 |
---|---|---|
|
@@ -19,14 +19,14 @@ | |
* +-------------------------------------------------------------------------------------------------------+ | ||
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt | | ||
* | Author: Yong.Teng <[email protected]> | | ||
* | Copyright @ 2013-2022 Buession.com Inc. | | ||
* | Copyright @ 2013-2023 Buession.com Inc. | | ||
* +-------------------------------------------------------------------------------------------------------+ | ||
*/ | ||
package com.buession.aop.interceptor; | ||
|
||
import com.buession.core.utils.AnnotationUtils; | ||
import com.buession.core.utils.Assert; | ||
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; | ||
import org.springframework.core.annotation.AnnotationUtils; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Method; | ||
|
@@ -42,7 +42,7 @@ public abstract class AbstractAttributeSourceAdvisor extends StaticMethodMatcher | |
private final Class<? extends Annotation>[] annotations; | ||
|
||
public AbstractAttributeSourceAdvisor(final AnnotationsMethodInterceptor annotationsMethodInterceptor, | ||
final Class<? extends Annotation>[] annotations){ | ||
final Class<? extends Annotation>[] annotations) { | ||
Assert.isNull(annotationsMethodInterceptor, "AnnotationsMethodInterceptor cloud not be null."); | ||
Assert.isNull(annotations, "Annotations cloud not be null."); | ||
|
||
|
@@ -51,7 +51,7 @@ public AbstractAttributeSourceAdvisor(final AnnotationsMethodInterceptor annotat | |
} | ||
|
||
@Override | ||
public boolean matches(Method method, Class<?> targetClass){ | ||
public boolean matches(Method method, Class<?> targetClass) { | ||
Method m = method; | ||
|
||
if(isAnnotationPresent(m)){ | ||
|
@@ -70,26 +70,12 @@ public boolean matches(Method method, Class<?> targetClass){ | |
return false; | ||
} | ||
|
||
private boolean isAnnotationPresent(final Class<?> targetClazz){ | ||
for(Class<? extends Annotation> annotationClass : annotations){ | ||
Annotation annotation = AnnotationUtils.findAnnotation(targetClazz, annotationClass); | ||
if(annotation != null){ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
private boolean isAnnotationPresent(final Class<?> targetClazz) { | ||
return AnnotationUtils.hasClassAnnotationPresent(targetClazz, annotations); | ||
} | ||
|
||
private boolean isAnnotationPresent(final Method method){ | ||
for(Class<? extends Annotation> annotationClass : annotations){ | ||
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationClass); | ||
if(annotation != null){ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
private boolean isAnnotationPresent(final Method method) { | ||
return AnnotationUtils.hasMethodAnnotationPresent(method, annotations); | ||
} | ||
|
||
} |
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
Oops, something went wrong.