1 22 package org.jboss.web.tomcat.tc6; 23 24 import java.net.URL ; 25 26 import org.apache.catalina.loader.WebappClassLoader; 27 import org.jboss.logging.Logger; 28 29 37 public class WebAppClassLoader extends WebappClassLoader 38 { 39 static Logger log = Logger.getLogger(WebAppClassLoader.class); 40 private String [] filteredPackages = { 41 "org.apache.commons.logging" 42 }; 43 44 public WebAppClassLoader() 45 { 46 } 47 48 public WebAppClassLoader(ClassLoader parent) 49 { 50 super(parent); 51 } 52 53 public String [] getFilteredPackages() 54 { 55 return filteredPackages; 56 } 57 public void setFilteredPackages(String [] pkgs) 58 { 59 this.filteredPackages = pkgs; 60 } 61 62 @Override 63 public void addURL(URL url) 64 { 65 super.addURL(url); 66 } 67 68 76 protected boolean filter(String name) 77 { 78 boolean excludeClass = super.filter(name); 79 if( excludeClass == false ) 80 { 81 int length = filteredPackages != null ? filteredPackages.length : 0; 83 for(int n = 0; n < length; n ++) 84 { 85 String pkg = filteredPackages[n]; 86 if( name.startsWith(pkg) ) 87 { 88 excludeClass = true; 89 break; 90 } 91 } 92 } 93 log.trace("filter name="+name+", exclude="+excludeClass); 94 return excludeClass; 95 } 96 } 97 | Popular Tags |