parent
60afbdc868
commit
f76479fb99
|
|
@ -17,7 +17,9 @@
|
|||
package org.springframework.boot.web.embedded.jetty;
|
||||
|
||||
import java.net.BindException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
@ -25,6 +27,7 @@ import org.eclipse.jetty.server.Connector;
|
|||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
|
|
@ -44,6 +47,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author David Liu
|
||||
* @author Eddú Meléndez
|
||||
* @author Brian Clozel
|
||||
* @author Kristine Jetzke
|
||||
* @since 2.0.0
|
||||
* @see JettyReactiveWebServerFactory
|
||||
*/
|
||||
|
|
@ -151,7 +155,8 @@ public class JettyWebServer implements WebServer {
|
|||
}
|
||||
this.started = true;
|
||||
JettyWebServer.logger
|
||||
.info("Jetty started on port(s) " + getActualPortsDescription());
|
||||
.info("Jetty started on port(s) " + getActualPortsDescription()
|
||||
+ " with context path " + getContextPath());
|
||||
}
|
||||
catch (WebServerException ex) {
|
||||
throw ex;
|
||||
|
|
@ -190,6 +195,13 @@ public class JettyWebServer implements WebServer {
|
|||
return " (" + StringUtils.collectionToDelimitedString(protocols, ", ") + ")";
|
||||
}
|
||||
|
||||
private String getContextPath() {
|
||||
return Arrays.stream(this.server.getHandlers())
|
||||
.filter(ContextHandler.class::isInstance)
|
||||
.map(handler -> ((ContextHandler) handler).getContextPath())
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private void handleDeferredInitialize(Handler... handlers) throws Exception {
|
||||
for (Handler handler : handlers) {
|
||||
if (handler instanceof JettyEmbeddedWebAppContext) {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@
|
|||
|
||||
package org.springframework.boot.web.embedded.tomcat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
|
|
@ -43,6 +45,7 @@ import org.springframework.util.Assert;
|
|||
* should be created using the {@link TomcatReactiveWebServerFactory} and not directly.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Kristine Jetzke
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class TomcatWebServer implements WebServer {
|
||||
|
|
@ -191,7 +194,8 @@ public class TomcatWebServer implements WebServer {
|
|||
checkThatConnectorsHaveStarted();
|
||||
this.started = true;
|
||||
TomcatWebServer.logger
|
||||
.info("Tomcat started on port(s): " + getPortsDescription(true));
|
||||
.info("Tomcat started on port(s): " + getPortsDescription(true)
|
||||
+ " with context path " + getContextPath());
|
||||
}
|
||||
catch (ConnectorStartFailedException ex) {
|
||||
stopSilently();
|
||||
|
|
@ -322,6 +326,13 @@ public class TomcatWebServer implements WebServer {
|
|||
return 0;
|
||||
}
|
||||
|
||||
private String getContextPath() {
|
||||
return Arrays.stream(this.tomcat.getHost().findChildren())
|
||||
.filter(TomcatEmbeddedContext.class::isInstance)
|
||||
.map(context -> ((TomcatEmbeddedContext) context).getPath())
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns access to the underlying Tomcat server.
|
||||
* @return the Tomcat server
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author Andy Wilkinson
|
||||
* @author Eddú Meléndez
|
||||
* @author Christoph Dreis
|
||||
* @author Kristine Jetzke
|
||||
* @since 2.0.0
|
||||
* @see UndertowServletWebServerFactory
|
||||
*/
|
||||
|
|
@ -156,7 +157,8 @@ public class UndertowServletWebServer implements WebServer {
|
|||
this.undertow.start();
|
||||
this.started = true;
|
||||
UndertowServletWebServer.logger
|
||||
.info("Undertow started on port(s) " + getPortsDescription());
|
||||
.info("Undertow started on port(s) " + getPortsDescription()
|
||||
+ " with context path " + this.contextPath);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue