1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.gridsystems.config.modules.jvm;
25
26 import java.util.Collection;
27
28 import com.gridsystems.config.Configurator;
29 import com.gridsystems.config.ConfiguratorModel;
30 import com.gridsystems.config.ConsoleConfiguratorView;
31 import com.gridsystems.config.SwingConfiguratorView;
32
33
34
35
36
37
38
39 public final class JVMConfigurator extends Configurator {
40
41
42
43 static final String BUNDLE = "com/gridsystems/config/modules/jvm/config_jvm";
44
45
46
47
48 private static JVMConfigurator instance = new JVMConfigurator();
49
50
51
52
53 private JVMConfigModel data = new JVMConfigModel(JVMConfigModel.DEFAULT_CONFIG_PATH);
54
55
56
57
58 private JVMSwingView swingView = null;
59
60
61
62
63 private JVMConsoleView consoleView = null;
64
65
66
67
68 private JVMConfigurator() {
69 super(BUNDLE, "config");
70
71 setModel(data);
72 }
73
74
75
76
77
78
79 public static JVMConfigurator getInstance() {
80 return instance;
81 }
82
83
84
85
86
87
88
89 public void setProperty(String name, String value) {
90 data.setProperty(name, value);
91 }
92
93
94
95
96
97
98
99
100 public String getProperty(String name, String def) {
101 return data.getProperty(name, def);
102 }
103
104
105
106
107
108
109
110
111 public int getIntProperty(String name, int def) {
112 String s = data.getProperty(name, null);
113 try {
114 return Integer.parseInt(s);
115 } catch (Exception e) {
116 return def;
117 }
118 }
119
120
121
122
123
124
125
126
127 public boolean getBoolProperty(String name, boolean def) {
128 String s = data.getProperty(name, null);
129 if (s == null) {
130 return def;
131 }
132 if (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("yes")) {
133 return true;
134 }
135 if (s.equalsIgnoreCase("false") || s.equalsIgnoreCase("no")) {
136 return false;
137 }
138 return def;
139 }
140
141
142
143
144
145
146 public void addFlags(Collection<String> flags) {
147 data.addFlags(flags);
148 }
149
150
151
152
153 protected SwingConfiguratorView getSwingView() {
154 if (swingView == null) {
155 swingView = new JVMSwingView(this);
156 }
157 return swingView;
158 }
159
160
161
162
163 protected ConsoleConfiguratorView getConsoleView() {
164 if (consoleView == null) {
165 consoleView = new JVMConsoleView(this);
166 }
167 return consoleView;
168 }
169
170
171
172
173 protected ConfiguratorModel createModel() {
174
175 return data;
176 }
177 }