diff options
author | Thomas Watson | 2007-12-06 18:24:50 +0000 |
---|---|---|
committer | Thomas Watson | 2007-12-06 18:24:50 +0000 |
commit | 83351c285457ea84a7f0c5236b5f21cb063d7790 (patch) | |
tree | a35fda380fc0214defb16347bb26ccfc81380b86 | |
parent | 74a61bc89b31eee59a4d11c125e3e12e95620574 (diff) | |
download | rt.equinox.bundles-83351c285457ea84a7f0c5236b5f21cb063d7790.tar.gz rt.equinox.bundles-83351c285457ea84a7f0c5236b5f21cb063d7790.tar.xz rt.equinox.bundles-83351c285457ea84a7f0c5236b5f21cb063d7790.zip |
Bug 208121 App model: listening on org.eclipse.equinox.app.applications
3 files changed, 32 insertions, 33 deletions
diff --git a/bundles/org.eclipse.equinox.app/.options b/bundles/org.eclipse.equinox.app/.options new file mode 100644 index 000000000..ee97ccb62 --- /dev/null +++ b/bundles/org.eclipse.equinox.app/.options @@ -0,0 +1,4 @@ +#### Debugging options for org.eclipse.equinox.app + +# Turn on general debugging for org.eclipse.osgi +org.eclipse.equinox.app/debug=false diff --git a/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF index c58366bb9..d2f9d85c7 100755 --- a/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF @@ -23,7 +23,7 @@ Import-Package: org.eclipse.osgi.framework.console;resolution:=optional, org.osgi.service.event;version="1.0.0";resolution:=optional, org.osgi.service.packageadmin;version="1.2", org.osgi.util.tracker -Require-Bundle: org.eclipse.equinox.registry;bundle-version="[3.2.0,4.0.0)", +Require-Bundle: org.eclipse.equinox.registry;bundle-version="[3.4.0,4.0.0)", org.eclipse.equinox.common;bundle-version="[3.2.0,4.0.0)" Comment-DynamicImport: this is only used to allow late binding of the package DynamicImport-Package: org.osgi.service.event;version="1.0.0" diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java index 8ee82d26a..afdab08e2 100644 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java @@ -32,7 +32,7 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; * container will discover installed eclipse applications and register the * appropriate ApplicatoinDescriptor service with the service registry. */ -public class EclipseAppContainer implements IRegistryChangeListener, SynchronousBundleListener, ServiceTrackerCustomizer { +public class EclipseAppContainer implements IRegistryEventListener, SynchronousBundleListener, ServiceTrackerCustomizer { private static final String PI_RUNTIME = "org.eclipse.core.runtime"; //$NON-NLS-1$ private static final String PT_APPLICATIONS = "applications"; //$NON-NLS-1$ private static final String PT_APP_VISIBLE = "visible"; //$NON-NLS-1$ @@ -49,7 +49,6 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous private static final String PROP_PRODUCT = "eclipse.product"; //$NON-NLS-1$ private static final String PROP_ECLIPSE_APPLICATION = "eclipse.application"; //$NON-NLS-1$ private static final String PROP_ECLIPSE_APPLICATION_LAUNCH_DEFAULT = "eclipse.application.launchDefault"; //$NON-NLS-1$ - private static final String PROP_ECLIPSE_REGISTER_APP_DESC = "eclipse.application.registerDescriptors"; //$NON-NLS-1$ static final int NOT_LOCKED = 0; static final int LOCKED_SINGLETON_GLOBAL_RUNNING = 1; @@ -85,27 +84,19 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous void start() { launcherTracker.open(); - extensionRegistry.addRegistryChangeListener(this); + extensionRegistry.addListener(this, PI_RUNTIME + '.' + PT_APPLICATIONS); // need to listen for system bundle stopping context.addBundleListener(this); + // register all the descriptors + registerAppDescriptors(); String startDefaultProp = context.getProperty(EclipseAppContainer.PROP_ECLIPSE_APPLICATION_LAUNCH_DEFAULT); if (startDefaultProp == null || "true".equalsIgnoreCase(startDefaultProp)) { //$NON-NLS-1$ - boolean registerDescs = "true".equalsIgnoreCase(context.getProperty(EclipseAppContainer.PROP_ECLIPSE_REGISTER_APP_DESC)); //$NON-NLS-1$ - // register all the descriptors if requested to - if (registerDescs) - registerAppDescriptors(); // Start the default application try { startDefaultApp(); } catch (ApplicationException e) { Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.ERROR, 0, Messages.application_errorStartDefault, 0, e, null)); - if (!registerDescs) - // if an error occurred then register all desciptors if they were not registered already. - registerAppDescriptors(); } - } else { - // we are not running the default application; we should register all applications - registerAppDescriptors(); } } @@ -113,7 +104,7 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous // stop all applications stopAllApps(); context.removeBundleListener(this); - extensionRegistry.removeRegistryChangeListener(this); + extensionRegistry.removeListener(this); // flush the apps apps.clear(); branding = null; @@ -139,6 +130,8 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous } private EclipseAppDescriptor createAppDescriptor(IExtension appExtension) { + if (Activator.DEBUG) + System.out.println("Creating application descriptor: " + appExtension.getUniqueIdentifier()); //$NON-NLS-1$ String iconPath = null; synchronized (apps) { EclipseAppDescriptor appDescriptor = (EclipseAppDescriptor) apps.get(appExtension.getUniqueIdentifier()); @@ -193,6 +186,8 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous } private EclipseAppDescriptor removeAppDescriptor(String applicationId) { + if (Activator.DEBUG) + System.out.println("Removing application descriptor: " + applicationId); //$NON-NLS-1$ synchronized (apps) { EclipseAppDescriptor appDescriptor = (EclipseAppDescriptor) apps.remove(applicationId); if (appDescriptor == null) @@ -344,24 +339,6 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous } } - public void registryChanged(IRegistryChangeEvent event) { - processAppDeltas(event.getExtensionDeltas(PI_RUNTIME, PT_APPLICATIONS)); - processAppDeltas(event.getExtensionDeltas(Activator.PI_APP, PT_APPLICATIONS)); - } - - private void processAppDeltas(IExtensionDelta[] deltas) { - for (int i = 0; i < deltas.length; i++) { - switch (deltas[i].getKind()) { - case IExtensionDelta.ADDED : - createAppDescriptor(deltas[i].getExtension()); - break; - case IExtensionDelta.REMOVED : - removeAppDescriptor(deltas[i].getExtension().getUniqueIdentifier()); - break; - } - } - } - public void bundleChanged(BundleEvent event) { // if this is not the system bundle stopping then ignore the event if ((BundleEvent.STOPPING & event.getType()) == 0 || event.getBundle().getBundleId() != 0) @@ -608,4 +585,22 @@ public class EclipseAppContainer implements IRegistryChangeListener, Synchronous public void removedService(ServiceReference reference, Object service) { // Do nothing } + + public void added(IExtension[] extensions) { + for (int i = 0; i < extensions.length; i++) + createAppDescriptor(extensions[i]); + } + + public void added(IExtensionPoint[] extensionPoints) { + // nothing + } + + public void removed(IExtension[] extensions) { + for (int i = 0; i < extensions.length; i++) + removeAppDescriptor(extensions[i].getUniqueIdentifier()); + } + + public void removed(IExtensionPoint[] extensionPoints) { + // nothing + } } |