File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
src/main/java/org/casbin/spring/boot/autoconfigure Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 10
10
11
11
public class TxWatcher implements Watcher {
12
12
private final Watcher watcher ;
13
+ private final AfterCommitExecute afterCommitExecute ;
13
14
14
15
public TxWatcher (Watcher watcher ) {
15
16
this .watcher = watcher ;
17
+ this .afterCommitExecute = new AfterCommitExecute (watcher );
16
18
}
17
19
18
20
@ Override
@@ -28,14 +30,22 @@ public void setUpdateCallback(Consumer<String> consumer) {
28
30
@ Override
29
31
public void update () {
30
32
if (isActualTransactionActive ()) {
31
- registerSynchronization (new TransactionSynchronization () {
32
- @ Override
33
- public void afterCommit () {
34
- watcher .update ();
35
- }
36
- });
33
+ registerSynchronization (afterCommitExecute );
37
34
} else {
38
35
watcher .update ();
39
36
}
40
37
}
38
+
39
+ public static class AfterCommitExecute implements TransactionSynchronization {
40
+ private final Watcher watcher ;
41
+
42
+ public AfterCommitExecute (Watcher watcher ) {
43
+ this .watcher = watcher ;
44
+ }
45
+
46
+ @ Override
47
+ public void afterCommit () {
48
+ watcher .update ();
49
+ }
50
+ }
41
51
}
You can’t perform that action at this time.
0 commit comments