1 29 30 package com.caucho.loader; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.loader.enhancer.EnhancerManager; 34 import com.caucho.make.MakeLoader; 35 import com.caucho.util.L10N; 36 import com.caucho.vfs.Path; 37 38 import javax.annotation.PostConstruct; 39 import java.util.ArrayList ; 40 41 44 public class ClassLoaderConfig { 45 private final static L10N L = new L10N(ClassLoaderConfig.class); 46 47 private EnvironmentClassLoader _classLoader; 48 private EnvironmentBean _owner; 49 50 private Path _source; 51 private boolean _servletHack; 52 53 private int _index; 54 55 private ArrayList <String > _priorityPackages; 56 57 public ClassLoaderConfig() 58 throws ConfigException 59 { 60 Thread thread = Thread.currentThread(); 61 62 ClassLoader loader = thread.getContextClassLoader(); 63 64 if (! (loader instanceof EnvironmentClassLoader)) 65 throw new ConfigException(L.l("<class-loader> requires an EnvironmentClassLoader.")); 66 67 _classLoader = (EnvironmentClassLoader) loader; 68 69 75 } 76 77 80 public void setServletHack(boolean hack) 81 { 82 _classLoader.setServletHack(hack); 83 } 84 85 88 public void addSimpleLoader(SimpleLoader loader) 89 { 90 _classLoader.addLoader(loader, _index++); 91 } 92 93 96 public void addLibraryLoader(LibraryLoader loader) 97 { 98 _classLoader.addLoader(loader, _index++); 99 } 100 101 104 public void addCompilingLoader(CompilingLoader loader) 105 { 106 _classLoader.addLoader(loader, _index++); 107 } 108 109 112 public void addTreeLoader(TreeLoader loader) 113 { 114 _classLoader.addLoader(loader, _index++); 115 } 116 117 120 public void addMakeLoader(MakeLoader loader) 121 { 122 _classLoader.addLoader(loader, _index++); 123 } 124 125 128 public EnhancerManager createEnhancer() 129 throws ConfigException 130 { 131 return EnhancerManager.create(); 132 } 133 134 137 144 145 152 public void addPriorityPackage(String priorityPackage) 153 { 154 _classLoader.addPriorityPackage(priorityPackage); 155 } 156 157 160 @PostConstruct 161 public void init() 162 throws ConfigException 163 { 164 _classLoader.init(); 165 166 _classLoader.validate(); 167 } 168 169 public String toString() 170 { 171 return "ClassLoaderConfig[]"; 172 } 173 } 174 175 176 | Popular Tags |