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 conf = new File(root, "jsvc.properties");
33 InputStream in = new FileInputStream(conf);
39 } catch(IOException e) {
40 throw(new RuntimeException(e));
43 File lib = new File(root, "lib");
44 if(lib.exists() && lib.isDirectory()) {
45 List<URL> jars = new ArrayList<URL>();
46 for(File f : lib.listFiles()) {
51 String nm = f.getName();
52 if((nm.length() < 4) || !nm.substring(nm.length() - 4).equals(".jar"))
55 jars.add(f.toURI().toURL());
56 } catch(MalformedURLException e) {
60 this.lib = URLClassLoader.newInstance(jars.toArray(new URL[0]), Environment.class.getClassLoader());
64 public ClassLoader libloader() {
66 return(Environment.class.getClassLoader());
70 public void initvm() {
73 File logging = new File(root, "logging.properties");
74 if(logging.exists() && logging.canRead()) {
76 InputStream in = new FileInputStream(logging);
78 java.util.logging.LogManager.getLogManager().readConfiguration(in);
82 } catch(IOException e) {
83 throw(new RuntimeException(e));