View Javadoc

1   package de.desy.acop.launcher;
2   
3   import java.io.IOException;
4   import java.io.InputStream;
5   import java.util.Properties;
6   
7   /**
8    * 
9    * <code>Utilities</code> offers a set of static methods to load the acop configurations.
10   *
11   * @author <a href="mailto:jaka.bobnar@cosylab.com">Jaka Bobnar</a>
12   *
13   */
14  public class Utilities {
15  	
16  	private static final String FILE_NAME = "acop/acop.properties";
17  	public static final String SPIDER_CUSTOMACTION = "spider.customAction";
18  	public static final String WEBPAGE_LOCATION = "about.webpage";
19  	
20  	private static Properties properties;
21  	
22  	/**
23  	 * Returns the property defined by the given name.
24  	 * 
25  	 * @param name the name of the property
26  	 * @return the property value
27  	 */
28  	public static String getAcopProperty(String name) {
29  		return getProperties().getProperty(name);
30  	}
31  	
32  	/**
33  	 * Reads and returns the properties from the acop/acop.properties file.
34  	 * 
35  	 * @return the acop properties
36  	 */
37  	public static Properties getProperties() {
38  		if (properties == null) {
39  			properties = System.getProperties();
40  			InputStream stream = Utilities.class.getClassLoader().getResourceAsStream(FILE_NAME);
41  			try {
42  				properties.load(stream);
43  			} catch (IOException e) {
44  				e.printStackTrace();
45  			}
46  		}
47  		return properties;
48  	}
49  	
50  }