Support abstract, bridge, & interface methods in AnnotatedElementUtils
This commit introduces support for finding annotations on abstract, bridge, and interface methods in AnnotatedElementUtils. - Introduced dedicated findAnnotationAttributes() methods in AnnotatedElementUtils that provide first-class support for processing methods, class hierarchies, interfaces, bridge methods, etc. - Introduced find/get search algorithm dichotomy in AnnotatedElementUtils which is visible in the public API as well as in the internal implementation. This was necessary in order to maintain backwards compatibility with the existing API (even though it was undocumented). - Reverted all recent changes made to the "get semantics" search algorithm in AnnotatedElementUtils in order to ensure backwards compatibility, and reverted recent changes to JtaTransactionAnnotationParser and SpringTransactionAnnotationParser accordingly. - Documented internal AnnotatedElementUtils.Processor<T> interface. - Enabled failing tests and introduced findAnnotationAttributesFromBridgeMethod() test in AnnotatedElementUtilsTests. - Refactored ApplicationListenerMethodAdapter.getCondition() and enabled failing test in TransactionalEventListenerTests. - AnnotationUtils.isInterfaceWithAnnotatedMethods() is now package private. Issue: SPR-12738, SPR-11514, SPR-11598
This commit is contained in:
@@ -162,7 +162,6 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean shouldHandle(ApplicationEvent event, Object[] args) {
|
||||
if (args == null) {
|
||||
return false;
|
||||
@@ -250,16 +249,11 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
protected String getCondition() {
|
||||
if (this.condition == null) {
|
||||
AnnotationAttributes annotationAttributes = AnnotatedElementUtils
|
||||
.getAnnotationAttributes(this.method, EventListener.class.getName());
|
||||
.findAnnotationAttributes(this.method, EventListener.class);
|
||||
if (annotationAttributes != null) {
|
||||
String value = annotationAttributes.getString("condition");
|
||||
this.condition = (value != null ? value : "");
|
||||
}
|
||||
// TODO [SPR-12738] Remove once AnnotatedElementUtils finds annotated methods on interfaces (e.g., in dynamic proxies)
|
||||
else {
|
||||
EventListener eventListener = getMethodAnnotation(EventListener.class);
|
||||
this.condition = (eventListener != null ? eventListener.condition() : "");
|
||||
}
|
||||
}
|
||||
return this.condition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user