X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fscgi%2FDSContext.java;fp=src%2Fdolda%2Fjsvc%2Fscgi%2FDSContext.java;h=9103525bb577f854af8b238e15ac5fc611aca74d;hp=0000000000000000000000000000000000000000;hb=13e578b10b388cc0dea88e05b79265c21416e3a0;hpb=b560fc1c45ee31c6d509781b53d5934121990189 diff --git a/src/dolda/jsvc/scgi/DSContext.java b/src/dolda/jsvc/scgi/DSContext.java new file mode 100644 index 0000000..9103525 --- /dev/null +++ b/src/dolda/jsvc/scgi/DSContext.java @@ -0,0 +1,48 @@ +package dolda.jsvc.scgi; + +import java.io.*; +import dolda.jsvc.*; +import dolda.jsvc.util.*; + +public class DSContext extends JarContext { + public final long mtime; + private final File datroot; + public final ThreadContext tg; + + public DSContext(File jar, File datroot) throws ThreadContext.CreateException { + super(jar); + this.mtime = jar.lastModified(); + this.datroot = datroot; + loadconfig(); + this.tg = ThreadContext.create(this, loader); + } + + private void loadconfig() { + if(datroot != null) { + File sroot = new File(new File(datroot, "store"), name()); + sysconfig.put("jsvc.storage", "file:" + sroot.getPath()); + File conf = new File(datroot, "jsvc.properties"); + if(conf.exists()) { + try { + InputStream in = new FileInputStream(conf); + try { + sysconfig.load(in); + } finally { + in.close(); + } + } catch(IOException e) { + throw(new RuntimeException(e)); + } + } + } + } + + public RequestThread worker(Responder root, Request req, ThreadGroup tg, String name) { + java.net.Socket sk = ((ScgiRequest)req).sk; + if(req.path().equals("")) { + return(new ScgiReqThread(new RootRedirect(""), req, tg, name, sk)); + } else { + return(new ScgiReqThread(root, RequestWrap.chpath(req, req.path().substring(1)), tg, name, sk)); + } + } +}