1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.deploy;
20
21 import java.io.FileNotFoundException;
22 import java.io.IOException;
23 import java.net.MalformedURLException;
24 import java.util.HashMap;
25 import java.util.Map;
26 import java.util.Properties;
27
28 import org.eclipse.jetty.util.resource.Resource;
29
30
31
32
33
34
35 public class FileConfigurationManager implements ConfigurationManager
36 {
37 private Resource _file;
38 private Map<String,String> _map = new HashMap<String,String>();
39
40 public FileConfigurationManager()
41 {
42 }
43
44 public void setFile(String filename) throws MalformedURLException, IOException
45 {
46 _file = Resource.newResource(filename);
47 }
48
49
50
51
52 public Map<String, String> getProperties()
53 {
54 try
55 {
56 loadProperties();
57 return _map;
58 }
59 catch (Exception e)
60 {
61 throw new RuntimeException(e);
62 }
63 }
64
65 private void loadProperties() throws FileNotFoundException, IOException
66 {
67 if (_map.isEmpty() && _file!=null)
68 {
69 Properties properties = new Properties();
70 properties.load(_file.getInputStream());
71 for (Map.Entry<Object, Object> entry : properties.entrySet())
72 _map.put(entry.getKey().toString(),String.valueOf(entry.getValue()));
73 }
74 }
75 }