Pedro Abelleira Seco wrote:

>That sounds well, but where do you store your properties file? I mean,
>how do you switch from development properties file to production file?
>
>Pedro
>  
>
I load it from the classpath with getResourceAsStream().  Each server
has its own version of the properties file at tomcat/shared/classes. 
Here's the guts of the code... I called it UserDefaults.java in memory
of our old WebObjects apps. I don't doubt that a system property is the
more java-proper way to do it.


    private static final String userDefaultsFilename = "user.defaults";
    private static Properties userDefaults;

    static {
        loadUserDefaults();
    }

    public static void loadUserDefaults()
    {
        userDefaults = new Properties();
        try {
            ClassLoader loader =
Thread.currentThread().getContextClassLoader();
            InputStream input =
loader.getResourceAsStream(userDefaultsFilename);

            userDefaults.load(input);
        }
        catch (NullPointerException npe) {
            System.out.println("No UserDefaults file found.);
        }
        catch (Exception ex) {
            throw new ExceptionAdapter(ex);
        }
    }






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

Reply via email to