1 25 package org.ofbiz.base.container; 26 27 import org.ofbiz.base.util.CachedClassLoader; 28 import org.ofbiz.base.util.Debug; 29 import org.ofbiz.base.start.Classpath; 30 31 import java.net.URL ; 32 33 40 public class ClassLoaderContainer implements Container { 41 42 public static final String module = ClassLoaderContainer.class.getName(); 43 protected static CachedClassLoader cl = null; 44 45 48 public void init(String [] args, String configFile) throws ContainerException { 49 ClassLoader parent = Thread.currentThread().getContextClassLoader(); 50 if (parent == null) { 51 parent = Classpath.class.getClassLoader(); 52 } 53 if (parent == null) { 54 parent = ClassLoader.getSystemClassLoader(); 55 } 56 57 cl = new CachedClassLoader(new URL [0], parent); 58 Thread.currentThread().setContextClassLoader(cl); 59 Debug.logInfo("CachedClassLoader created", module); 60 } 61 62 65 public boolean start() throws ContainerException { 66 return true; 67 } 68 69 72 public void stop() throws ContainerException { 73 } 74 75 public static ClassLoader getClassLoader() { 76 if (cl != null) { 77 return cl; 78 } else { 79 return ClassLoader.getSystemClassLoader(); 80 } 81 } 82 } 83 | Popular Tags |