1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.migration.hook;
17
18 import java.util.Map;
19
20 public class FileMigrationHook implements MigrationHook {
21
22 protected final HookScript beforeScript;
23 protected final HookScript beforeEachScript;
24 protected final HookScript afterEachScript;
25 protected final HookScript afterScript;
26
27 public FileMigrationHook(HookScript beforeScript, HookScript beforeEachScript, HookScript afterEachScript,
28 HookScript afterScript) {
29 this.beforeScript = beforeScript;
30 this.beforeEachScript = beforeEachScript;
31 this.afterEachScript = afterEachScript;
32 this.afterScript = afterScript;
33 }
34
35 @Override
36 public void before(Map<String, Object> bindingMap) {
37 if (beforeScript != null) {
38 beforeScript.execute(bindingMap);
39 }
40 }
41
42 @Override
43 public void beforeEach(Map<String, Object> bindingMap) {
44 if (beforeEachScript != null) {
45 beforeEachScript.execute(bindingMap);
46 }
47 }
48
49 @Override
50 public void afterEach(Map<String, Object> bindingMap) {
51 if (afterEachScript != null) {
52 afterEachScript.execute(bindingMap);
53 }
54 }
55
56 @Override
57 public void after(Map<String, Object> bindingMap) {
58 if (afterScript != null) {
59 afterScript.execute(bindingMap);
60 }
61 }
62 }