Search in sources :

Example 1 with IServerType

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

the class SlingWstServer method before.

@Override
protected void before() throws Throwable {
    IRuntimeType launchpadRuntime = null;
    for (IRuntimeType type : ServerCore.getRuntimeTypes()) {
        if ("org.apache.sling.ide.launchpadRuntimeType".equals(type.getId())) {
            launchpadRuntime = type;
            break;
        }
    }
    if (launchpadRuntime == null) {
        throw new IllegalArgumentException("No runtime of type 'org.apache.sling.ide.launchpadRuntimeType' found");
    }
    IRuntimeWorkingCopy rtwc = launchpadRuntime.createRuntime("temp.sling.launchpad.rt.id", new NullProgressMonitor());
    rtwc.save(true, new NullProgressMonitor());
    IServerType serverType = null;
    for (IServerType type : ServerCore.getServerTypes()) {
        if ("org.apache.sling.ide.launchpadServer".equals(type.getId())) {
            serverType = type;
            break;
        }
    }
    if (serverType == null) {
        throw new IllegalArgumentException("No server type of type 'org.apache.sling.ide.launchpadServer' found");
    }
    IServerWorkingCopy wc = serverType.createServer("temp.sling.launchpad.server.id", null, new NullProgressMonitor());
    wc.setHost(config.getHostname());
    wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, config.getPort());
    wc.setAttribute(ISlingLaunchpadServer.PROP_CONTEXT_PATH, config.getContextPath());
    wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, config.getUsername());
    wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, config.getPassword());
    wc.setAttribute("auto-publish-time", 0);
    server = wc.save(true, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServerType(org.eclipse.wst.server.core.IServerType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 2 with IServerType

use of org.eclipse.wst.server.core.IServerType 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

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