Search in sources :

Example 1 with IRuntime

use of org.eclipse.wst.server.core.IRuntime in project sling by apache.

the class SetupServerWizardPage method getOrCreateServer.

/**
     * Gets or creates a <tt>IServer</tt> instance to deploy projects on
     * 
     * @param monitor
     * @return the server instance, possibly null if the user requested to skip deployment
     * @throws CoreException
     */
public IServer getOrCreateServer(IProgressMonitor monitor) throws CoreException {
    if (skipServerConfiguration.getSelection()) {
        return null;
    }
    if (server != null) {
        return server;
    }
    if (useExistingServer.getSelection()) {
        return existingServerCombo.getServer();
    } else {
        IServerType serverType = ServerCore.findServerType(SERVER_TYPE_LAUNCHPAD);
        IRuntime slingRuntime = getOrCreateSlingRuntime(monitor);
        try {
            // TODO there should be a nicer API for creating this
            IServerWorkingCopy wc = serverType.createServer(null, null, slingRuntime, monitor);
            wc.setHost(getHostname());
            wc.setName(newServerName.getText());
            wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, getPort());
            wc.setAttribute(ISlingLaunchpadServer.PROP_DEBUG_PORT, Integer.parseInt(newServerDebugPort.getText()));
            wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, newServerUsername.getText());
            wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, newServerPassword.getText());
            SlingLaunchpadConfigurationDefaults.applyDefaultValues(wc);
            wc.setRuntime(slingRuntime);
            server = wc.save(true, monitor);
            return server;
        } catch (CoreException e) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed creating the new server instance", e));
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) IServerType(org.eclipse.wst.server.core.IServerType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntime(org.eclipse.wst.server.core.IRuntime)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1 IServerType (org.eclipse.wst.server.core.IServerType)1 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)1