Polish
This commit is contained in:
@@ -154,9 +154,8 @@ public class JettyWebServer implements WebServer {
|
||||
}
|
||||
}
|
||||
this.started = true;
|
||||
JettyWebServer.logger
|
||||
.info("Jetty started on port(s) " + getActualPortsDescription()
|
||||
+ " with context path '" + getContextPath() + "'");
|
||||
logger.info("Jetty started on port(s) " + getActualPortsDescription()
|
||||
+ " with context path '" + getContextPath() + "'");
|
||||
}
|
||||
catch (WebServerException ex) {
|
||||
stopSilently();
|
||||
@@ -188,8 +187,7 @@ public class JettyWebServer implements WebServer {
|
||||
connector);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
JettyWebServer.logger
|
||||
.info("could not determine port ( " + ex.getMessage() + ")");
|
||||
logger.info("could not determine port ( " + ex.getMessage() + ")");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class NettyWebServer implements WebServer {
|
||||
}
|
||||
throw new WebServerException("Unable to start Netty", ex);
|
||||
}
|
||||
NettyWebServer.logger.info("Netty started on port(s): " + getPort());
|
||||
logger.info("Netty started on port(s): " + getPort());
|
||||
startDaemonAwaitThread(this.disposableServer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,19 +51,26 @@ class TomcatEmbeddedContext extends StandardContext {
|
||||
}
|
||||
|
||||
public void deferredLoadOnStartup() throws LifecycleException {
|
||||
// Some older Servlet frameworks (e.g. Struts, BIRT) use the Thread context class
|
||||
// loader to create servlet instances in this phase. If they do that and then try
|
||||
// to initialize them later the class loader may have changed, so wrap the call to
|
||||
// loadOnStartup in what we think its going to be the main webapp classloader at
|
||||
// runtime.
|
||||
ClassLoader classLoader = getLoader().getClassLoader();
|
||||
ClassLoader existingLoader = null;
|
||||
if (classLoader != null) {
|
||||
existingLoader = ClassUtils.overrideThreadContextClassLoader(classLoader);
|
||||
}
|
||||
try {
|
||||
doWithThreadContextClassLoader(getLoader().getClassLoader(), () -> {
|
||||
boolean started = super.loadOnStartup(findChildren());
|
||||
Assert.state(started, "Unable to start embedded tomcat context " + getName());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Some older Servlet frameworks (e.g. Struts, BIRT) use the Thread context class
|
||||
* loader to create servlet instances in this phase. If they do that and then try to
|
||||
* initialize them later the class loader may have changed, so wrap the call to
|
||||
* loadOnStartup in what we think its going to be the main webapp classloader at
|
||||
* runtime.
|
||||
* @param classLoader the class loader to use
|
||||
* @param code the code to run
|
||||
*/
|
||||
private void doWithThreadContextClassLoader(ClassLoader classLoader, Runnable code) {
|
||||
ClassLoader existingLoader = (classLoader != null)
|
||||
? ClassUtils.overrideThreadContextClassLoader(classLoader) : null;
|
||||
try {
|
||||
code.run();
|
||||
}
|
||||
finally {
|
||||
if (existingLoader != null) {
|
||||
|
||||
@@ -87,8 +87,7 @@ public class TomcatWebServer implements WebServer {
|
||||
}
|
||||
|
||||
private void initialize() throws WebServerException {
|
||||
TomcatWebServer.logger
|
||||
.info("Tomcat initialized with port(s): " + getPortsDescription(false));
|
||||
logger.info("Tomcat initialized with port(s): " + getPortsDescription(false));
|
||||
synchronized (this.monitor) {
|
||||
try {
|
||||
addInstanceIdToEngineName();
|
||||
@@ -202,9 +201,8 @@ public class TomcatWebServer implements WebServer {
|
||||
}
|
||||
checkThatConnectorsHaveStarted();
|
||||
this.started = true;
|
||||
TomcatWebServer.logger
|
||||
.info("Tomcat started on port(s): " + getPortsDescription(true)
|
||||
+ " with context path '" + getContextPath() + "'");
|
||||
logger.info("Tomcat started on port(s): " + getPortsDescription(true)
|
||||
+ " with context path '" + getContextPath() + "'");
|
||||
}
|
||||
catch (ConnectorStartFailedException ex) {
|
||||
stopSilently();
|
||||
@@ -273,7 +271,7 @@ public class TomcatWebServer implements WebServer {
|
||||
connector.getProtocolHandler().stop();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
TomcatWebServer.logger.error("Cannot pause connector: ", ex);
|
||||
logger.error("Cannot pause connector: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +284,7 @@ public class TomcatWebServer implements WebServer {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
TomcatWebServer.logger.error("Cannot start connector: ", ex);
|
||||
logger.error("Cannot start connector: ", ex);
|
||||
throw new WebServerException("Unable to start embedded Tomcat connectors",
|
||||
ex);
|
||||
}
|
||||
|
||||
@@ -101,8 +101,7 @@ public class UndertowWebServer implements WebServer {
|
||||
}
|
||||
this.undertow.start();
|
||||
this.started = true;
|
||||
UndertowWebServer.logger
|
||||
.info("Undertow started on port(s) " + getPortsDescription());
|
||||
logger.info("Undertow started on port(s) " + getPortsDescription());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user