X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fj2ee%2FJ2eeContext.java;h=bf1917c9c1ad8462f84d694648a7644873c89a49;hb=762009abaf3acc38003c9635115c721c602bdaa5;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..bf1917c 100644 --- a/src/dolda/jsvc/j2ee/J2eeContext.java +++ b/src/dolda/jsvc/j2ee/J2eeContext.java @@ -3,24 +3,35 @@ 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 config; - 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(); + config = 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 config(String key) { + return((String)config.get(key)); + } + + public ServletConfig j2eeconfig() { + return(sc); } }