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());
}
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));
}
}
}
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;
}
Aggregations