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