diff options
author | Thomas Watson | 2013-10-09 20:29:22 +0000 |
---|---|---|
committer | Thomas Watson | 2013-10-09 20:29:22 +0000 |
commit | 758730093cc35939fa6e60305a1dfbf9bbc03028 (patch) | |
tree | 0f7ad63288a1a25aa66c1d8ea51c6b3252d97aaf | |
parent | 3f410db5092aaa5705d6fcd392d47888f440e4a0 (diff) | |
download | rt.equinox.framework-758730093cc35939fa6e60305a1dfbf9bbc03028.tar.gz rt.equinox.framework-758730093cc35939fa6e60305a1dfbf9bbc03028.tar.xz rt.equinox.framework-758730093cc35939fa6e60305a1dfbf9bbc03028.zip |
Bug 419079 - framework events for extension activator errors must use a BundleException
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java index 7ff816973..0b5c8a6ce 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java @@ -24,7 +24,9 @@ import org.eclipse.osgi.framework.util.ArrayMap; import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory; import org.eclipse.osgi.internal.hookregistry.HookRegistry; +import org.eclipse.osgi.internal.messages.Msg; import org.eclipse.osgi.storage.BundleInfo.Generation; +import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.framework.namespace.HostNamespace; import org.osgi.framework.wiring.BundleWiring; @@ -162,7 +164,11 @@ public class FrameworkExtensionInstaller { List<ActivatorHookFactory> activatorHookFactories = hookRegistry.getActivatorHookFactories(); for (ActivatorHookFactory activatorFactory : activatorHookFactories) { BundleActivator activator = activatorFactory.createActivator(); - startActivator(activator, context, null); + try { + startActivator(activator, context, null); + } catch (Exception e) { + configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, null, e); + } } // start the extension bundle activators. In Equinox we let // framework extensions define Bundle-Activator headers. @@ -186,7 +192,9 @@ public class FrameworkExtensionInstaller { try { activator.stop(context); } catch (Exception e) { - configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, current.get(activator), e); + Bundle b = current.get(activator); + BundleException eventException = new BundleException(NLS.bind(Msg.BUNDLE_ACTIVATOR_EXCEPTION, new Object[] {activator.getClass(), "stop", b == null ? "" : b.getSymbolicName()}), BundleException.ACTIVATOR_ERROR, e); //$NON-NLS-1$ //$NON-NLS-2$ + configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, b, eventException); } } } @@ -201,23 +209,28 @@ public class FrameworkExtensionInstaller { if (activatorName == null) { return; } + + BundleActivator activator = null; try { Class<?> activatorClass = Class.forName(activatorName); - BundleActivator activator = (BundleActivator) activatorClass.newInstance(); + activator = (BundleActivator) activatorClass.newInstance(); startActivator(activator, context, extensionRevision.getBundle()); } catch (Exception e) { - configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, extensionRevision.getBundle(), e); + BundleException eventException; + if (activator == null) { + eventException = new BundleException(Msg.BundleContextImpl_LoadActivatorError, BundleException.ACTIVATOR_ERROR, e); + } else { + eventException = new BundleException(NLS.bind(Msg.BUNDLE_ACTIVATOR_EXCEPTION, new Object[] {activator.getClass(), "start", extensionRevision.getSymbolicName()}), BundleException.ACTIVATOR_ERROR, e); //$NON-NLS-1$ + } + configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, extensionRevision.getBundle(), eventException); } + } - private void startActivator(BundleActivator activator, BundleContext context, Bundle b) { - try { - activator.start(context); - synchronized (hookActivators) { - hookActivators.put(activator, b); - } - } catch (Exception e) { - configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, b, e); + private void startActivator(BundleActivator activator, BundleContext context, Bundle b) throws Exception { + activator.start(context); + synchronized (hookActivators) { + hookActivators.put(activator, b); } } |