View | Details | Raw Unified | Return to bug 50677
Collapse All | Expand All

(-)java/org/apache/catalina/startup/Bootstrap.java (-34 lines)
Lines 56-68 Link Here
56
56
57
    private static final Log log = LogFactory.getLog(Bootstrap.class);
57
    private static final Log log = LogFactory.getLog(Bootstrap.class);
58
58
59
    // -------------------------------------------------------------- Constants
60
61
62
    protected static final String CATALINA_HOME_TOKEN = "${" + Globals.CATALINA_HOME_PROP + "}";
63
    protected static final String CATALINA_BASE_TOKEN = "${" + Globals.CATALINA_BASE_PROP + "}";
64
65
66
    // ------------------------------------------------------- Static Variables
59
    // ------------------------------------------------------- Static Variables
67
60
68
61
Lines 115-152 Link Here
115
108
116
        ArrayList<String> repositoryLocations = new ArrayList<String>();
109
        ArrayList<String> repositoryLocations = new ArrayList<String>();
117
        ArrayList<Integer> repositoryTypes = new ArrayList<Integer>();
110
        ArrayList<Integer> repositoryTypes = new ArrayList<Integer>();
118
        int i;
119
111
120
        StringTokenizer tokenizer = new StringTokenizer(value, ",");
112
        StringTokenizer tokenizer = new StringTokenizer(value, ",");
121
        while (tokenizer.hasMoreElements()) {
113
        while (tokenizer.hasMoreElements()) {
122
            String repository = tokenizer.nextToken();
114
            String repository = tokenizer.nextToken();
123
115
124
            // Local repository
125
            boolean replace = false;
126
            String before = repository;
127
            while ((i=repository.indexOf(CATALINA_HOME_TOKEN))>=0) {
128
                replace=true;
129
                if (i>0) {
130
                repository = repository.substring(0,i) + getCatalinaHome()
131
                    + repository.substring(i+CATALINA_HOME_TOKEN.length());
132
                } else {
133
                    repository = getCatalinaHome()
134
                        + repository.substring(CATALINA_HOME_TOKEN.length());
135
                }
136
            }
137
            while ((i=repository.indexOf(CATALINA_BASE_TOKEN))>=0) {
138
                replace=true;
139
                if (i>0) {
140
                repository = repository.substring(0,i) + getCatalinaBase()
141
                    + repository.substring(i+CATALINA_BASE_TOKEN.length());
142
                } else {
143
                    repository = getCatalinaBase()
144
                        + repository.substring(CATALINA_BASE_TOKEN.length());
145
                }
146
            }
147
            if (replace && log.isDebugEnabled())
148
                log.debug("Expanded " + before + " to " + repository);
149
150
            // Check for a JAR URL repository
116
            // Check for a JAR URL repository
151
            try {
117
            try {
152
                new URL(repository);
118
                new URL(repository);
(-)java/org/apache/catalina/startup/CatalinaProperties.java (-6 / +43 lines)
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
     */

Return to bug 50677