Added initial SCGI server and a handler for serving JARs from the filesystem.
[jsvc.git] / src / dolda / jsvc / j2ee / J2eeContext.java
1 package dolda.jsvc.j2ee;
2
3 import dolda.jsvc.*;
4 import dolda.jsvc.util.*;
5 import javax.servlet.*;
6 import java.util.*;
7 import java.io.*;
8
9 public abstract class J2eeContext implements ServerContext {
10     private final ServletConfig sc;
11     private final long ctime;
12     protected final Properties sysconfig, libconfig;
13     
14     protected J2eeContext(ServletConfig sc) {
15         this.sc = sc;
16         this.ctime = System.currentTimeMillis();
17         sysconfig = new Properties();
18         libconfig = new Properties();
19     }
20     
21     static J2eeContext create(ServletConfig sc) {
22         if(TomcatContext.tomcatp(sc))
23             return(new TomcatContext(sc));
24         return(new StandardContext(sc));
25     }
26     
27     public long starttime() {
28         return(ctime);
29     }
30     
31     public String sysconfig(String key, String def) {
32         return(sysconfig.getProperty(key, def));
33     }
34     
35     public String libconfig(String key, String def) {
36         return(libconfig.getProperty(key, def));
37     }
38     
39     void loadconfig(InputStream in) throws IOException {
40         libconfig.load(in);
41     }
42     
43     public ServletConfig j2eeconfig() {
44         return(sc);
45     }
46     
47     public RequestThread worker(Responder root, Request req, ThreadGroup tg, String name) {
48         return(new RequestThread(root, req, tg, name));
49     }
50 }