View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 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   * BundleClassLoaderHelper
26   * <p> 
27   * Is there a clean OSGi way to go from the Bundle object to the classloader of
28   * the Bundle ? You can certainly take a class inside the bundle and get the
29   * bundle's classloader that way. Getting the classloader directly from the
30   * bundle would be nice.
31   * <p>
32   * We could use fragments that are specific to each OSGi implementation. Using
33   * introspection here to keep packaging simple and avoid the multiplication of
34   * the jars.
35   * <p>
36   * The default implementation relies on introspection and supports equinox-3.5
37   * and felix-2.0.0
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       * @param bundle the bundle
50       * @return The classloader of a given bundle. Assuming the bundle is
51       *         started.
52       */
53      public ClassLoader getBundleClassLoader(Bundle bundle);
54  
55  }