Package: OsgiFramework

OsgiFramework

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.kernel.osgi.framework;
13:
14: import java.io.File;
15: import java.util.jar.Manifest;
16:
17: import org.osgi.framework.Bundle;
18: import org.osgi.framework.BundleContext;
19: import org.osgi.framework.BundleException;
20: import org.osgi.service.packageadmin.PackageAdmin;
21:
22: /**
23: * <code>OsgiFramework</code> defines a basic abstraction for interacting with various OSGi implementations in a
24: * server-independent manner.
25: * <p/>
26: *
27: * Implementations <strong>must</strong> make themselves available in the OSGi service registry under the
28: * <code>OsgiFramework</code> class names.
29: *
30: */
31: @SuppressWarnings("deprecation")
32: public interface OsgiFramework {
33:
34: /**
35: * Name of the {@link Manifest} entry defining the scope of a bundle.
36: */
37: public static String HEADER_MODULE_SCOPE = "Module-Scope";
38:
39: /**
40: * Gets the {@link BundleContext} of the system {@link Bundle}.
41: *
42: * @return the system <code>BundleContext</code>.
43: */
44: BundleContext getBundleContext();
45:
46: /**
47: * Gets the {@link ClassLoader} for the supplied {@link Bundle}.
48: *
49: * @param bundle the <code>Bundle</code>.
50: * @return the <code>ClassLoader</code>.
51: */
52: ClassLoader getBundleClassLoader(Bundle bundle);
53:
54: /**
55: * Returns true if the class with the given name will be loaded via boot delegation by the underlying OSGi framework
56: *
57: * @param className The class name
58: * @return Whether the underlying framework considers the class to be boot delegated.
59: */
60: boolean isBootDelegated(String className);
61:
62: /**
63: * Returns all of the supplied bundle's direct dependencies. A bundle's direct dependencies are the bundles to which
64: * its package imports have been wired. Equivalent to calling <code>getDirectDependencies(bundle, false)</code>.
65: *
66: * @param bundle The bundle for which the direct dependencies are required
67: * @return the supplied bundle's direct dependencies
68: */
69: Bundle[] getDirectDependencies(Bundle bundle);
70:
71: /**
72: * Returns all of the supplied bundle's direct dependencies, optionally including the fragments, if any, of each
73: * direct dependency in the returned array. A bundle's direct dependencies are the bundles to which its package
74: * imports have been wired.
75: *
76: * @param bundle The bundle for which the direct dependencies are required
77: * @param includeFragments <code>true</code> if fragments of bundles to which package imports have been wired should
78: * be included in the returned array
79: * @return the supplied bundle's direct dependencies
80: */
81: Bundle[] getDirectDependencies(Bundle bundle, boolean includeFragments);
82:
83: /**
84: * Refreshes the supplied {@link Bundle}. Reloads all contents, and refreshes the packages.
85: *
86: * @param bundle the <code>Bundle</code> to refresh.
87: * @throws BundleException if there is an error during refresh.
88: * @see PackageAdmin#refreshPackages(Bundle[])
89: */
90: void refresh(Bundle bundle) throws BundleException;
91:
92: /**
93: * Updates the supplied <code>Bundle</code> from the supplied file or directory using the supplied
94: * <code>ManifestTransformer</code> to transformer the <code>Bundle</code>'s manifest as it is updated.
95: *
96: * @param bundle the bundle to update
97: * @param manifestTransformer the manifest transformer to apply to the bundle's manifest
98: * @param location the file or directory containing the updated bundle contents
99: *
100: * @throws BundleException if the bundle fails to update
101: */
102: void update(Bundle bundle, ManifestTransformer manifestTransformer, File location) throws BundleException;
103: }