X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fj2ee%2FJ2eeContext.java;h=84ce918a79f95108ca13bbaa990159e0f5750662;hb=b560fc1c45ee31c6d509781b53d5934121990189;hp=e8f65a6ee64c86f46e1a6e76bbd659da0344fb82;hpb=7114c38b358d27e6c390a689a50c7f9d2d2a048c;p=jsvc.git diff --git a/src/dolda/jsvc/j2ee/J2eeContext.java b/src/dolda/jsvc/j2ee/J2eeContext.java index e8f65a6..84ce918 100644 --- a/src/dolda/jsvc/j2ee/J2eeContext.java +++ b/src/dolda/jsvc/j2ee/J2eeContext.java @@ -1,25 +1,46 @@ 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(req.getContextPath()); + 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); } }