Removed native components (now in own repositories)
[guacamole.git] / web / guacamole-common / src / main / java / net / sourceforge / guacamole / net / GuacamoleProperties.java
1
2 package net.sourceforge.guacamole.net;
3
4 /*
5  *  Guacamole - Clientless Remote Desktop
6  *  Copyright (C) 2010  Michael Jumper
7  *
8  *  This program is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU Affero General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU Affero General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Affero General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.util.Properties;
25 import net.sourceforge.guacamole.GuacamoleException;
26
27 public class GuacamoleProperties {
28
29     private static final Properties properties;
30     private static GuacamoleException exception;
31
32     static {
33
34         properties = new Properties();
35
36         try {
37
38             InputStream stream = GuacamoleProperties.class.getResourceAsStream("/guacamole.properties");
39             if (stream == null)
40                 throw new IOException("Resource /guacamole.properties not found.");
41
42             properties.load(stream);
43         }
44         catch (IOException e) {
45             exception = new GuacamoleException("Error reading guacamole.properties", e);
46         }
47
48     }
49
50     public static String getProperty(String name) throws GuacamoleException {
51         if (exception != null) throw exception;
52         return properties.getProperty(name);
53     }
54
55 }