1 29 30 package com.caucho.loader; 31 32 import com.caucho.config.Config; 33 import com.caucho.config.ConfigException; 34 import com.caucho.vfs.Path; 35 import com.caucho.vfs.Vfs; 36 37 import java.io.File ; 38 import java.net.URLClassLoader ; 39 40 55 public class SystemClassLoader 56 extends EnvironmentClassLoader 57 implements EnvironmentBean 58 { 59 private boolean _isInit; 60 61 private URLClassLoader _loader; 62 63 66 public SystemClassLoader(ClassLoader parent) 67 { 68 super(parent); 69 } 70 71 public ClassLoader getClassLoader() 72 { 73 return this; 74 } 75 76 public void init() 77 { 78 if (_isInit) 79 return; 80 81 _isInit = true; 82 83 initClasspath(); 84 85 super.init(); 86 87 String systemConf = System.getProperty("system.conf"); 88 89 if (systemConf != null) { 90 try { 91 Path path = Vfs.lookup(systemConf); 92 93 Config config = new Config(); 94 95 config.configure(this, path, getSchema()); 96 } 97 catch (Exception ex) { 98 ex.printStackTrace(); 99 100 throw new RuntimeException (ex.toString()); 101 } 102 } 103 } 104 105 private void initClasspath() 106 { 107 String classpath = System.getProperty("java.class.path"); 108 109 String [] classpathElements = classpath.split(File.pathSeparator, 512); 110 111 for (String classpathElement : classpathElements) { 112 SimpleLoader loader = new SimpleLoader(Vfs.lookup(classpathElement)); 113 114 try { 115 loader.init(); 116 addLoader(loader); 117 } 118 catch (ConfigException ex) { 119 System.err.println("bad classpath elenent " + classpathElement); 120 ex.printStackTrace(); 121 } 122 } 123 } 124 125 protected String getSchema() 126 { 127 return "com/caucho/loader/system.rnc"; 128 } 129 } 130 131 132 | Popular Tags |