KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > loader > WebappClassLoader


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: WebappClassLoader.java,v 1.6 2004/12/16 16:09:11 sauthieg Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_lib.loader;
27
28 import java.io.IOException JavaDoc;
29 import java.net.URL JavaDoc;
30
31 /**
32  * ClassLoader specialized for WebApps. It add the WEB-INF/wsdl/ directory
33  * of the war in the URL repository, the base URL of the jar file and the
34  * WEB-INF/classes/ directory.
35  * Used in WsGen.
36  *
37  * @author Guillaume Sauthier
38  */

39 public class WebappClassLoader extends SimpleWebappClassLoader {
40
41     /** Classes directory entry name in Web module */
42     private static final String JavaDoc CLASSES_DIRECTORY = "WEB-INF/classes/";
43
44     /** Libraries directory entry name in Web module */
45     private static final String JavaDoc LIB_DIRECTORY = "WEB-INF/lib/";
46
47     /**
48      * Create a new WebappClassLoader with default parent ClassLoader
49      *
50      * @param module an URL of Web file
51      *
52      * @throws IOException if creation fails
53      */

54     public WebappClassLoader(URL JavaDoc module) throws IOException JavaDoc {
55         super(module);
56     }
57
58     /**
59      * Create a new WebappClassLoader with specified parent ClassLoader
60      *
61      * @param module an URL of Web file
62      * @param parent the parent ClasLoader
63      *
64      * @throws IOException if creation fails
65      */

66     public WebappClassLoader(URL JavaDoc module, ClassLoader JavaDoc parent) throws IOException JavaDoc {
67         super(module, parent);
68     }
69
70     /**
71      * Add the WEB-INF/classes/ directory and the content of
72      * WEB-INF/lib/ in the ClassLoader
73      *
74      * @throws IOException if cannot add in repository specified paths
75      */

76     protected void init() throws IOException JavaDoc {
77         super.init();
78         addInRepository(CLASSES_DIRECTORY);
79         addContentInRepository(LIB_DIRECTORY);
80     }
81
82     /**
83      * @return Returns the Base URL for this ClassLoader
84      */

85     public URL JavaDoc getBaseURL() {
86         return getBases()[0];
87     }
88
89 }
90
Popular Tags