1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.t7mp.steps;
17
18 import java.util.Map;
19
20 import com.googlecode.t7mp.PluginLog;
21
22 public class SetSystemPropertiesStep implements Step {
23
24 @Override
25 public void execute(Context context) {
26 final String catalinaBasPath = context.getConfiguration().getCatalinaBase().getAbsolutePath();
27 final PluginLog log = context.getLog();
28 System.setProperty("catalina.home", catalinaBasPath);
29 log.debug("set systemproperty key: catalina.home to value " + catalinaBasPath);
30 System.setProperty("catalina.base", catalinaBasPath);
31 log.debug("set systemproperty key: catalina.base to value " + catalinaBasPath);
32 Map<String, String> properties = context.getConfiguration().getSystemProperties();
33 for (String key : properties.keySet()) {
34 String value = replaceCatalinas(properties.get(key));
35 System.setProperty(key, value);
36 log.debug("set systemproperty key: " + key + " to value: " + System.getProperty(key));
37 }
38 }
39
40 protected String replaceCatalinas(String value) {
41 if (value.startsWith("${catalina.home}")) {
42 value = value.replace("${catalina.home}", System.getProperty("catalina.home"));
43 }
44 if (value.startsWith("${catalina.base}")) {
45 value = value.replace("${catalina.base}", System.getProperty("catalina.base"));
46 }
47 return value;
48 }
49 }