1 //
2 // ========================================================================
3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.osgi.boot.internal.jsp;
20
21 import java.net.URL;
22
23 /**
24 * Add a classloader to the
25 * org.apache.jasper.compiler.TldLocatableURLClassloader. Hopefuly not
26 * necessary: still experimenting.
27 *
28 * @see TldLocatableURLClassloader
29 */
30 public class TldLocatableURLClassloaderWithInsertedJettyClassloader extends TldLocatableURLClassloader
31 {
32
33 private ClassLoader _internalClassLoader;
34
35 /**
36 *
37 * @param osgiClassLoaderParent
38 * The parent classloader
39 * @param internalClassLoader
40 * The classloader that will be at the same level than the
41 * jarsWithTldsInside
42 * @param jarsWithTldsInside
43 * jars that are scanned for tld files.
44 */
45 public TldLocatableURLClassloaderWithInsertedJettyClassloader(ClassLoader osgiClassLoaderParent, ClassLoader internalClassLoader, URL[] jarsWithTldsInside)
46 {
47 super(osgiClassLoaderParent,jarsWithTldsInside);
48 _internalClassLoader = internalClassLoader;
49 }
50
51 protected Class<?> findClass(String name) throws ClassNotFoundException
52 {
53 try
54 {
55 return super.findClass(name);
56 }
57 catch (ClassNotFoundException cne)
58 {
59 if (_internalClassLoader != null)
60 {
61 return _internalClassLoader.loadClass(name);
62 }
63 else
64 {
65 throw cne;
66 }
67 }
68 }
69 }