KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > web > tomcat > tc5 > WebAppLoader


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.web.tomcat.tc5;
9
10 import org.apache.catalina.loader.WebappLoader;
11 import org.apache.catalina.LifecycleException;
12
13 /**
14  * Override the tomcat WebappLoader to set the default class loader to the
15  * WebAppClassLoader and pass the filtered packages to the WebAppClassLoader.
16  *
17  * @author Scott.Stark@jboss.org
18  * @version $Revision: 1.1 $
19  */

20 public class WebAppLoader extends WebappLoader
21 {
22    private String JavaDoc[] filteredPackages = {
23       "org.apache.commons.logging"
24    };
25
26    public WebAppLoader()
27    {
28       super();
29       setLoaderClass(WebAppClassLoader.class.getName());
30    }
31
32    public WebAppLoader(ClassLoader JavaDoc parent, String JavaDoc[] filteredPackages)
33    {
34       super(parent);
35       setLoaderClass(WebAppClassLoader.class.getName());
36       this.filteredPackages = filteredPackages;
37    }
38
39    /**
40     * Override to apply the filteredPackages to the jboss WebAppClassLoader
41     *
42     * @throws LifecycleException
43     */

44    public void start() throws LifecycleException
45    {
46       super.start();
47       ClassLoader JavaDoc loader = getClassLoader();
48       if( loader instanceof WebAppClassLoader )
49       {
50          WebAppClassLoader webLoader = (WebAppClassLoader) loader;
51          webLoader.setFilteredPackages(filteredPackages);
52       }
53    }
54 }
55
Popular Tags