try {
// TODO there should be a nicer API for creating this, and also a central place for defaults
// TODO - we should not be creating runtimes, but maybe matching against existing ones
IRuntime runtime = serverRuntime.createRuntime(null, monitor);
runtime = runtime.createWorkingCopy().save(true, monitor);
IServerWorkingCopy wc = serverType.createServer(null, null, runtime, 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_INSTALL_LOCALLY, installToolingSupportBundle.getSelection());
wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, newServerUsername.getText());
wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, newServerPassword.getText());
wc.setAttribute("auto-publish-time", 0);
if (finalVersion != null) {
wc.setAttribute(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT,
EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME), finalVersion.toString());
}
wc.setRuntime(runtime);
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));