Example usage for org.springframework.ide.eclipse.boot.dash.model RunState DEBUGGING

List of usage examples for org.springframework.ide.eclipse.boot.dash.model RunState DEBUGGING

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.model RunState DEBUGGING.

Prototype

RunState DEBUGGING

To view the source code for org.springframework.ide.eclipse.boot.dash.model RunState DEBUGGING.

Click Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudAppDashElement.java

public void pushAndDebug(CloudApplicationDeploymentProperties deploymentProperties, RunState runningOrDebugging,
        UserInteractions ui, CancelationToken cancelationToken, IProgressMonitor monitor) throws Exception {
    String opName = "Starting application '" + getName() + "' in "
            + (runningOrDebugging == RunState.DEBUGGING ? "DEBUG" : "RUN") + " mode";
    DebugSupport debugSupport = getDebugSupport();

    if (runningOrDebugging == RunState.DEBUGGING) {

        if (debugSupport != null && debugSupport.isSupported(this)) {
            Operation<?> debugOp = debugSupport.createOperation(this, opName, ui, cancelationToken);

            push(deploymentProperties, runningOrDebugging, debugSupport, cancelationToken, ui, monitor);
            debugOp.run(monitor);/*w  ww . j  a v  a2s.c  o  m*/
        } else {
            String title = "Debugging is not supported for '" + getName() + "'";
            String msg = debugSupport.getNotSupportedMessage(this);
            if (msg == null) {
                msg = title;
            }
            ui.errorPopup(title, msg);
            throw ExceptionUtil.coreException(msg);
        }
    } else {
        push(deploymentProperties, runningOrDebugging, debugSupport, cancelationToken, ui, monitor);
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudAppDashElement.java

@Override
public RunState getRunState() {
    RunState state = baseRunState.getValue();
    if (state == RunState.RUNNING) {
        DebugSupport debugSupport = getDebugSupport();
        if (debugSupport.isDebuggerAttached(CloudAppDashElement.this)) {
            //         if (DevtoolsUtil.isDevClientAttached(this, ILaunchManager.DEBUG_MODE)) {
            state = RunState.DEBUGGING;
        }// w  w w  . j a v a 2s  .c  o m
    }
    return state;
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudAppDashElement.java

public void push(CloudApplicationDeploymentProperties deploymentProperties, RunState runningOrDebugging,
        DebugSupport debugSupport, CancelationToken cancelationToken, UserInteractions ui,
        IProgressMonitor monitor) throws Exception {

    boolean isDebugging = runningOrDebugging == RunState.DEBUGGING;
    whileStarting(ui, cancelationToken, monitor, () -> {
        // Refresh app data and check that the application (still) exists in
        // Cloud Foundry
        // This also ensures that the 'diff change dialog' will pick up on
        // the latest changes.
        // TODO: should this refresh be moved closer to the where we
        // actually compute the diff?
        CloudAppDashElement updatedApp = this.refresh();
        if (updatedApp == null) {
            ExceptionUtil.coreException(new Status(IStatus.ERROR, BootDashActivator.PLUGIN_ID,
                    "No Cloud Application found for '" + getName() + "'"));
        }/*from   w w  w. ja va  2s.  c o m*/
        IProject project = getProject();
        if (project == null) {
            ExceptionUtil.coreException(new Status(IStatus.ERROR, BootDashActivator.PLUGIN_ID,
                    "Local project not associated to CF app '" + getName() + "'"));
        }

        checkTerminationRequested(cancelationToken, monitor);

        CloudApplicationDeploymentProperties properties = deploymentProperties == null
                ? getCloudModel().resolveDeploymentProperties(updatedApp, ui, monitor)
                : deploymentProperties;

        // Update JAVA_OPTS env variable with Remote DevTools Client secret
        DevtoolsUtil.setupEnvVarsForRemoteClient(properties.getEnvironmentVariables(),
                DevtoolsUtil.getSecret(project));
        if (debugSupport != null) {
            if (isDebugging) {
                debugSupport.setupEnvVars(properties.getEnvironmentVariables());
            } else {
                debugSupport.clearEnvVars(properties.getEnvironmentVariables());
            }
        }

        checkTerminationRequested(cancelationToken, monitor);

        CFPushArguments pushArgs = properties.toPushArguments(getCloudModel().getCloudDomains(monitor));

        getClient().push(pushArgs, CancelationTokens.merge(cancelationToken, monitor));

        log("Application pushed to Cloud Foundry: " + getName());
    });
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.DevtoolsUtil.java

public static boolean isEnvVarSetupForRemoteClient(Map<String, String> envVars, String secret,
        RunState runOrDebug) {/*from w  w w.  ja v  a  2  s. c om*/
    String javaOpts = envVars.get(JAVA_OPTS_ENV_VAR);
    if (javaOpts.matches("(.*\\s+|^)" + REMOTE_SECRET_JVM_ARG + secret + "(\\s+.*|$)")) {
        if (runOrDebug == RunState.DEBUGGING) {
            return javaOpts.matches("(.*\\s+|^)" + REMOTE_DEBUG_JVM_ARGS + "(\\s+.*|$)");
        } else {
            return !javaOpts.matches("(.*\\s+|^)" + REMOTE_DEBUG_JVM_ARGS + "(\\s+.*|$)");
        }
    }
    return false;
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.DevtoolsUtil.java

public static void setupEnvVarsForRemoteClient(Map<String, String> envVars, String secret,
        RunState runOrDebug) {/*  w  w  w.j a v a  2  s.c  o  m*/
    String javaOpts = clearJavaOpts(envVars.get(JAVA_OPTS_ENV_VAR));
    StringBuilder sb = javaOpts == null ? new StringBuilder() : new StringBuilder(javaOpts);
    if (sb.length() > 0) {
        sb.append(' ');
    }
    sb.append(REMOTE_SECRET_JVM_ARG);
    sb.append(secret);
    if (runOrDebug == RunState.DEBUGGING) {
        sb.append(' ');
        sb.append(REMOTE_DEBUG_JVM_ARGS);
    }
    envVars.put(JAVA_OPTS_ENV_VAR, sb.toString());
}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java

@Test
public void testDeployAppIntoDebugMode() throws Exception {
    harness.createCfTarget(CfTestTargetParams.fromEnv());
    final CloudFoundryBootDashModel model = harness.getCfTargetModel();

    final BootProjectDashElement project = harness
            .getElementFor(projects.createBootProject("to-deploy", withStarters("actuator", "web")));
    final String appName = appHarness.randomAppName();

    harness.answerDeploymentPrompt(ui, appName, appName);
    model.performDeployment(ImmutableSet.of(project.getProject()), ui, RunState.DEBUGGING);

    new ACondition("wait for app '" + appName + "'to be DEBUGGING", APP_DEPLOY_TIMEOUT) {
        public boolean test() throws Exception {
            CloudAppDashElement element = model.getApplication(appName);
            assertEquals(RunState.DEBUGGING, element.getRunState());
            return true;
        }/*  www  .  ja  va  2 s.  c  o  m*/
    };

}