1 22 package org.jboss.web.tomcat.tc6; 23 24 import java.net.URL ; 25 import java.util.List ; 26 27 import org.apache.catalina.LifecycleException; 28 import org.apache.catalina.loader.WebappLoader; 29 import org.jboss.logging.Logger; 30 31 38 public class WebAppLoader extends WebappLoader 39 { 40 private static final Logger log = Logger.getLogger(WebAppLoader.class); 41 42 private String [] filteredPackages = { 43 "org.apache.commons.logging" 44 }; 45 private List <URL > classpath; 46 47 private TomcatInjectionContainer injectionContainer; 48 49 public WebAppLoader() 50 { 51 super(); 52 setLoaderClass(WebAppClassLoader.class.getName()); 53 } 54 55 public WebAppLoader(ClassLoader parent, String [] filteredPackages) 56 { 57 this(parent, filteredPackages, null); 58 } 59 public WebAppLoader(ClassLoader parent, String [] filteredPackages, TomcatInjectionContainer container) 60 { 61 super(parent); 62 setLoaderClass(WebAppClassLoader.class.getName()); 63 this.filteredPackages = filteredPackages; 64 injectionContainer = container; 65 } 66 67 72 public void setClasspath(List <URL > classpath) 73 { 74 this.classpath = classpath; 75 } 76 77 82 public void start() throws LifecycleException 83 { 84 super.start(); 85 ClassLoader loader = getClassLoader(); 86 if (loader instanceof WebAppClassLoader) 87 { 88 WebAppClassLoader webLoader = (WebAppClassLoader) loader; 89 webLoader.setFilteredPackages(filteredPackages); 90 if( classpath != null ) 91 { 92 for(URL url : classpath) 93 { 94 webLoader.addURL(url); 95 } 96 } 97 } 98 if (injectionContainer != null) 99 { 100 log.debug("injectionContainer enabled and processing beginning with Tomcat WebAppLoader"); 101 injectionContainer.setClassLoader(getClassLoader()); 104 injectionContainer.processMetadata(); 105 } 106 } 107 } 108 | Popular Tags |