1 // ========================================================================
2 // Copyright (c) 2009 Intalio, Inc.
3 // ------------------------------------------------------------------------
4 // All rights reserved. This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v1.0
6 // and Apache License v2.0 which accompanies this distribution.
7 // The Eclipse Public License is available at
8 // http://www.eclipse.org/legal/epl-v10.html
9 // The Apache License v2.0 is available at
10 // http://www.opensource.org/licenses/apache2.0.php
11 // You may elect to redistribute this code under either of these licenses.
12 // Contributors:
13 // Hugues Malphettes - initial API and implementation
14 // ========================================================================
15 package org.eclipse.jetty.osgi.boot.internal.jsp;
16
17 import java.net.URL;
18 import java.net.URLClassLoader;
19
20 /**
21 * Tricky url classloader. In fact we don't want a real URLClassLoader: we want
22 * OSGi to provide its classloader and let it does. But to let
23 * {@link org.apache.jasper.compiler.TldLocationsCache} find the core tlds
24 * inside the jars we must be a URLClassLoader that returns an array of jars
25 * where tlds are stored when the method getURLs is called.
26 */
27 public class TldLocatableURLClassloader extends URLClassLoader
28 {
29
30 private URL[] _jarsWithTldsInside;
31
32 public TldLocatableURLClassloader(ClassLoader osgiClassLoader, URL[] jarsWithTldsInside)
33 {
34 super(new URL[] {},osgiClassLoader);
35 _jarsWithTldsInside = jarsWithTldsInside;
36 }
37
38 /**
39 * @return the jars that contains tlds so that TldLocationsCache or
40 * TldScanner can find them.
41 */
42 @Override
43 public URL[] getURLs()
44 {
45 return _jarsWithTldsInside;
46 }
47 }