01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2003-2004 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 5983 2004-12-16 16:09:12Z sauthieg $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_lib.loader;
25:
26: import java.io.IOException;
27: import java.net.URL;
28:
29: /**
30: * ClassLoader specialized for WebApps. It add the WEB-INF/wsdl/ directory
31: * of the war in the URL repository, the base URL of the jar file and the
32: * WEB-INF/classes/ directory.
33: * Used in WsGen.
34: *
35: * @author Guillaume Sauthier
36: */
37: public class WebappClassLoader extends SimpleWebappClassLoader {
38:
39: /** Classes directory entry name in Web module */
40: private static final String CLASSES_DIRECTORY = "WEB-INF/classes/";
41:
42: /** Libraries directory entry name in Web module */
43: private static final String LIB_DIRECTORY = "WEB-INF/lib/";
44:
45: /**
46: * Create a new WebappClassLoader with default parent ClassLoader
47: *
48: * @param module an URL of Web file
49: *
50: * @throws IOException if creation fails
51: */
52: public WebappClassLoader(URL module) throws IOException {
53: super (module);
54: }
55:
56: /**
57: * Create a new WebappClassLoader with specified parent ClassLoader
58: *
59: * @param module an URL of Web file
60: * @param parent the parent ClasLoader
61: *
62: * @throws IOException if creation fails
63: */
64: public WebappClassLoader(URL module, ClassLoader parent)
65: throws IOException {
66: super (module, parent);
67: }
68:
69: /**
70: * Add the WEB-INF/classes/ directory and the content of
71: * WEB-INF/lib/ in the ClassLoader
72: *
73: * @throws IOException if cannot add in repository specified paths
74: */
75: protected void init() throws IOException {
76: super .init();
77: addInRepository(CLASSES_DIRECTORY);
78: addContentInRepository(LIB_DIRECTORY);
79: }
80:
81: /**
82: * @return Returns the Base URL for this ClassLoader
83: */
84: public URL getBaseURL() {
85: return getBases()[0];
86: }
87:
88: }
|