> Whats the best place / access method to storing and retriving 
> config attributes like administrator email addresses and directories
> to store uploaded files in a multi-tiered webapp, web.xml?  
> Resources file?  Both servlets and non servlets need to access 
> these values.  Opinions greatly appreciated.

Here's a properties manager: 


public class PropertiesManager {

    private final static String PROPERTIES_FILE =
"/application.properties";
    private static Properties props = null;
    private static Log log = LogFactory.getLog(PropertiesManager.class);

    //  Load the properties from properties file into memory.
    static {
        props = new Properties();
        InputStream is =
PropertiesManager.class.getResourceAsStream(PROPERTIES_FILE);
        try {
            props.load(is);
        } catch (IOException e) {
            log.error(e);
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                log.error(e);
            }

        }
    }

    /**
     * Gets a property value
     * @param key a property key
     * @return a property value.
     */
    public static String getProperty(String key) {
        return props.getProperty(key);
    }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to