Add support for 'processId/appGuid' for remote apps
This commit is contained in:
@@ -40,6 +40,8 @@ import org.springsource.ide.eclipse.commons.livexp.core.ValueListener;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.Disposable;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
/**
|
||||
* if the system property "boot-java-ls-port" exists, delegate to the socket-based
|
||||
@@ -163,6 +165,11 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
//keepChecking defaults to true. Boot dash automatic remote apps should override this explicitly.
|
||||
//Reason. All other 'sources' of remote apps are 'manual' and we want them to default to
|
||||
//'keepChecking' even if the user doesn't set this to true manually.
|
||||
|
||||
private String processId = null;
|
||||
|
||||
public RemoteBootAppData() {
|
||||
}
|
||||
|
||||
public RemoteBootAppData(String jmxurl, String host) {
|
||||
super();
|
||||
@@ -209,6 +216,14 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
public void setKeepChecking(boolean keepChecking) {
|
||||
this.keepChecking = keepChecking;
|
||||
}
|
||||
|
||||
public String getProcessId() {
|
||||
return processId;
|
||||
}
|
||||
|
||||
public void getProcessId(String processId) {
|
||||
this.processId = processId;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendConfiguration() {
|
||||
@@ -292,6 +307,10 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
app.setKeepChecking("true".equals(keepChecking));
|
||||
}
|
||||
return app;
|
||||
} else if (incomingData instanceof Map) {
|
||||
Gson gson = new Gson();
|
||||
JsonElement tree = gson.toJsonTree(incomingData);
|
||||
return gson.fromJson(tree, RemoteBootAppData.class);
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid remote app data: "+incomingData);
|
||||
}
|
||||
|
||||
@@ -19,13 +19,15 @@ public class LiveProcessCommand {
|
||||
private String label;
|
||||
private String action;
|
||||
private String projectName;
|
||||
private String processId;
|
||||
|
||||
public LiveProcessCommand(String action, String processKey, String label, String projectName) {
|
||||
public LiveProcessCommand(String action, String processKey, String label, String projectName, String processId) {
|
||||
super();
|
||||
this.processKey = processKey;
|
||||
this.label = label;
|
||||
this.action = action;
|
||||
this.projectName = projectName;
|
||||
this.processId = processId;
|
||||
}
|
||||
|
||||
public String getProcessKey() {
|
||||
@@ -42,10 +44,14 @@ public class LiveProcessCommand {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LiveProcessCommand [processKey=" + processKey + ", label=" + label + ", action=" + action + "]";
|
||||
return "LiveProcessCommand [processKey=" + processKey + ", action=" + action + ", projectName=" + projectName
|
||||
+ ", processId=" + processId + "]";
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
public String getProcessId() {
|
||||
return processId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ public class SpringProcessCommandHandler {
|
||||
for (SpringProcessConnector process : connectedProcesses) {
|
||||
String processKey = process.getProcessKey();
|
||||
String label = process.getLabel();
|
||||
result.add(new LiveProcessCommand(COMMAND_REFRESH, processKey, label, process.getProjectName()));
|
||||
result.add(new LiveProcessCommand(COMMAND_DISCONNECT, processKey, label, process.getProjectName()));
|
||||
result.add(new LiveProcessCommand(COMMAND_REFRESH, processKey, label, process.getProjectName(), process.getProcessId()));
|
||||
result.add(new LiveProcessCommand(COMMAND_DISCONNECT, processKey, label, process.getProjectName(), process.getProcessId()));
|
||||
alreadyConnected.add(processKey);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class SpringProcessCommandHandler {
|
||||
if (!alreadyConnected.contains(processKey)) {
|
||||
String label = localProcess.getLabel();
|
||||
|
||||
LiveProcessCommand command = new LiveProcessCommand(COMMAND_CONNECT, processKey, label, localProcess.getProjectName());
|
||||
LiveProcessCommand command = new LiveProcessCommand(COMMAND_CONNECT, processKey, label, localProcess.getProjectName(), null);
|
||||
result.add(command);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class SpringProcessCommandHandler {
|
||||
String processKey = SpringProcessConnectorRemote.getProcessKey(remoteProcess);
|
||||
if (!alreadyConnected.contains(processKey)) {
|
||||
String label = "remote process: " + remoteProcess.getJmxurl();
|
||||
result.add(new LiveProcessCommand(COMMAND_CONNECT, processKey, label, null));
|
||||
result.add(new LiveProcessCommand(COMMAND_CONNECT, processKey, label, null, remoteProcess.getProcessId()));
|
||||
}
|
||||
}
|
||||
log.info("getProcessCommands => {}", result);
|
||||
|
||||
@@ -25,5 +25,6 @@ public interface SpringProcessConnector {
|
||||
void addConnectorChangeListener(SpringProcessConnectionChangeListener listener);
|
||||
void removeConnectorChangeListener(SpringProcessConnectionChangeListener listener);
|
||||
String getProjectName();
|
||||
String getProcessId();
|
||||
|
||||
}
|
||||
|
||||
@@ -184,4 +184,8 @@ public class SpringProcessConnectorOverJMX implements SpringProcessConnector {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProcessId() {
|
||||
return processID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ public class SpringProcessConnectorRemote {
|
||||
//keepChecking defaults to true. Boot dash automatic remote apps should override this explicitly.
|
||||
//Reason. All other 'sources' of remote apps are 'manual' and we want them to default to
|
||||
//'keepChecking' even if the user doesn't set this to true manually.
|
||||
|
||||
private String processId;
|
||||
|
||||
public String getJmxurl() {
|
||||
return jmxurl;
|
||||
@@ -85,6 +87,14 @@ public class SpringProcessConnectorRemote {
|
||||
+ port + ", keepChecking=" + keepChecking + "]";
|
||||
}
|
||||
|
||||
public String getProcessId() {
|
||||
return processId;
|
||||
}
|
||||
|
||||
public void setProcessId(String processId) {
|
||||
this.processId = processId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -94,6 +104,7 @@ public class SpringProcessConnectorRemote {
|
||||
result = prime * result + (keepChecking ? 1231 : 1237);
|
||||
result = prime * result + ((port == null) ? 0 : port.hashCode());
|
||||
result = prime * result + ((urlScheme == null) ? 0 : urlScheme.hashCode());
|
||||
result = prime * result + ((processId == null) ? 0 : processId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -128,9 +139,13 @@ public class SpringProcessConnectorRemote {
|
||||
return false;
|
||||
} else if (!urlScheme.equals(other.urlScheme))
|
||||
return false;
|
||||
if (processId == null) {
|
||||
if (other.processId != null)
|
||||
return false;
|
||||
} else if (!processId.equals(other.processId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SpringProcessConnectorRemote.class);
|
||||
@@ -191,8 +206,8 @@ public class SpringProcessConnectorRemote {
|
||||
|
||||
public void connectProcess(RemoteBootAppData remoteProcess) {
|
||||
String processKey = getProcessKey(remoteProcess);
|
||||
String processID = null;
|
||||
String processName = null;
|
||||
String processID = remoteProcess.getProcessId();
|
||||
String processName = processKey;
|
||||
String jmxURL = remoteProcess.getJmxurl();
|
||||
String host = remoteProcess.getHost();
|
||||
String port = remoteProcess.getPort();
|
||||
|
||||
Reference in New Issue
Block a user