1 package dolda.jsvc.j2ee;
4 import dolda.jsvc.util.*;
5 import javax.servlet.*;
6 import javax.servlet.http.*;
10 public class J2eeContext implements ServerContext {
11 private final ServletConfig sc;
12 private final long ctime;
13 private final Properties config;
15 J2eeContext(ServletConfig sc) {
17 this.ctime = System.currentTimeMillis();
18 config = readconfig(sc);
21 private static void loadprops(Properties props, File pfile) {
25 InputStream in = new FileInputStream(pfile);
31 } catch(IOException e) {
32 throw(new RuntimeException(e));
36 private static Properties readconfig(ServletConfig sc) {
37 /* This only works on Tomcat now, but that's because I've no
38 * idea how other J2EE servers work. I don't even know if they
39 * _have_ any reasonable place to put configuration and
41 Properties cfg = new Properties();
42 String basename = System.getProperty("catalina.base");
43 if(basename != null) {
44 File base = new File(basename);
45 cfg.put("jsvc.storage", new File(new File(base, "work"), "jsvc").getPath());
46 File cdir = new File(base, "conf");
47 loadprops(cfg, new File(cdir, "jsvc.properties"));
52 public long starttime() {
56 public String config(String key) {
57 return((String)config.get(key));
60 public ServletConfig j2eeconfig() {