keeping JMX connection open and react to connection lost event + integrating remote apps into the regular connect/disconnect command handling

This commit is contained in:
Martin Lippert
2019-09-11 12:47:48 +02:00
parent 96e5b1d1a4
commit 66c95991a9
10 changed files with 225 additions and 115 deletions

View File

@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -94,8 +95,14 @@ public class LiveProcessCommandElement extends QuickAccessElement {
commandParams.setArguments(arguments);
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
ls.getWorkspaceService().executeCommand(commandParams)).toArray(CompletableFuture[]::new)).join();
try {
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
ls.getWorkspaceService().executeCommand(commandParams)).toArray(CompletableFuture[]::new)).get(2, TimeUnit.SECONDS);
}
catch (Exception e) {
// TODO: better exception handling
e.printStackTrace();
}
}
}

View File

@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
@@ -59,9 +60,16 @@ public class LiveProcessCommandsQuickAccessProvider implements IQuickAccessCompu
commandParams.setCommand(LiveProcessCommandElement.COMMAND_LIST_PROCESSES);
List<QuickAccessElement> res = Collections.synchronizedList(new ArrayList<>());
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
ls.getWorkspaceService().executeCommand(commandParams).thenAcceptAsync(commandResult ->
createCommandItems(res, commandResult))).toArray(CompletableFuture[]::new)).join();
try {
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
ls.getWorkspaceService().executeCommand(commandParams).thenAcceptAsync(commandResult ->
createCommandItems(res, commandResult))).toArray(CompletableFuture[]::new)).get(2000, TimeUnit.MILLISECONDS);
}
catch (Exception e) {
// TODO: better error handling
e.printStackTrace();
}
return res.toArray(new QuickAccessElement[res.size()]);
}