Search in sources :

Example 81 with IServer

use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.

the class CDK3LaunchController method launch.

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    final IServer s = ServerUtil.getServer(configuration);
    if (s == null) {
        throw new CoreException(CDKCoreActivator.statusFactory().errorStatus("Unable to locate server from launch configuration."));
    }
    final ControllableServerBehavior beh = (ControllableServerBehavior) JBossServerBehaviorUtils.getControllableBehavior(configuration);
    beh.setServerStarting();
    String minishiftLoc = MinishiftBinaryUtility.getMinishiftLocation(s);
    if (minishiftLoc == null || !(new File(minishiftLoc).exists())) {
        beh.setServerStopped();
        if (minishiftLoc == null)
            throw new CoreException(CDKCoreActivator.statusFactory().errorStatus("Unable to locate minishift command. Please set a correct value in the server editor."));
        throw new CoreException(CDKCoreActivator.statusFactory().errorStatus("Expected location of minishift command does not exist: " + minishiftLoc + "\nPlease set a correct value in the server editor."));
    }
    CDKServer cdkServer = (CDKServer) s.loadAdapter(CDKServer.class, new NullProgressMonitor());
    boolean passCredentials = cdkServer.passCredentials();
    boolean skipReg = cdkServer.skipRegistration();
    if (passCredentials && !skipReg) {
        handleCredentialsDuringLaunch(s, cdkServer, beh);
    }
    // Poll the server once more
    IStatus stat = getCDKPoller(s).getCurrentStateSynchronous(s);
    if (stat.isOK()) {
        beh.setServerStarted();
        ((Server) beh.getServer()).setMode("run");
        return;
    }
    String args = configuration.getAttribute(ATTR_ARGS, (String) null);
    // Add listener first
    IDebugEventSetListener debug = getDebugListener(launch);
    DebugPlugin.getDefault().addDebugEventListener(debug);
    beh.putSharedData(AbstractStartJavaServerLaunchDelegate.DEBUG_LISTENER, debug);
    Process p = null;
    try {
        CDKServer cdk = (CDKServer) getServer().loadAdapter(CDKServer.class, new NullProgressMonitor());
        p = new CDKLaunchUtility().callMinishiftConsole(s, args, getStartupLaunchName(s), cdk.skipRegistration());
    } catch (IOException ioe) {
        CDKCoreActivator.pluginLog().logError(ioe);
        beh.setServerStopped();
        DebugPlugin.getDefault().removeDebugEventListener(debug);
        throw new CoreException(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, ioe.getMessage(), ioe));
    }
    if (p == null) {
        beh.setServerStopped();
        DebugPlugin.getDefault().removeDebugEventListener(debug);
        throw new CoreException(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, "Call to minishift up has failed."));
    }
    IProcess process = addProcessToLaunch(p, launch, s, false, minishiftLoc);
    beh.putSharedData(AbstractStartJavaServerLaunchDelegate.PROCESS, process);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IStatus(org.eclipse.core.runtime.IStatus) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer) Server(org.eclipse.wst.server.core.internal.Server) CDK3Server(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDK3Server) IServer(org.eclipse.wst.server.core.IServer) CDK32Server(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDK32Server) IProcess(org.eclipse.debug.core.model.IProcess) IOException(java.io.IOException) IDebugEventSetListener(org.eclipse.debug.core.IDebugEventSetListener) CoreException(org.eclipse.core.runtime.CoreException) ControllableServerBehavior(org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior) File(java.io.File) IProcess(org.eclipse.debug.core.model.IProcess) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 82 with IServer

use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.

the class CDKLaunchController method launch.

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    final IServer s = ServerUtil.getServer(configuration);
    verifyServer(s);
    final ControllableServerBehavior beh = (ControllableServerBehavior) JBossServerBehaviorUtils.getControllableBehavior(configuration);
    beh.setServerStarting();
    String vagrantLoc = VagrantBinaryUtility.getVagrantLocation(s);
    if (vagrantLoc == null || !(new File(vagrantLoc).exists())) {
        beh.setServerStopped();
        if (vagrantLoc == null)
            throw new CoreException(CDKCoreActivator.statusFactory().errorStatus("Unable to locate vagrant command. Please check the server's launch configuration on the 'Environment' tab to ensure that the command is available on your Path environment variable."));
        throw new CoreException(CDKCoreActivator.statusFactory().errorStatus("Expected location of vagrant command does not exist: " + vagrantLoc));
    }
    CDKServer cdkServer = (CDKServer) s.loadAdapter(CDKServer.class, new NullProgressMonitor());
    boolean passCredentials = cdkServer.passCredentials();
    boolean skipReg = cdkServer.skipRegistration();
    if (passCredentials && !skipReg) {
        setBehaviourUserAndPassword(s, beh, cdkServer);
    }
    // Poll the server once more
    IStatus stat = getCDKPoller(s).getCurrentStateSynchronous(s);
    if (stat.isOK()) {
        beh.setServerStarted();
        ((Server) beh.getServer()).setMode(ILaunchManager.RUN_MODE);
        return;
    }
    String args = configuration.getAttribute(ATTR_ARGS, (String) null);
    CDKServer cdk = (CDKServer) getServer().loadAdapter(CDKServer.class, new NullProgressMonitor());
    Process p = getProcess(s, beh, args, cdk.skipRegistration());
    if (p == null) {
        beh.setServerStopped();
        throw new CoreException(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, "Call to vagrant up has failed."));
    }
    IProcess process = addProcessToLaunch(p, launch, s, true);
    IDebugEventSetListener debug = getDebugListener(new IProcess[] { process }, launch);
    DebugPlugin.getDefault().addDebugEventListener(debug);
    beh.putSharedData(AbstractStartJavaServerLaunchDelegate.PROCESS, process);
    beh.putSharedData(AbstractStartJavaServerLaunchDelegate.DEBUG_LISTENER, debug);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IStatus(org.eclipse.core.runtime.IStatus) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer) Server(org.eclipse.wst.server.core.internal.Server) IServer(org.eclipse.wst.server.core.IServer) IProcess(org.eclipse.debug.core.model.IProcess) IDebugEventSetListener(org.eclipse.debug.core.IDebugEventSetListener) CoreException(org.eclipse.core.runtime.CoreException) ControllableServerBehavior(org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior) IControllableServerBehavior(org.jboss.ide.eclipse.as.wtp.core.server.behavior.IControllableServerBehavior) File(java.io.File) IProcess(org.eclipse.debug.core.model.IProcess) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 83 with IServer

use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.

the class CDKLaunchController method initialize.

public void initialize(ILaunchConfigurationWorkingCopy wc) throws CoreException {
    final IServer s = ServerUtil.getServer(wc);
    final CDKServer cdkServer = (CDKServer) s.loadAdapter(CDKServer.class, new NullProgressMonitor());
    // for testing purposes.
    // we can't mock final methods like getServer(), so we need to be creative
    initialize(wc, cdkServer.getUsername(), cdkServer.getServer());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 84 with IServer

use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.

the class OpenShiftPublishController method publishStart.

@Override
public void publishStart(final IProgressMonitor monitor) throws CoreException {
    this.syncDownFailed = false;
    IServer server = getServer();
    this.rsync = createRsync(server, monitor);
    final File localDirectory = getLocalFolder();
    final MultiStatus status = new MultiStatus(OpenShiftCoreActivator.PLUGIN_ID, 0, NLS.bind("Error while publishing server {0}.  Could not sync all pods to folder {1}", server.getName(), localDirectory.getAbsolutePath()), null);
    rsync.syncPodsToDirectory(localDirectory, status, ServerConsoleModel.getDefault().getConsoleWriter());
    if (!status.isOK()) {
        handleSyncDownFailure(status);
    }
    final IProject deployProject = OpenShiftServerUtils.checkedGetDeployProject(server);
    // If the magic project is *also* a module on the server, do nothing
    if (!modulesIncludesMagicProject(getServer(), deployProject)) {
        publishModule(monitor, deployProject, localDirectory);
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) MultiStatus(org.eclipse.core.runtime.MultiStatus) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 85 with IServer

use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.

the class OpenShiftLaunchController method createDebugContext.

protected DebugContext createDebugContext(OpenShiftServerBehaviour beh, IProgressMonitor monitor) {
    monitor.subTask("Initialising debugging...");
    DockerImageLabels imageLabels = getDockerImageLabels(beh, monitor);
    IServer server = beh.getServer();
    String devmodeKey = StringUtils.defaultIfBlank(OpenShiftServerUtils.getDevmodeKey(server), imageLabels.getDevmodeKey());
    String debugPortKey = StringUtils.defaultIfBlank(OpenShiftServerUtils.getDebugPortKey(server), imageLabels.getDevmodePortKey());
    String debugPort = StringUtils.defaultIfBlank(OpenShiftServerUtils.getDebugPort(server), imageLabels.getDevmodePortValue());
    return new DebugContext(beh.getServer(), devmodeKey, debugPortKey, debugPort);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) DebugContext(org.jboss.tools.openshift.internal.core.server.debug.DebugContext) DockerImageLabels(org.jboss.tools.openshift.core.server.DockerImageLabels)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8