summaryrefslogtreecommitdiffstats
path: root/java-vaadin/src/ch/asynk/helloworld/Context.java
blob: c59016da3de47406f5956e533bdae7820c2e1942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package ch.asynk.helloworld;

import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Context {
    //
	private static final long serialVersionUID = 1L;
    //
    private Logger log = Logger.getLogger("ch.asynk");
    public Logger getLogger() {
        return log;
    }
    //
    private Properties props = null;
    public Properties getProps() {
        return props;
    }
    //
    private HelloWorldApp app = null;
    public HelloWorldApp getApp() {
        return app;
    }
    //
    public Context(HelloWorldApp application) {
        app = application;
        initProps();
    }
    //
    private void initProps() {
        props = new Properties();
        //
        String properties_file = "Application.properties";
        log.info("doing stuff : ");
        java.io.InputStream is = null;
        try {
            is = HelloWorldApp.class.getClassLoader().getResourceAsStream(properties_file);
        }
        catch(java.lang.Exception x) {
            log.log(Level.SEVERE,"Error loading "+properties_file+"' properties",x);
            return;
        }
        if (is!=null) {
            try {
                props.load(is);
            }
            catch (java.io.IOException e) {
                log.log(Level.SEVERE,"Error reading properties '"+properties_file+"' ",e);
            }
        } else {
            log.warning("'"+properties_file+"' file not found");
        }
    }
}