1 22 package org.jboss.web; 23 24 import java.net.URL ; 25 import java.net.URLClassLoader ; 26 import javax.management.ObjectName ; 27 28 import org.jboss.mx.loading.RepositoryClassLoader; 29 import org.jboss.mx.loading.LoaderRepositoryClassLoader; 30 31 55 public class WebClassLoader extends LoaderRepositoryClassLoader 56 { 57 58 private ObjectName containerName; 59 60 61 private URL [] webURLs; 62 63 private String codebaseString; 64 65 67 public WebClassLoader(ObjectName containerName, RepositoryClassLoader parent) 68 { 69 super(parent, parent.getLoaderRepository()); 70 this.containerName = containerName; 71 } 72 73 74 public String getKey() 75 { 76 String className = getClass().getName(); 77 int dot = className.lastIndexOf('.'); 78 if( dot >= 0 ) 79 className = className.substring(dot+1); 80 String key = className + '[' + hashCode() + ']'; 81 return key; 82 } 83 84 85 public ObjectName getContainer() 86 { 87 return containerName; 88 } 89 90 91 public URL getURL() 92 { 93 return ((RepositoryClassLoader) getParent()).getURL(); 94 } 95 96 102 public URL [] getURLs() 103 { 104 URL [] urls = webURLs; 105 if( urls == null ) 106 urls = super.getURLs(); 107 return urls; 108 } 109 112 public URL [] getLocalURLs() 113 { 114 return super.getURLs(); 115 } 116 117 120 public void setWebURLs(URL [] webURLs) 121 { 122 this.webURLs = webURLs; 123 StringBuffer sb = new StringBuffer (); 124 for (int i = 0; i < webURLs.length; i++) 125 { 126 sb.append(webURLs[i].toString()); 127 if (i < webURLs.length - 1) 128 { 129 sb.append(" "); 130 } 131 } 132 codebaseString = sb.toString(); 133 } 134 135 public String getCodebaseString() 136 { 137 return codebaseString; 138 } 139 140 150 public byte[] getBytes(Class clz) 151 { 152 return null; } 154 155 } 156 | Popular Tags |