X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Futil%2FJarContext.java;fp=src%2Fdolda%2Fjsvc%2Futil%2FJarContext.java;h=0000000000000000000000000000000000000000;hb=22779185ec3cd3ab6fafdbcbe675161ceae9ce7d;hp=cb16d37c187fb3b58b630ad8af43a47ba78156cc;hpb=a13bfa2c65aa523f9981531f3db1f125fbcfc19e;p=jsvc.git diff --git a/src/dolda/jsvc/util/JarContext.java b/src/dolda/jsvc/util/JarContext.java deleted file mode 100644 index cb16d37..0000000 --- a/src/dolda/jsvc/util/JarContext.java +++ /dev/null @@ -1,93 +0,0 @@ -package dolda.jsvc.util; - -import java.io.*; -import java.util.*; -import java.net.*; -import dolda.jsvc.*; - -public class JarContext implements ServerContext { - private final long ctime; - private final String name; - public final ClassLoader loader; - protected final Properties sysconfig, libconfig; - - private static String mangle(File f) { - String ret = f.getName(); - int p = ret.lastIndexOf('.'); - if(p > 0) - ret = ret.substring(0, p); - for(f = f.getParentFile(); f != null; f = f.getParentFile()) - ret = f.getName() + "/" + ret; - return(ret); - } - - private void loadconfig() { - try { - InputStream pi = loader.getResourceAsStream("jsvc.properties"); - if(pi != null) { - try { - libconfig.load(pi); - } finally { - pi.close(); - } - } - } catch(IOException e) { - throw(new Error(e)); - } - } - - public Class findboot() { - String clnm = libconfig("jsvc.bootstrap", null); - if(clnm == null) - return(null); - Class bc; - try { - bc = loader.loadClass(clnm); - } catch(ClassNotFoundException e) { - return(null); - } - return(bc); - } - - public JarContext(ClassLoader cl, String name) { - this.ctime = System.currentTimeMillis(); - this.name = name; - this.loader = cl; - sysconfig = new Properties(); - libconfig = new Properties(); - - loadconfig(); - } - - private static URL makingmewanttokilljavac(File jar) { - try { - return(jar.toURI().toURL()); - } catch(MalformedURLException e) { - throw(new RuntimeException(e)); - } - } - - public JarContext(File jar) { - this(new URLClassLoader(new URL[] {makingmewanttokilljavac(jar)}, JarContext.class.getClassLoader()), mangle(jar)); - } - - public long starttime() { - return(ctime); - } - - public String name() { - return(name); - } - - public String sysconfig(String key, String def) { - return(sysconfig.getProperty(key, def)); - } - - public String libconfig(String key, String def) { - return(libconfig.getProperty(key, def)); - } - - public RequestThread worker(Responder root, Request req, ThreadGroup tg, String name) { - return(new RequestThread(root, req, tg, name)); - } -}