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.utils;
20
21 import org.eclipse.jetty.osgi.boot.utils.internal.DefaultBundleClassLoaderHelper;
22 import org.osgi.framework.Bundle;
23
24 /**
25 * Is there a clean OSGi way to go from the Bundle object to the classloader of
26 * the Bundle ? You can certainly take a class inside the bundle and get the
27 * bundle's classloader that way. Getting the classloader directly from the
28 * bundle would be nice.
29 * <p>
30 * We could use fragments that are specific to each OSGi implementation. Using
31 * introspection here to keep packaging simple and avoid the multiplication of
32 * the jars.
33 * </p>
34 * <p>
35 * The default implementation relies on introspection and supports equinox-3.5
36 * and felix-2.0.0
37 * </p>
38 */
39 public interface BundleClassLoaderHelper
40 {
41
42 /** The name of the custom implementation for this interface in a fragment. */
43 public static final String CLASS_NAME = "org.eclipse.jetty.osgi.boot.utils.BundleClassLoaderHelperImpl";
44
45 /** The default instance supports felix and equinox */
46 public static BundleClassLoaderHelper DEFAULT = new DefaultBundleClassLoaderHelper();
47
48 /**
49 * @return The classloader of a given bundle. Assuming the bundle is
50 * started.
51 */
52 public ClassLoader getBundleClassLoader(Bundle bundle);
53
54 }