IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
subMonitor.beginTask(LaunchingMessages.SocketAttachConnector_Connecting____1, 2);
subMonitor.subTask(LaunchingMessages.SocketAttachConnector_Configuring_connection____1);
AttachingConnector connector= getAttachingConnector();
String portNumberString = arguments.get("port"); //$NON-NLS-1$
if (portNumberString == null) {
abort(LaunchingMessages.SocketAttachConnector_Port_unspecified_for_remote_connection__2, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_PORT);
}
String host = arguments.get("hostname"); //$NON-NLS-1$
if (host == null) {
abort(LaunchingMessages.SocketAttachConnector_Hostname_unspecified_for_remote_connection__4, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_HOSTNAME);
}
Map<String, Connector.Argument> map= connector.defaultArguments();
Connector.Argument param= map.get("hostname"); //$NON-NLS-1$
param.setValue(host);
param= map.get("port"); //$NON-NLS-1$
param.setValue(portNumberString);
String timeoutString = arguments.get("timeout"); //$NON-NLS-1$
if (timeoutString != null) {
param= map.get("timeout"); //$NON-NLS-1$
param.setValue(timeoutString);
}
ILaunchConfiguration configuration = launch.getLaunchConfiguration();
boolean allowTerminate = false;
if (configuration != null) {
allowTerminate = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false);
}
subMonitor.worked(1);
subMonitor.subTask(LaunchingMessages.SocketAttachConnector_Establishing_connection____2);
try {
VirtualMachine vm = connector.attach(map);
String vmLabel = constructVMLabel(vm, host, portNumberString, configuration);
IDebugTarget debugTarget= DroolsDebugModel.newDebugTarget(launch, vm, vmLabel, null, allowTerminate, true);
launch.addDebugTarget(debugTarget);
subMonitor.worked(1);
subMonitor.done();