1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.appstatus.core.check;
17
18 import java.util.Locale;
19 import java.util.Properties;
20
21 import net.sf.appstatus.core.check.impl.StatusResultImpl;
22
23
24
25
26
27 public abstract class AbstractCheck implements ICheck, IConfigurationAware {
28
29 protected static final int FATAL = 2;
30 protected static final int OK = 0;
31 protected static final int WARN = 1;
32 private Properties configuration;
33
34
35
36
37
38 @Deprecated
39 public ICheckResult checkStatus() {
40 return null;
41 }
42
43
44
45
46
47
48
49
50
51
52
53
54 public ICheckResult checkStatus(Locale locale) {
55 return checkStatus();
56 }
57
58
59
60
61
62
63
64
65
66
67
68 @Deprecated
69 protected ICheckResult createResult(int code) {
70 StatusResultImpl result = new StatusResultImpl();
71 result.setProbeName(getName());
72 result.setGroup(getGroup());
73
74 switch (code) {
75 case OK:
76 result.setCode(ICheckResult.OK);
77 result.setFatal(false);
78
79 break;
80 case FATAL:
81 result.setFatal(true);
82 result.setCode(ICheckResult.ERROR);
83 break;
84 default:
85
86 result.setFatal(false);
87 result.setCode(ICheckResult.ERROR);
88 break;
89 }
90
91 return result;
92 }
93
94 public Properties getConfiguration() {
95 return configuration;
96 }
97
98
99
100
101
102
103
104 protected CheckResultBuilder result() {
105 return new CheckResultBuilder();
106 }
107
108
109
110
111
112
113
114
115 protected CheckResultBuilder result(ICheck check) {
116 return new CheckResultBuilder().from(check);
117 }
118
119 public void setConfiguration(Properties configuration) {
120 this.configuration = configuration;
121 }
122 }