root / trunk / src / java / org / lidar / Config.java @ 10
History | View | Annotate | Download (846 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 | private static XMLConfiguration configuration; | ||
| 12 | |||
| 13 | public static XMLConfiguration getConfiguration(){ | ||
| 14 | if(configuration == null){ | ||
| 15 |             try {
 | ||
| 16 | configuration = new XMLConfiguration("/etc/lidar/config.xml"); | ||
| 17 |                 configuration.setAutoSave(true);
 | ||
| 18 |                 configuration.setReloadingStrategy(new FileChangedReloadingStrategy());
 | ||
| 19 | } catch (Exception e) { | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 23 |         return configuration;
 | ||
| 24 | } | ||
| 25 | |||
| 26 | public static void save(){ | ||
| 27 |         try {
 | ||
| 28 |             configuration.save("/etc/lidar/config.xml");
 | ||
| 29 | } catch (Exception e) { | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } |