View Javadoc

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