X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fj2ee%2FJ2eeContext.java;h=bf1917c9c1ad8462f84d694648a7644873c89a49;hp=5049d266d5e5d36c6221e0bd5d9f35ab71fad054;hb=762009abaf3acc38003c9635115c721c602bdaa5;hpb=b1f70a1cd26e6ba6af9ae0bb067f60786ae2e550 diff --git a/src/dolda/jsvc/j2ee/J2eeContext.java b/src/dolda/jsvc/j2ee/J2eeContext.java index 5049d26..bf1917c 100644 --- a/src/dolda/jsvc/j2ee/J2eeContext.java +++ b/src/dolda/jsvc/j2ee/J2eeContext.java @@ -3,50 +3,24 @@ 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 { +public abstract class J2eeContext implements ServerContext { private final ServletConfig sc; private final long ctime; - private final Properties config; + protected final Properties config; - J2eeContext(ServletConfig sc) { + protected J2eeContext(ServletConfig sc) { this.sc = sc; this.ctime = System.currentTimeMillis(); - config = readconfig(sc); + config = new Properties(); } - private static void loadprops(Properties props, File pfile) { - if(!pfile.exists()) - return; - try { - InputStream in = new FileInputStream(pfile); - try { - props.load(in); - } finally { - in.close(); - } - } catch(IOException e) { - throw(new RuntimeException(e)); - } - } - - private static Properties readconfig(ServletConfig sc) { - /* This only works on Tomcat now, but that's because I've no - * idea how other J2EE servers work. I don't even know if they - * _have_ any reasonable place to put configuration and - * storage. */ - Properties cfg = new Properties(); - String basename = System.getProperty("catalina.base"); - if(basename != null) { - File base = new File(basename); - cfg.put("jsvc.storage", new File(new File(base, "work"), "jsvc").getPath()); - File cdir = new File(base, "conf"); - loadprops(cfg, new File(cdir, "jsvc.properties")); - } - return(cfg); + static J2eeContext create(ServletConfig sc) { + if(TomcatContext.tomcatp(sc)) + return(new TomcatContext(sc)); + return(new StandardContext(sc)); } public long starttime() {