|
|
@ -90,32 +90,38 @@ public class TomcatEmbeddedServletContainer implements EmbeddedWebServer {
|
|
|
|
synchronized (this.monitor) {
|
|
|
|
synchronized (this.monitor) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
addInstanceIdToEngineName();
|
|
|
|
addInstanceIdToEngineName();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// Remove service connectors to that protocol binding doesn't happen
|
|
|
|
|
|
|
|
// yet
|
|
|
|
|
|
|
|
removeServiceConnectors();
|
|
|
|
|
|
|
|
|
|
|
|
// Remove service connectors to that protocol binding doesn't happen yet
|
|
|
|
// Start the server to trigger initialization listeners
|
|
|
|
removeServiceConnectors();
|
|
|
|
this.tomcat.start();
|
|
|
|
|
|
|
|
|
|
|
|
// Start the server to trigger initialization listeners
|
|
|
|
// We can re-throw failure exception directly in the main thread
|
|
|
|
this.tomcat.start();
|
|
|
|
rethrowDeferredStartupExceptions();
|
|
|
|
|
|
|
|
|
|
|
|
// We can re-throw failure exception directly in the main thread
|
|
|
|
Context context = findContext();
|
|
|
|
rethrowDeferredStartupExceptions();
|
|
|
|
try {
|
|
|
|
|
|
|
|
ContextBindings.bindClassLoader(context, context.getNamingToken(),
|
|
|
|
|
|
|
|
getClass().getClassLoader());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (NamingException ex) {
|
|
|
|
|
|
|
|
// Naming is not enabled. Continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Context context = findContext();
|
|
|
|
// Unlike Jetty, all Tomcat threads are daemon threads. We create a
|
|
|
|
try {
|
|
|
|
// blocking non-daemon to stop immediate shutdown
|
|
|
|
ContextBindings.bindClassLoader(context, context.getNamingToken(),
|
|
|
|
startDaemonAwaitThread();
|
|
|
|
getClass().getClassLoader());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NamingException ex) {
|
|
|
|
catch (Exception ex) {
|
|
|
|
// Naming is not enabled. Continue
|
|
|
|
containerCounter.decrementAndGet();
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Unlike Jetty, all Tomcat threads are daemon threads. We create a
|
|
|
|
|
|
|
|
// blocking non-daemon to stop immediate shutdown
|
|
|
|
|
|
|
|
startDaemonAwaitThread();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
catch (Exception ex) {
|
|
|
|
throw new EmbeddedWebServerException(
|
|
|
|
throw new EmbeddedWebServerException("Unable to start embedded Tomcat",
|
|
|
|
"Unable to start embedded Tomcat", ex);
|
|
|
|
ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -279,9 +285,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedWebServer {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void stop() throws EmbeddedWebServerException {
|
|
|
|
public void stop() throws EmbeddedWebServerException {
|
|
|
|
synchronized (this.monitor) {
|
|
|
|
synchronized (this.monitor) {
|
|
|
|
if (!this.started) {
|
|
|
|
boolean wasStarted = this.started;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
this.started = false;
|
|
|
|
this.started = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -293,11 +297,13 @@ public class TomcatEmbeddedServletContainer implements EmbeddedWebServer {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
catch (Exception ex) {
|
|
|
|
throw new EmbeddedWebServerException(
|
|
|
|
throw new EmbeddedWebServerException("Unable to stop embedded Tomcat",
|
|
|
|
"Unable to stop embedded Tomcat", ex);
|
|
|
|
ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
finally {
|
|
|
|
containerCounter.decrementAndGet();
|
|
|
|
if (wasStarted) {
|
|
|
|
|
|
|
|
containerCounter.decrementAndGet();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|