X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fj2ee%2FJ2eeContext.java;h=f687afd3f158b6be29c2e5f284dacd087759a8c7;hb=c39ae6d24864244eab704dea7307f769f2f2e9da;hp=696e32b939e88f83877c139d84582a4e6b58ddbb;hpb=c25c3aadf42cf04fe8dbbfb60624589ba60112bd;p=jsvc.git diff --git a/src/dolda/jsvc/j2ee/J2eeContext.java b/src/dolda/jsvc/j2ee/J2eeContext.java index 696e32b..f687afd 100644 --- a/src/dolda/jsvc/j2ee/J2eeContext.java +++ b/src/dolda/jsvc/j2ee/J2eeContext.java @@ -3,24 +3,48 @@ package dolda.jsvc.j2ee; import dolda.jsvc.*; import dolda.jsvc.util.*; import javax.servlet.*; -import javax.servlet.http.*; +import java.util.*; +import java.io.*; -public class J2eeContext implements ServerContext { - private ServletConfig cfg; - private HttpServletRequest req; - private HttpServletResponse resp; +public abstract class J2eeContext implements ServerContext { + private final ServletConfig sc; + private final long ctime; + protected final Properties sysconfig, libconfig; - J2eeContext(ServletConfig cfg, HttpServletRequest req, HttpServletResponse resp) { - this.cfg = cfg; - this.req = req; - this.resp = resp; + protected J2eeContext(ServletConfig sc) { + this.sc = sc; + this.ctime = System.currentTimeMillis(); + sysconfig = new Properties(); + libconfig = new Properties(); } - public String rootpath() { - return("/" + Misc.stripslashes(req.getContextPath(), true, true)); + static J2eeContext create(ServletConfig sc) { + if(TomcatContext.tomcatp(sc)) + return(new TomcatContext(sc)); + return(new StandardContext(sc)); } public long starttime() { - return((Long)cfg.getServletContext().getAttribute("jsvc.starttime")); + return(ctime); + } + + public String sysconfig(String key, String def) { + return(sysconfig.getProperty(key, def)); + } + + public String libconfig(String key, String def) { + return(libconfig.getProperty(key, def)); + } + + void loadconfig(InputStream in) throws IOException { + libconfig.load(in); + } + + public ServletConfig j2eeconfig() { + return(sc); + } + + public RequestThread worker(Responder root, Request req, ThreadGroup tg, String name) { + return(new RequestThread(root, req, tg, name)); } }