01: //========================================================================
02: //$Id: FileConfigurationManager.java 1096 2006-10-12 20:59:46Z janb $
03: //Copyright 2006 Mort Bay Consulting Pty. Ltd.
04: //------------------------------------------------------------------------
05: //Licensed under the Apache License, Version 2.0 (the "License");
06: //you may not use this file except in compliance with the License.
07: //You may obtain a copy of the License at
08: //http://www.apache.org/licenses/LICENSE-2.0
09: //Unless required by applicable law or agreed to in writing, software
10: //distributed under the License is distributed on an "AS IS" BASIS,
11: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: //See the License for the specific language governing permissions and
13: //limitations under the License.
14: //========================================================================
15:
16: package org.mortbay.jetty.deployer;
17:
18: import java.io.FileNotFoundException;
19: import java.io.IOException;
20: import java.net.MalformedURLException;
21: import java.util.Map;
22: import java.util.Properties;
23:
24: import org.mortbay.resource.Resource;
25:
26: /**
27: * FileConfigurationManager
28: *
29: * Supplies properties defined in a file.
30: */
31: public class FileConfigurationManager implements ConfigurationManager {
32: private Resource _file;
33: private Properties _properties = new Properties();
34:
35: public FileConfigurationManager() {
36: }
37:
38: public void setFile(String filename) throws MalformedURLException,
39: IOException {
40: _file = Resource.newResource(filename);
41: }
42:
43: /**
44: * @see org.mortbay.jetty.deployer.ConfigurationManager#getProperties()
45: */
46: public Map getProperties() {
47: try {
48: loadProperties();
49: return _properties;
50: } catch (Exception e) {
51: throw new RuntimeException(e);
52: }
53: }
54:
55: private void loadProperties() throws FileNotFoundException,
56: IOException {
57: if (_properties.isEmpty())
58: _properties.load(_file.getInputStream());
59: }
60: }
|