use of org.gradle.api.plugins.jetty.internal.JettyPluginServer in project gradle by gradle.
the class AbstractJettyRunTask method startJettyInternal.
public void startJettyInternal() {
ProgressLoggerFactory progressLoggerFactory = getServices().get(ProgressLoggerFactory.class);
ProgressLogger progressLogger = progressLoggerFactory.newOperation(AbstractJettyRunTask.class).start("Start Jetty server", "Starting Jetty");
try {
setServer(createServer());
applyJettyXml();
JettyPluginServer plugin = getServer();
Object[] configuredConnectors = getConnectors();
plugin.setConnectors(configuredConnectors);
Object[] connectors = plugin.getConnectors();
if (connectors == null || connectors.length == 0) {
configuredConnectors = new Object[] { plugin.createDefaultConnector(getHttpPort()) };
plugin.setConnectors(configuredConnectors);
}
//set up a RequestLog if one is provided
if (getRequestLog() != null) {
getServer().setRequestLog(getRequestLog());
}
//set up the webapp and any context provided
getServer().configureHandlers();
configureWebApplication();
getServer().addWebApplication(webAppConfig);
// set up security realms
Object[] configuredRealms = getUserRealms();
for (int i = 0; (configuredRealms != null) && i < configuredRealms.length; i++) {
LOGGER.debug(configuredRealms[i].getClass().getName() + ": " + configuredRealms[i].toString());
}
plugin.setUserRealms(configuredRealms);
//do any other configuration required by the
//particular Jetty version
finishConfigurationBeforeStart();
// start Jetty
server.start();
if (getStopPort() != null && getStopPort() > 0 && getStopKey() != null) {
Monitor monitor = new Monitor(getStopPort(), getStopKey(), (Server) server.getProxiedObject());
monitor.start();
}
if (daemon) {
return;
}
// start the scanner thread (if necessary) on the main webapp
configureScanner();
startScanner();
// start the new line scanner thread if necessary
startConsoleScanner();
} catch (Exception e) {
throw new GradleException("Could not start the Jetty server.", e);
} finally {
progressLogger.completed();
}
progressLogger = progressLoggerFactory.newOperation(AbstractJettyRunTask.class).start("Run Jetty at http://localhost:" + getHttpPort() + "/" + getContextPath(), "Running at http://localhost:" + getHttpPort() + "/" + getContextPath());
try {
// keep the thread going if not in daemon mode
server.join();
} catch (Exception e) {
throw new GradleException("Failed to wait for the Jetty server to stop.", e);
} finally {
progressLogger.completed();
}
}
Aggregations