1 package dolda.jsvc.scgi;
7 public class Environment {
8 public final File root;
9 public final Properties sysconfig = new Properties();
10 private ClassLoader lib = null;
12 public Environment(File root) {
18 private static File defroot() {
19 File root = new File(System.getProperty("user.home"), ".jsvc");
20 if(root.exists() && root.isDirectory())
25 public Environment() {
29 private void loadconfig() {
30 File sroot = new File(root, "store");
31 sysconfig.put("jsvc.storage", "file:" + sroot.getPath());
32 File conf = new File(root, "jsvc.properties");
35 InputStream in = new FileInputStream(conf);
41 } catch(IOException e) {
42 throw(new RuntimeException(e));
45 File lib = new File(root, "lib");
46 if(lib.exists() && lib.isDirectory()) {
47 List<URL> jars = new ArrayList<URL>();
48 for(File f : lib.listFiles()) {
53 String nm = f.getName();
54 if((nm.length() < 4) || !nm.substring(nm.length() - 4).equals(".jar"))
57 jars.add(f.toURI().toURL());
58 } catch(MalformedURLException e) {
62 this.lib = URLClassLoader.newInstance(jars.toArray(new URL[0]), Environment.class.getClassLoader());
66 public ClassLoader libloader() {
68 return(Environment.class.getClassLoader());
72 public void initvm() {
75 File logging = new File(root, "logging.properties");
76 if(logging.exists() && logging.canRead()) {
78 InputStream in = new FileInputStream(logging);
80 java.util.logging.LogManager.getLogManager().readConfiguration(in);
84 } catch(IOException e) {
85 throw(new RuntimeException(e));