1 23 24 package com.sun.appserv.server.util; 25 26 import com.sun.enterprise.server.PELaunch; 27 import java.net.URL ; 28 import java.net.URLClassLoader ; 29 30 39 40 public class ASURLClassLoader extends URLClassLoader { 41 42 private URL [] classLoaderList = new URL []{}; 43 45 private String nameOfCL = null; 46 47 private ClassLoader parentChain = null; 48 49 private String parentToString = null; 50 56 57 public ASURLClassLoader(URL [] urls, ClassLoader parent) { 58 super(urls, PELaunch.getSharedChain()!=null ?PELaunch.getSharedChain() 63 : ClassLoader.getSystemClassLoader()); 64 this.parentChain = parent; 65 66 if(this.parentChain instanceof ClassLoaderChain) { 67 this.parentToString = 70 ((ClassLoaderChain)this.parentChain).getName(); 71 } else { 72 this.parentToString = this.parentChain.toString(); 73 } 74 this.classLoaderList = urls; 75 } 76 77 public void setName(String n) { 78 this.nameOfCL = n; 79 } 80 81 public String getName() { 82 return this.nameOfCL; 83 } 84 85 93 @Override 94 public Class <?> loadClass(String name, boolean resolve) 95 throws ClassNotFoundException { 96 try { 97 Class cls = super.loadClass(name, resolve); 101 if (cls != null) { 102 return cls; 103 } 104 throw new ClassNotFoundException (name); 106 } catch(ClassNotFoundException e) { 107 if ((parentChain != null) && 111 (parentChain instanceof ClassLoaderChain)) { 112 ClassLoaderChain chain = (ClassLoaderChain)parentChain; 113 Class c = chain.loadClass(name,this); 115 if (c != null) { 117 if(resolve) { 118 resolveClass(c); 119 } 120 return c; 121 } 122 } 123 throw e; 124 } 125 126 } 127 128 @Override 129 public String toString() { 130 String s = this.nameOfCL + " parentCL :: " + 131 this.parentToString + " URLs :: \n"; 132 for(URL u:classLoaderList){ 133 s += ", " + u; 134 } 135 s +="\n"; 136 return s; 137 } 138 } 139 | Popular Tags |