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