root / trunk / src / java / org / lidar / Config.java
History | View | Annotate | Download (851 Bytes)
1 | 9 | andrej.cim | package org.lidar; |
---|---|---|---|
2 | |||
3 | import org.apache.commons.configuration.XMLConfiguration; |
||
4 | import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy; |
||
5 | |||
6 | /**
|
||
7 | *
|
||
8 | * @author Andrej Cimpersek
|
||
9 | */
|
||
10 | public class Config { |
||
11 | 11 | andrej.cim | |
12 | 9 | andrej.cim | private static XMLConfiguration configuration; |
13 | |||
14 | 11 | andrej.cim | public static XMLConfiguration getConfiguration() { |
15 | if (configuration == null) { |
||
16 | 9 | andrej.cim | try {
|
17 | configuration = new XMLConfiguration("/etc/lidar/config.xml"); |
||
18 | configuration.setAutoSave(true);
|
||
19 | configuration.setReloadingStrategy(new FileChangedReloadingStrategy());
|
||
20 | } catch (Exception e) { |
||
21 | } |
||
22 | } |
||
23 | |||
24 | return configuration;
|
||
25 | } |
||
26 | |||
27 | 11 | andrej.cim | public static void save() { |
28 | 9 | andrej.cim | try {
|
29 | configuration.save("/etc/lidar/config.xml");
|
||
30 | } catch (Exception e) { |
||
31 | } |
||
32 | } |
||
33 | } |