File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
main/java/org/sterl/spring/persistent_tasks/task/util
test/java/org/sterl/spring/persistent_tasks/task Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,14 @@ public abstract class ReflectionUtil {
1212
1313 public static <A extends Annotation > A getAnnotation (PersistentTask <? extends Serializable > inTask , Class <A > searchFor ) {
1414 var task = AopProxyUtils .ultimateTargetClass (inTask );
15- A result = AnnotationUtils .findAnnotation (task , searchFor );
16- if (result != null ) return result ;
17-
1815 var targetMethod = ReflectionUtils .findMethod (task , "accept" , Serializable .class );
19- if (targetMethod == null ) return null ;
16+
17+ A result = null ;
18+ // check the method first
19+ if (targetMethod != null ) result = AnnotationUtils .findAnnotation (targetMethod , searchFor );
20+ // check the class if no method annotation was found
21+ if (result == null ) result = AnnotationUtils .findAnnotation (task , searchFor );
2022
21- result = AnnotationUtils .findAnnotation (targetMethod , searchFor );
2223 return result ;
2324 }
2425}
Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ public void accept(String name) {
3636 personRepository .save (new PersonBE (name ));
3737 }
3838 }
39+
3940 @ Component ("transactionalMethod" )
41+ @ Transactional (timeout = 76 , propagation = Propagation .REQUIRED , isolation = Isolation .REPEATABLE_READ )
4042 @ RequiredArgsConstructor
4143 static class TransactionalMethod implements PersistentTask <String > {
4244 private final PersonRepository personRepository ;
@@ -96,7 +98,7 @@ void testFindTransactionAnnotation() {
9698 assertThat (a ).isNotNull ();
9799 assertThat (a .timeout ()).isEqualTo (7 );
98100 }
99-
101+
100102 @ Test
101103 void testGetTransactionTemplate () {
102104 var a = subject .getTransactionTemplate (transactionalClass );
You can’t perform that action at this time.
0 commit comments