Source:
private void deployBundle(Resolver resolver) { long bytes = getSize(resource); StringBuilder resourcesNames = new StringBuilder(); Resource[] resources = resolver.getRequiredResources(); StringBuilder dependencyStr = new StringBuilder(); if ((resources != null) && (resources.length > 0)) { for (Resource dependency : resources) { dependencyStr.append(dependency.getPresentationName()); dependencyStr.append(" ("); dependencyStr.append(dependency.getVersion()); dependencyStr.append(")\n"); bytes += getSize(dependency); } } resources = resolver.getOptionalResources(); if ((resources != null) && (resources.length > 0)) { for (Resource dependency : resources) { bytes += getSize(dependency); dependencyStr.append("Optional, "); dependencyStr.append(dependency.getPresentationName()); dependencyStr.append(" ("); dependencyStr.append(dependency.getVersion()); dependencyStr.append(")\n"); } } boolean deployBundle = true; if(dependencyStr.length() != 0) { if (dependencyStr.length() > 0) { resourcesNames.insert(0, ") ?\n"); resourcesNames.insert(0, BundleItem.getHumanReadableBytes(bytes)); resourcesNames.insert(0, "Do you want to download the following dependencies (Size : "); } if (DependencyMessageDialog.showModal(SwingUtilities.getWindowAncestor(frame), I18N.tr("Dependencies downloading"), resourcesNames.toString(), dependencyStr.toString()) .equals(DependencyMessageDialog.CHOICE.CANCEL)) { deployBundle = false; } } if(deployBundle){ DeployBundleSwingWorker worker = new DeployBundleSwingWorker(resolver); ServiceReference<ExecutorService> executorServiceReference = bundleContext.getServiceReference(ExecutorService.class); ExecutorService executorService = null; if(executorServiceReference != null){ executorService = bundleContext.getService(executorServiceReference); } if(executorService != null){ executorService.execute(worker); } else{ worker.execute(); } } }

Target:
private void deployBundle(Resolver resolver) { long bytes = getSize(resource); StringBuilder resourcesNames = new StringBuilder(); Resource[] resources = resolver.getRequiredResources(); StringBuilder dependencyStr = new StringBuilder(); if ((resources != null) && (resources.length > 0)) { for (Resource dependency : resources) { dependencyStr.append(dependency.getPresentationName()); dependencyStr.append(" ("); dependencyStr.append(dependency.getVersion()); dependencyStr.append(")\n"); bytes += getSize(dependency); } } resources = resolver.getOptionalResources(); if ((resources != null) && (resources.length > 0)) { for (Resource dependency : resources) { bytes += getSize(dependency); dependencyStr.append("Optional, "); dependencyStr.append(dependency.getPresentationName()); dependencyStr.append(" ("); dependencyStr.append(dependency.getVersion()); dependencyStr.append(")\n"); } } boolean deployBundle = true; if(dependencyStr.length() != 0) { if (dependencyStr.length() > 0) { resourcesNames.insert(0, ") ?\n"); resourcesNames.insert(0, BundleItem.getHumanReadableBytes(bytes)); resourcesNames.insert(0, "Do you want to download the following dependencies (Size : "); } if (DependencyMessageDialog.showModal(SwingUtilities.getWindowAncestor(frame), I18N.tr("Dependencies downloading"), resourcesNames.toString(), dependencyStr.toString()) .equals(DependencyMessageDialog.CHOICE.CANCEL)) { deployBundle = false; } } if(deployBundle){ DeployBundleSwingWorker worker = new DeployBundleSwingWorker(resolver); if(executorService != null){ executorService.execute(worker); } else{ worker.execute(); } } }