protected void setEnvironmentVariable( CloudFoundryApplicationModule appModule, CloudFoundryServer cloudServer, int remoteDebugPort, IProgressMonitor monitor) throws CoreException { ApplicationDeploymentInfo info = appModule.getDeploymentInfo(); List<EnvironmentVariable> vars = info.getEnvVariables(); EnvironmentVariable javaOpts = getDebugEnvironment(info); IModule[] mod = new IModule[] {appModule.getLocalModule()}; boolean restart = CloudFoundryProperties.isModuleStopped.testProperty(mod, cloudServer); if (!containsDebugOption(javaOpts)) { if (javaOpts == null) { javaOpts = new EnvironmentVariable(); javaOpts.setVariable(JAVA_OPTS); vars.add(javaOpts); } String debugOpts = "-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=" + remoteDebugPort //$NON-NLS-1$ + ",suspend=n"; //$NON-NLS-1$ javaOpts.setValue(debugOpts); cloudServer .getBehaviour() .operations() .environmentVariablesUpdate( appModule.getLocalModule(), appModule.getDeployedApplicationName(), vars) .run(monitor); restart = true; } if (restart) { printToConsole( appModule, cloudServer, NLS.bind( Messages.SshDebugLaunchConfigDelegate_RESTARTING_APP, appModule.getDeployedApplicationName()), false); cloudServer .getBehaviour() .operations() .applicationDeployment(mod, ApplicationAction.START, false) .run(monitor); } }
protected DebugConnectionDescriptor getSshConnectionDescriptor( CloudFoundryApplicationModule appModule, CloudFoundryServer cloudServer, int appInstance, int remoteDebugPort, IProgressMonitor monitor) throws CoreException { CFInfo cloudInfo = cloudServer.getBehaviour().getCloudInfo(); if (cloudInfo instanceof CloudInfoSsh) { ISshClientSupport ssh = cloudServer.getBehaviour().getSshClientSupport(monitor); if (ssh == null) { return null; } try { printToConsole( appModule, cloudServer, NLS.bind( Messages.SshDebugLaunchConfigDelegate_CONNECTING_FOR_USER, appModule.getDeployedApplicationName()), false); Session session = ssh.connect( appModule.getDeployedApplicationName(), appInstance, cloudServer.getServer(), monitor); printToConsole( appModule, cloudServer, NLS.bind( Messages.SshDebugLaunchConfigDelegate_CONNECTION_SUCCESSFUL, appModule.getDeployedApplicationName()), false); int localDebuggerPort = session.setPortForwardingL(0, "localhost", remoteDebugPort); // $NON-NLS-1$ printToConsole( appModule, cloudServer, NLS.bind( Messages.SshDebugLaunchConfigDelegate_PORT_FORWARDING_SUCCESSFUL, remoteDebugPort, localDebuggerPort), false); return new DebugConnectionDescriptor("localhost", localDebuggerPort); // $NON-NLS-1$ } catch (JSchException e) { throw CloudErrorUtil.toCoreException( "SSH connection error " + e.getMessage()); // $NON-NLS-1$ } } else { throw CloudErrorUtil.toCoreException( "Unable to resolve SSH connection information from the Cloud Foundry target. Please ensure SSH is supported."); //$NON-NLS-1$ } }