diff options
author | Susan Franklin | 2008-11-13 21:40:23 +0000 |
---|---|---|
committer | Susan Franklin | 2008-11-13 21:40:23 +0000 |
commit | 842961a273de3679fad54258b95686d23407b651 (patch) | |
tree | 91fa1c57570c207b75ffa549e74a57eb04fb61ba /bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java | |
parent | e4e75eef4f5375d733475300cc60c6b01ea6dbd4 (diff) | |
download | rt.equinox.p2-842961a273de3679fad54258b95686d23407b651.tar.gz rt.equinox.p2-842961a273de3679fad54258b95686d23407b651.tar.xz rt.equinox.p2-842961a273de3679fad54258b95686d23407b651.zip |
Bug 227582 - [ui] Should the early startup extension be separated from the rest of the UI plugin?
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java index 0b4e3c2c1..a0900a12e 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java @@ -14,9 +14,11 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEv import org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateChecker; import org.eclipse.equinox.internal.provisional.p2.updatechecker.UpdateChecker; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; +import org.osgi.service.packageadmin.PackageAdmin; /** * Activator class for the automatic updates plugin @@ -25,6 +27,9 @@ public class AutomaticUpdatePlugin extends AbstractUIPlugin { private static AutomaticUpdatePlugin plugin; private static BundleContext context; + private static PackageAdmin packageAdmin = null; + private static ServiceReference packageAdminRef = null; + private AutomaticUpdateScheduler scheduler; private AutomaticUpdater updater; private ServiceRegistration registrationChecker; @@ -34,6 +39,21 @@ public class AutomaticUpdatePlugin extends AbstractUIPlugin { public static BundleContext getContext() { return context; } + + public static Bundle getBundle(String symbolicName) { + if (packageAdmin == null) + return null; + Bundle[] bundles = packageAdmin.getBundles(symbolicName, null); + if (bundles == null) + return null; + // Return the first bundle that is not installed or uninstalled + for (int i = 0; i < bundles.length; i++) { + if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { + return bundles[i]; + } + } + return null; + } /** * Returns the singleton plugin instance @@ -57,6 +77,13 @@ public class AutomaticUpdatePlugin extends AbstractUIPlugin { super.start(bundleContext); plugin = this; context = bundleContext; + packageAdminRef = bundleContext.getServiceReference(PackageAdmin.class.getName()); + packageAdmin = (PackageAdmin) bundleContext.getService(packageAdminRef); + + // TODO for now we need to manually start up the update checker + // because the Eclipse Application launch config won't let me specify bundles to start. + getBundle("org.eclipse.equinox.p2.updatechecker").start(Bundle.START_TRANSIENT); //$NON-NLS-1$ + registrationChecker = context.registerService(IUpdateChecker.SERVICE_NAME, new UpdateChecker(), null); } @@ -69,6 +96,10 @@ public class AutomaticUpdatePlugin extends AbstractUIPlugin { updater.shutdown(); updater = null; } + registrationChecker.unregister(); + registrationChecker = null; + packageAdmin = null; + packageAdminRef = null; plugin = null; super.stop(bundleContext); context = null; |