@Override public void unloadPlugin(GoPluginDescriptor pluginDescriptor) { Bundle bundle = pluginDescriptor.bundle(); if (bundle == null) { return; } for (PluginChangeListener listener : pluginChangeListeners) { try { listener.pluginUnLoaded(pluginDescriptor); } catch (Exception e) { LOGGER.warn("A plugin unload listener ({}) failed: {}", listener.toString(), pluginDescriptor, e); } } try { bundle.stop(); bundle.uninstall(); } catch (Exception e) { throw new RuntimeException("Failed to unload plugin: " + bundle, e); } }
@Test public void shouldUnloadAPlugin() throws BundleException { GoPluginDescriptor pluginDescriptor = mock(GoPluginDescriptor.class); when(pluginDescriptor.bundle()).thenReturn(bundle); spy.unloadPlugin(pluginDescriptor); verify(bundle, atLeastOnce()).stop(); verify(bundle, atLeastOnce()).uninstall(); }
@Test public void shouldNotFailToUnloadAPluginWhenAPluginUnloadListenerFails() throws BundleException { GoPluginDescriptor pluginDescriptor = mock(GoPluginDescriptor.class); when(pluginDescriptor.bundle()).thenReturn(bundle); PluginChangeListener listenerWhichThrowsWhenUnloading = mock(PluginChangeListener.class); doThrow(new RuntimeException("Fail!")).when(listenerWhichThrowsWhenUnloading).pluginUnLoaded(pluginDescriptor); spy.addPluginChangeListener(listenerWhichThrowsWhenUnloading); spy.unloadPlugin(pluginDescriptor); verify(bundle, times(1)).stop(); verify(bundle, times(1)).uninstall(); }
@Test public void shouldRunOtherUnloadListenersEvenIfOneFails() throws BundleException { GoPluginDescriptor pluginDescriptor = mock(GoPluginDescriptor.class); when(pluginDescriptor.bundle()).thenReturn(bundle); PluginChangeListener listenerWhichWorks1 = mock(PluginChangeListener.class, "Listener Which Works: 1"); PluginChangeListener listenerWhichWorks2 = mock(PluginChangeListener.class, "Listener Which Works: 2"); PluginChangeListener listenerWhichThrowsWhenUnloading = mock(PluginChangeListener.class, "Listener Which Throws"); doThrow(new RuntimeException("Fail!")).when(listenerWhichThrowsWhenUnloading).pluginUnLoaded(pluginDescriptor); spy.addPluginChangeListener(listenerWhichWorks1); spy.addPluginChangeListener(listenerWhichThrowsWhenUnloading); spy.addPluginChangeListener(listenerWhichWorks2); spy.unloadPlugin(pluginDescriptor); verify(listenerWhichWorks1, times(1)).pluginUnLoaded(pluginDescriptor); verify(listenerWhichThrowsWhenUnloading, times(1)).pluginUnLoaded(pluginDescriptor); verify(listenerWhichWorks2, times(1)).pluginUnLoaded(pluginDescriptor); verify(bundle, times(1)).stop(); verify(bundle, times(1)).uninstall(); }
@Override public InstallOrUpgradeStatus removeAddOn(BundleSymbolicName bsn) { synchronized (mutex) { InstallOrUpgradeStatus status; try { Validate.notNull(bsn, "Bundle symbolic name required"); bsn.findBundleWithoutFail(context).uninstall(); LOGGER.log(Level.INFO, String.format("Bundle '%s' : Uninstalled!", bsn.getKey())); LOGGER.log(Level.INFO, ""); status = InstallOrUpgradeStatus.SUCCESS; return status; } catch (BundleException e) { LOGGER.warning("Unable to remove add-on: " + bsn.getKey()); status = InstallOrUpgradeStatus.FAILED; return status; } } }
public void uninstall(Bundle b) throws BundleException { b.uninstall(); _bundles.remove(b); } }
public void uninstallPlugins() { for (Bundle bundle : plugins) { try { bundle.uninstall(); } catch (Throwable t) { if (logger.isDebugEnabled()) { logger.debug("Exception caught uninstalling the bundle", t); } } } }
@Override public void run() { try { bundleContext.getBundle().uninstall(); } catch (Throwable e) { log.warn("Error occurred while uninstalling hosting.mgt UI bundle", e); } } };
private void uninstallBundle(Bundle bundle) { try { bundle.uninstall(); } catch (BundleException e) { log.error("Bundle " + bundle.getBundleId() + " failed to uninstall: " + e.getMessage()); } }
public void tryUninstall() throws BundleException { // only install if _we_ loaded the driver if ( !isInUse() && m_dynamic ) { m_bundle.uninstall(); } }
public void stopAndUninstall(Iterable<Bundle> bundles) throws BundleException { for (Bundle bundle : bundles) { stop(bundle); } for (Bundle bundle : bundles) { bundle.uninstall(); } }
public void uninstall() { // This method is called when the hk2-osgi-adapter module is stopped. // During that time, we need to stop all the modules, hence no sticky check is // performed in this method. try { bundle.uninstall(); } catch (BundleException e) { throw new RuntimeException(e); } registry.remove(this); this.registry = null; }
public void uninstall() { // This method is called when the hk2-osgi-adapter module is stopped. // During that time, we need to stop all the modules, hence no sticky check is // performed in this method. try { bundle.uninstall(); } catch (BundleException e) { throw new RuntimeException(e); } registry.remove(this); this.registry = null; }
public void uninstall(String bundleId) throws MBeanException { try { List<Bundle> bundles = selectBundles(bundleId); for (Bundle bundle : bundles) { bundle.uninstall(); } } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
public void uninstall(String bundleId) throws MBeanException { try { List<Bundle> bundles = selectBundles(bundleId); for (Bundle bundle : bundles) { bundle.uninstall(); } } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
@Override public synchronized void uninstallProbe() { Bundle bundle = framework.getBundleContext().getBundle(probeId); try { bundle.uninstall(); probeId = null; } catch (BundleException exc) { throw new TestContainerException(exc); } } }
@Override public Result call() throws Exception { try { logger().info("Uninstalling bundle {}", bundle.getSymbolicName()); bundle.uninstall(); return ok(); } catch (BundleException e) { logger().error("Cannot uninstall bundle {}", bundle.getSymbolicName(), e); return badRequest(e); } } });
private void uninstall(ApplicationContextImpl app) { Set<Bundle> bundles = app.getApplicationContent(); for (Bundle b : bundles) { try { b.uninstall(); } catch (BundleException be) { // TODO ignoring this feels wrong, but I'm not sure how to communicate to the caller multiple failures. } } app.setState(ApplicationState.UNINSTALLED); }
@Test public void testUninstallAndReinstallBundle() throws Exception { Bundle bundle = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH); checkMath(bundle, 3, 6); setAMultiplier(bundle, 3); checkMath(bundle, 3, 9); bundle.uninstall(); Bundle bundle2 = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH); checkMath(bundle2, 3, 6); }