Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2017-07-31 19:44:48 +0000
committerJeff Johnston2017-08-01 00:31:14 +0000
commite8adb885b1980407d6a58df38ca152e633242d03 (patch)
treed81664be36c6834b8f5beb00c871d0fa92743e74
parent0c799fed64a3f18008dda6fb3cb11f6e043bc908 (diff)
downloadorg.eclipse.linuxtools-e8adb885b1980407d6a58df38ca152e633242d03.tar.gz
org.eclipse.linuxtools-e8adb885b1980407d6a58df38ca152e633242d03.tar.xz
org.eclipse.linuxtools-e8adb885b1980407d6a58df38ca152e633242d03.zip
Replace usage of getFirstConnection with the selected connection.v6.1.0
Change-Id: I2809d7e93f1a547313e751846d46298998ed9363 Reviewed-on: https://git.eclipse.org/r/102270 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java17
-rw-r--r--containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java4
-rw-r--r--containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ImageQuery.java3
3 files changed, 18 insertions, 6 deletions
diff --git a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java
index b17840a1b3..c39e314d7d 100644
--- a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java
+++ b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java
@@ -13,6 +13,7 @@ package org.eclipse.linuxtools.jdt.docker.launcher;
import java.io.File;
import java.net.URL;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
@@ -50,7 +51,7 @@ public class ContainerVMInstall implements IVMInstall {
@Override
public String getName() {
if (name == null) {
- DockerConnection conn = (DockerConnection) DockerConnectionManager.getInstance().getFirstConnection();
+ DockerConnection conn = getConnection();
ImageQuery q = new ImageQuery(conn, image.id());
name = q.getDefaultJVMName();
q.destroy();
@@ -66,7 +67,7 @@ public class ContainerVMInstall implements IVMInstall {
@Override
public File getInstallLocation() {
if (installLocation == null) {
- DockerConnection conn = (DockerConnection) DockerConnectionManager.getInstance().getFirstConnection();
+ DockerConnection conn = getConnection();
ImageQuery q = new ImageQuery(conn, image.id());
installLocation = q.getDefaultJVMInstallLocation();
q.destroy();
@@ -130,7 +131,7 @@ public class ContainerVMInstall implements IVMInstall {
final String[] fgCandidateJavaFiles = {"javaw", "javaw.exe", "java", "java.exe", "j9w", "j9w.exe", "j9", "j9.exe"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
final String[] fgCandidateJavaLocations = {"bin" + UnixFile.separatorChar, JRE + UnixFile.separatorChar + "bin" + UnixFile.separatorChar}; //$NON-NLS-1$ //$NON-NLS-2$
- DockerConnection conn = (DockerConnection) DockerConnectionManager.getInstance().getFirstConnection();
+ DockerConnection conn = getConnection();
ImageQuery q = new ImageQuery(conn, image.id());
// Try each candidate in order. The first one found wins. Thus, the order
@@ -148,4 +149,14 @@ public class ContainerVMInstall implements IVMInstall {
return null;
}
+ public DockerConnection getConnection () {
+ String connectionURI;
+ try {
+ connectionURI = config.getAttribute(JavaLaunchConfigurationConstants.CONNECTION_URI, (String) null);
+ return (DockerConnection) DockerConnectionManager.getInstance().getConnectionByUri(connectionURI);
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
}
diff --git a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java
index b7885bd1e3..ed07a7bf37 100644
--- a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java
+++ b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java
@@ -47,7 +47,7 @@ public class ContainerVMRunner extends StandardVMRunner {
@Override
protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
- String connectionUri = DockerConnectionManager.getInstance().getFirstConnection().getUri();
+ String connectionUri = ((ContainerVMInstall) fVMInstance).getConnection().getUri();
String command = String.join(" ", cmdLine); //$NON-NLS-1$
String newWD = workingDirectory.getAbsolutePath();
@@ -142,7 +142,7 @@ public class ContainerVMRunner extends StandardVMRunner {
@Override
protected boolean fileExists(File file) {
- DockerConnection conn = (DockerConnection) DockerConnectionManager.getInstance().getFirstConnection();
+ DockerConnection conn = ((ContainerVMInstall) fVMInstance).getConnection();
ImageQuery q = new ImageQuery(conn, fVMInstance.getId());
try {
return q.isFile(file);
diff --git a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ImageQuery.java b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ImageQuery.java
index a93390b5aa..61dc3610dd 100644
--- a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ImageQuery.java
+++ b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ImageQuery.java
@@ -33,6 +33,7 @@ public class ImageQuery {
private String id;
private DockerClient client;
+ private DockerConnection conn;
public ImageQuery(DockerConnection conn, String image) {
IDockerHostConfig hc = DockerHostConfig.builder().build();
@@ -49,6 +50,7 @@ public class ImageQuery {
this.id = conn.createContainer(cc, hc);
conn.startContainer(id, null);
this.client = conn.getClient();
+ this.conn = conn;
} catch (DockerException e) {
e.printStackTrace();
} catch (InterruptedException e) {
@@ -153,7 +155,6 @@ public class ImageQuery {
}
public void destroy() {
- IDockerConnection conn = DockerConnectionManager.getInstance().getFirstConnection();
try {
conn.stopContainer(id);
conn.removeContainer(id);

Back to the top