Lines 5-13
Link Here
|
5 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
5 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
6 |
* (the "License"); you may not use this file except in compliance with |
6 |
* (the "License"); you may not use this file except in compliance with |
7 |
* the License. You may obtain a copy of the License at |
7 |
* the License. You may obtain a copy of the License at |
8 |
* |
8 |
* |
9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
10 |
* |
10 |
* |
11 |
* Unless required by applicable law or agreed to in writing, software |
11 |
* Unless required by applicable law or agreed to in writing, software |
12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Lines 24-29
Link Here
|
24 |
import java.net.URL; |
24 |
import java.net.URL; |
25 |
import java.util.Enumeration; |
25 |
import java.util.Enumeration; |
26 |
import java.util.Properties; |
26 |
import java.util.Properties; |
|
|
27 |
import java.util.regex.Matcher; |
28 |
import java.util.regex.Pattern; |
27 |
|
29 |
|
28 |
import org.apache.catalina.Globals; |
30 |
import org.apache.catalina.Globals; |
29 |
|
31 |
|
Lines 53-58
Link Here
|
53 |
} |
55 |
} |
54 |
|
56 |
|
55 |
|
57 |
|
|
|
58 |
// ------------------------------------------------------ Protected Methods |
59 |
|
60 |
|
61 |
/** |
62 |
* Returns the provided string with all property variables (in the form |
63 |
* <code>${property.name}</code>) replaced with their respective values. |
64 |
* |
65 |
* @param value The <code>String</code> in which property expansion should |
66 |
* be performed. |
67 |
* @return The provided value with all property variables replaced. |
68 |
*/ |
69 |
protected static String expandPropertyVariables(String value) { |
70 |
|
71 |
final Matcher matcher = Pattern.compile("\\$\\{(.*?)\\}").matcher(value); |
72 |
|
73 |
if (matcher.find()) { |
74 |
return value.substring(0, matcher.start()) |
75 |
+ System.getProperty(matcher.group(1), matcher.group()) |
76 |
+ expandPropertyVariables(value.substring(matcher.end())); |
77 |
} |
78 |
else { |
79 |
return value; |
80 |
} |
81 |
|
82 |
} |
83 |
|
84 |
|
56 |
// --------------------------------------------------------- Public Methods |
85 |
// --------------------------------------------------------- Public Methods |
57 |
|
86 |
|
58 |
|
87 |
|
Lines 60-66
Link Here
|
60 |
* Return specified property value. |
89 |
* Return specified property value. |
61 |
*/ |
90 |
*/ |
62 |
public static String getProperty(String name) { |
91 |
public static String getProperty(String name) { |
63 |
|
92 |
|
64 |
return properties.getProperty(name); |
93 |
return properties.getProperty(name); |
65 |
|
94 |
|
66 |
} |
95 |
} |
Lines 140-146
Link Here
|
140 |
String name = (String) enumeration.nextElement(); |
169 |
String name = (String) enumeration.nextElement(); |
141 |
String value = properties.getProperty(name); |
170 |
String value = properties.getProperty(name); |
142 |
if (value != null) { |
171 |
if (value != null) { |
143 |
System.setProperty(name, value); |
172 |
String result = expandPropertyVariables(value); |
|
|
173 |
|
174 |
properties.setProperty(name, result); |
175 |
System.setProperty(name, result); |
176 |
|
177 |
if (log.isDebugEnabled() && !value.equals(result)) { |
178 |
log.debug("Expanded Catalina property \"" + name + "\" from \"" |
179 |
+ value + "\" to \"" + result + "\""); |
180 |
} |
144 |
} |
181 |
} |
145 |
} |
182 |
} |
146 |
|
183 |
|
Lines 154-161
Link Here
|
154 |
return System.getProperty(Globals.CATALINA_HOME_PROP, |
191 |
return System.getProperty(Globals.CATALINA_HOME_PROP, |
155 |
System.getProperty("user.dir")); |
192 |
System.getProperty("user.dir")); |
156 |
} |
193 |
} |
157 |
|
194 |
|
158 |
|
195 |
|
159 |
/** |
196 |
/** |
160 |
* Get the value of the catalina.base environment variable. |
197 |
* Get the value of the catalina.base environment variable. |
161 |
*/ |
198 |
*/ |