Search in sources :

Example 6 with IServerWorkingCopy

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

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

Example 8 with IServerWorkingCopy

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

the class SlingLaunchpadConfiguration method workingCopy.

private IServerWorkingCopy workingCopy() {
    IServerWorkingCopy workingCopy = server.getServerWorkingCopy();
    server.getServer().createWorkingCopy();
    if (workingCopy == null)
        workingCopy = server.getServer().createWorkingCopy();
    return workingCopy;
}
Also used : IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy)

Aggregations

IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)8 CoreException (org.eclipse.core.runtime.CoreException)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IModule (org.eclipse.wst.server.core.IModule)2 IServer (org.eclipse.wst.server.core.IServer)2 IServerType (org.eclipse.wst.server.core.IServerType)2 LinkedList (java.util.LinkedList)1 IProject (org.eclipse.core.resources.IProject)1 IStatus (org.eclipse.core.runtime.IStatus)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