public static void throwIf(String message, List<Exception> exceptions) throws MultiException { if (exceptions != null && !exceptions.isEmpty()) { StringBuilder sb = new StringBuilder(message); sb.append(":"); for (Exception e : exceptions) { sb.append("\n\t"); sb.append(e.getMessage()); } throw new MultiException(sb.toString(), exceptions); } } }
protected void doExecute(List<Bundle> bundles) throws Exception { if (bundles.isEmpty()) { System.err.println("No bundles specified."); return; } List<Exception> exceptions = new ArrayList<Exception>(); for (Bundle bundle : bundles) { try { bundle.start(); } catch (Exception e) { exceptions.add(new Exception("Unable to start bundle " + bundle.getBundleId() + (e.getMessage() != null ? ": " + e.getMessage() : ""), e)); } } MultiException.throwIf("Error starting bundles", exceptions); }
protected void doExecute(List<Bundle> bundles) throws Exception { if (bundles.isEmpty()) { System.err.println("No bundles specified."); return; } List<Exception> exceptions = new ArrayList<Exception>(); for (Bundle bundle : bundles) { try { if (transientStop) { bundle.stop(Bundle.STOP_TRANSIENT); } else { bundle.stop(); } } catch (Exception e) { exceptions.add(new Exception("Unable to stop bundle " + bundle.getBundleId() + (e.getMessage() != null ? ": " + e.getMessage() : ""), e)); } } MultiException.throwIf("Error stopping bundles", exceptions); }
protected void doExecute(List<Bundle> bundles) throws Exception { if (bundles.isEmpty()) { System.err.println("No bundles specified."); return; } List<Exception> exceptions = new ArrayList<Exception>(); for (Bundle bundle : bundles) { try { bundle.stop(); } catch (Exception e) { exceptions.add(new Exception("Unable to stop bundle " + bundle.getBundleId() + (e.getMessage() != null ? ": " + e.getMessage() : ""), e)); } } for (Bundle bundle : bundles) { try { bundle.start(); } catch (Exception e) { exceptions.add(new Exception("Unable to start bundle " + bundle.getBundleId() + (e.getMessage() != null ? ": " + e.getMessage() : ""), e)); } } MultiException.throwIf("Error restarting bundles", exceptions); }
MultiException.throwIf("Error installing bundles", exceptions); return null;