-
Notifications
You must be signed in to change notification settings - Fork 8.9k
support @GlobalTransactional and @GlobalLock in parent class and interface #7794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Changes from 10 commits
52ca977
2a2eb49
36c35dd
1e36819
17efeff
2fb26b7
c415798
e65cf2f
43989f3
988994b
e796ae9
b8cd3cf
454c552
e028fef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -705,6 +705,45 @@ public static Map<String, Object> getAnnotationValues(Annotation annotation) thr | |
| return getFieldValue(h, "memberValues"); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param targetClass the target class | ||
| * @param methodName the method name | ||
| * @param paramTypes the param types | ||
| * @param annotationClass the annotation class | ||
| * @return the annotation | ||
| * @param <A> | ||
| */ | ||
| public static <A extends Annotation> A findAnnotationInHierarchy( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe method-level annotation data should take precedence. Only if a method does not have that annotation should we check the corresponding method in the superclass. This ensures that if the same annotation appears with different configured values, the value on the method is the one that ultimately applies.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right! the invoker will check the actual class first just as you wish private <A extends Annotation> A findAnnotation(Method method, Class<?> targetClass, Class<A> annotationClass) {
A anno = getAnnotation(method, targetClass, annotationClass);
if (anno == null) {
anno = ReflectionUtil.findAnnotationInHierarchy(
targetClass, method.getName(), method.getParameterTypes(), annotationClass);
}
return anno;
} |
||
| Class<?> targetClass, String methodName, Class<?>[] paramTypes, Class<A> annotationClass) { | ||
| Class<?> superClass = targetClass.getSuperclass(); | ||
| while (superClass != null && superClass != Object.class) { | ||
| try { | ||
| Method superMethod = superClass.getDeclaredMethod(methodName, paramTypes); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we attempt to read the annotation from the superclass instead of only checking the method itself?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update, pls have a check |
||
| A superAnnotation = superMethod.getAnnotation(annotationClass); | ||
| if (superAnnotation != null) { | ||
| return superAnnotation; | ||
| } | ||
| } catch (NoSuchMethodException e) { | ||
| } | ||
| superClass = superClass.getSuperclass(); | ||
| } | ||
|
|
||
| Set<Class<?>> interfaces = getInterfaces(targetClass); | ||
| for (Class<?> iface : interfaces) { | ||
| try { | ||
| Method ifaceMethod = iface.getDeclaredMethod(methodName, paramTypes); | ||
| A ifaceAnnotation = ifaceMethod.getAnnotation(annotationClass); | ||
| if (ifaceAnnotation != null) { | ||
| return ifaceAnnotation; | ||
| } | ||
| } catch (NoSuchMethodException e) { | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| // endregion | ||
|
|
||
| // region toString | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The javadoc comment is incomplete and doesn't follow the standard javadoc format. The description is unclear and contains grammatical issues. Parameter descriptions should use @param tags, and the generic type parameter description is missing.