Rename EmbeddedServletContainer -> EmbeddedWebServer

This contract is not specific to servlet containers and should be
reused by all web server implementations (including reactive variants).

Fixes gh-8208
pull/8054/merge
Brian Clozel 8 years ago
parent 457d0414ea
commit 8619d6a229

@ -148,7 +148,7 @@ public class EndpointWebMvcAutoConfiguration
if (managementPort == ManagementServerPort.DIFFERENT) {
if (this.applicationContext instanceof EmbeddedWebApplicationContext
&& ((EmbeddedWebApplicationContext) this.applicationContext)
.getEmbeddedServletContainer() != null) {
.getEmbeddedWebServer() != null) {
createChildManagementContext();
}
else {

@ -44,9 +44,9 @@ import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfigura
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.ErrorPage;
@ -68,7 +68,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
* {@link EmbeddedServletContainer} running on a different port is required.
* {@link EmbeddedWebServer} running on a different port is required.
*
* @author Dave Syer
* @author Stephane Nicoll

@ -28,8 +28,8 @@ import org.apache.catalina.session.ManagerBase;
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@ -58,10 +58,10 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
}
private Manager getManager(EmbeddedWebApplicationContext applicationContext) {
EmbeddedServletContainer embeddedServletContainer = applicationContext
.getEmbeddedServletContainer();
if (embeddedServletContainer instanceof TomcatEmbeddedServletContainer) {
return getManager((TomcatEmbeddedServletContainer) embeddedServletContainer);
EmbeddedWebServer embeddedWebServer = applicationContext
.getEmbeddedWebServer();
if (embeddedWebServer instanceof TomcatEmbeddedServletContainer) {
return getManager((TomcatEmbeddedServletContainer) embeddedWebServer);
}
return null;
}

@ -62,10 +62,10 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfi
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
@ -351,7 +351,7 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.thrown.expect(EmbeddedServletContainerException.class);
this.thrown.expect(EmbeddedWebServerException.class);
this.applicationContext.refresh();
}
finally {
@ -887,7 +887,7 @@ public class EndpointWebMvcAutoConfigurationTests {
private ApplicationContext rootContext;
private EmbeddedServletContainer servletContainer;
private EmbeddedWebServer servletContainer;
GrabManagementPort(ApplicationContext rootContext) {
this.rootContext = rootContext;
@ -900,7 +900,7 @@ public class EndpointWebMvcAutoConfigurationTests {
}
}
public EmbeddedServletContainer getServletContainer() {
public EmbeddedWebServer getServletContainer() {
return this.servletContainer;
}

@ -23,7 +23,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.ExampleServlet;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
@ -66,7 +66,7 @@ public class SkipSslVerificationHttpRequestFactoryTests {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(
0);
factory.setSsl(getSsl("password", "classpath:test.jks"));
EmbeddedServletContainer container = factory.getEmbeddedServletContainer(
EmbeddedWebServer container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
container.start();
return "https://localhost:" + container.getPort() + "/hello";

@ -128,7 +128,7 @@ public class SpringApplicationAdminJmxAutoConfigurationTests {
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
.getEmbeddedWebServer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertThat(actual).isEqualTo(String.valueOf(expected));
}

@ -64,7 +64,7 @@ public class MustacheAutoConfigurationIntegrationTests {
@Before
public void init() {
this.port = this.context.getEmbeddedServletContainer().getPort();
this.port = this.context.getEmbeddedWebServer().getPort();
}
@Test

@ -70,7 +70,7 @@ public class MustacheWebIntegrationTests {
@Before
public void init() {
this.port = this.context.getEmbeddedServletContainer().getPort();
this.port = this.context.getEmbeddedWebServer().getPort();
}
@Test

@ -64,7 +64,7 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
"security.user.password:password");
context.register(Config.class);
context.refresh();
int port = context.getEmbeddedServletContainer().getPort();
int port = context.getEmbeddedWebServer().getPort();
new TestRestTemplate("user", "password")
.getForEntity("http://localhost:" + port, Object.class);
// If early initialization occurred a ConverterNotFoundException is thrown

@ -399,7 +399,7 @@ public class OAuth2AutoConfigurationTests {
private void verifyAuthentication(ClientDetails config, HttpStatus finalStatus) {
String baseUrl = "http://localhost:"
+ this.context.getEmbeddedServletContainer().getPort();
+ this.context.getEmbeddedWebServer().getPort();
TestRestTemplate rest = new TestRestTemplate();
// First, verify the web endpoint can't be reached
assertEndpointUnauthorized(baseUrl, rest);

@ -22,8 +22,8 @@ import javax.servlet.ServletContextListener;
import org.junit.Test;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
@ -36,7 +36,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link EmbeddedServletContainer}s driving {@link ServletContextListener}s
* Tests for {@link EmbeddedWebServer}s driving {@link ServletContextListener}s
* correctly
*
* @author Andy Wilkinson

@ -139,7 +139,7 @@ public class MultipartAutoConfigurationTests {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithEverythingTomcat.class, BaseConfiguration.class);
new RestTemplate().getForObject("http://localhost:"
+ this.context.getEmbeddedServletContainer().getPort() + "/",
+ this.context.getEmbeddedWebServer().getPort() + "/",
String.class);
this.context.getBean(MultipartConfigElement.class);
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
@ -208,7 +208,7 @@ public class MultipartAutoConfigurationTests {
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
ClientHttpRequest request = requestFactory.createRequest(
new URI("http://localhost:"
+ this.context.getEmbeddedServletContainer().getPort() + "/"),
+ this.context.getEmbeddedWebServer().getPort() + "/"),
HttpMethod.GET);
ClientHttpResponse response = request.execute();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
@ -217,7 +217,7 @@ public class MultipartAutoConfigurationTests {
private void verifyServletWorks() {
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:"
+ this.context.getEmbeddedServletContainer().getPort() + "/";
+ this.context.getEmbeddedWebServer().getPort() + "/";
assertThat(restTemplate.getForObject(url, String.class)).isEqualTo("Hello");
}

@ -16,7 +16,7 @@ class Example implements CommandLineRunner {
}
void run(String... args) {
def port = context.embeddedServletContainer.port;
def port = context.embeddedWebServer.port;
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
print "Hello " + world
}

@ -246,7 +246,7 @@ public class LocalDevToolsAutoConfigurationTests {
public void devToolsSwitchesJspServletToDevelopmentMode() {
this.context = initializeAndRun(Config.class);
TomcatEmbeddedServletContainer tomcatContainer = (TomcatEmbeddedServletContainer) ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer();
.getEmbeddedWebServer();
Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils

@ -571,7 +571,7 @@ To scan for a free port (using OS natives to prevent clashes) use `server.port=0
[[howto-discover-the-http-port-at-runtime]]
=== Discover the HTTP port at runtime
You can access the port the server is running on from log output or from the
`EmbeddedWebApplicationContext` via its `EmbeddedServletContainer`. The best way to get
`EmbeddedWebApplicationContext` via its `EmbeddedWebServer`. The best way to get
that and be sure that it has initialized is to add a `@Bean` of type
`ApplicationListener<EmbeddedServletContainerInitializedEvent>` and pull the container
out of the event when it is published.

@ -41,7 +41,7 @@ public class TomcatLegacyCookieProcessorExampleTests {
EmbeddedWebApplicationContext applicationContext = (EmbeddedWebApplicationContext) new SpringApplication(
TestConfiguration.class, LegacyCookieProcessorConfiguration.class).run();
Context context = (Context) ((TomcatEmbeddedServletContainer) applicationContext
.getEmbeddedServletContainer()).getTomcat().getHost().findChildren()[0];
.getEmbeddedWebServer()).getTomcat().getHost().findChildren()[0];
assertThat(context.getCookieProcessor())
.isInstanceOf(LegacyCookieProcessor.class);
}

@ -90,7 +90,7 @@ public class SampleTomcatApplicationTests {
public void testTimeout() throws Exception {
EmbeddedWebApplicationContext context = (EmbeddedWebApplicationContext) this.applicationContext;
TomcatEmbeddedServletContainer embeddedServletContainer = (TomcatEmbeddedServletContainer) context
.getEmbeddedServletContainer();
.getEmbeddedWebServer();
ProtocolHandler protocolHandler = embeddedServletContainer.getTomcat()
.getConnector().getProtocolHandler();
int timeout = ((AbstractProtocol<?>) protocolHandler).getConnectionTimeout();

@ -184,7 +184,7 @@ public abstract class AbstractEmbeddedServletContainerFactory
return tempDir;
}
catch (IOException ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to create tempDir. java.io.tmpdir is set to "
+ System.getProperty("java.io.tmpdir"),
ex);

@ -23,12 +23,12 @@ import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletCon
import org.springframework.boot.web.servlet.ServletContextInitializer;
/**
* Factory interface that can be used to create {@link EmbeddedServletContainer}s.
* Factory interface that can be used to create {@link EmbeddedWebServer}s.
* Implementations are encouraged to extend
* {@link AbstractEmbeddedServletContainerFactory} when possible.
*
* @author Phillip Webb
* @see EmbeddedServletContainer
* @see EmbeddedWebServer
* @see AbstractEmbeddedServletContainerFactory
* @see JettyEmbeddedServletContainerFactory
* @see TomcatEmbeddedServletContainerFactory
@ -37,16 +37,16 @@ import org.springframework.boot.web.servlet.ServletContextInitializer;
public interface EmbeddedServletContainerFactory {
/**
* Gets a new fully configured but paused {@link EmbeddedServletContainer} instance.
* Gets a new fully configured but paused {@link EmbeddedWebServer} instance.
* Clients should not be able to connect to the returned server until
* {@link EmbeddedServletContainer#start()} is called (which happens when the
* {@link EmbeddedWebServer#start()} is called (which happens when the
* {@link ApplicationContext} has been fully refreshed).
* @param initializers {@link ServletContextInitializer}s that should be applied as
* the container starts
* @return a fully configured and started {@link EmbeddedServletContainer}
* @see EmbeddedServletContainer#stop()
* @return a fully configured and started {@link EmbeddedWebServer}
* @see EmbeddedWebServer#stop()
*/
EmbeddedServletContainer getEmbeddedServletContainer(
EmbeddedWebServer getEmbeddedServletContainer(
ServletContextInitializer... initializers);
}

@ -20,7 +20,7 @@ import org.springframework.context.ApplicationEvent;
/**
* Event to be published after the context is refreshed and the
* {@link EmbeddedServletContainer} is ready. Useful for obtaining the local port of a
* {@link EmbeddedWebServer} is ready. Useful for obtaining the local port of a
* running server. Normally it will have been started, but listeners are free to inspect
* the server and stop and start it if they want to.
*
@ -33,26 +33,26 @@ public class EmbeddedServletContainerInitializedEvent extends ApplicationEvent {
public EmbeddedServletContainerInitializedEvent(
EmbeddedWebApplicationContext applicationContext,
EmbeddedServletContainer source) {
EmbeddedWebServer source) {
super(source);
this.applicationContext = applicationContext;
}
/**
* Access the {@link EmbeddedServletContainer}.
* Access the {@link EmbeddedWebServer}.
* @return the embedded servlet container
*/
public EmbeddedServletContainer getEmbeddedServletContainer() {
public EmbeddedWebServer getEmbeddedServletContainer() {
return getSource();
}
/**
* Access the source of the event (an {@link EmbeddedServletContainer}).
* Access the source of the event (an {@link EmbeddedWebServer}).
* @return the embedded servlet container
*/
@Override
public EmbeddedServletContainer getSource() {
return (EmbeddedServletContainer) super.getSource();
public EmbeddedWebServer getSource() {
return (EmbeddedWebServer) super.getSource();
}
/**

@ -57,7 +57,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
* A {@link WebApplicationContext} that can be used to bootstrap itself from a contained
* {@link EmbeddedServletContainerFactory} bean.
* <p>
* This context will create, initialize and run an {@link EmbeddedServletContainer} by
* This context will create, initialize and run an {@link EmbeddedWebServer} by
* searching for a single {@link EmbeddedServletContainerFactory} bean within the
* {@link ApplicationContext} itself. The {@link EmbeddedServletContainerFactory} is free
* to use standard Spring concepts (such as dependency injection, lifecycle callbacks and
@ -99,7 +99,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
*/
public static final String DISPATCHER_SERVLET_NAME = "dispatcherServlet";
private volatile EmbeddedServletContainer embeddedServletContainer;
private volatile EmbeddedWebServer embeddedWebServer;
private ServletConfig servletConfig;
@ -142,7 +142,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
@Override
protected void finishRefresh() {
super.finishRefresh();
EmbeddedServletContainer localContainer = startEmbeddedServletContainer();
EmbeddedWebServer localContainer = startEmbeddedServletContainer();
if (localContainer != null) {
publishEvent(
new EmbeddedServletContainerInitializedEvent(this, localContainer));
@ -156,11 +156,11 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
}
private void createEmbeddedServletContainer() {
EmbeddedServletContainer localContainer = this.embeddedServletContainer;
EmbeddedWebServer localContainer = this.embeddedWebServer;
ServletContext localServletContext = getServletContext();
if (localContainer == null && localServletContext == null) {
EmbeddedServletContainerFactory containerFactory = getEmbeddedServletContainerFactory();
this.embeddedServletContainer = containerFactory
this.embeddedWebServer = containerFactory
.getEmbeddedServletContainer(getSelfInitializer());
}
else if (localServletContext != null) {
@ -291,8 +291,8 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
}
}
private EmbeddedServletContainer startEmbeddedServletContainer() {
EmbeddedServletContainer localContainer = this.embeddedServletContainer;
private EmbeddedWebServer startEmbeddedServletContainer() {
EmbeddedWebServer localContainer = this.embeddedWebServer;
if (localContainer != null) {
localContainer.start();
}
@ -300,11 +300,11 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
}
private void stopAndReleaseEmbeddedServletContainer() {
EmbeddedServletContainer localContainer = this.embeddedServletContainer;
EmbeddedWebServer localContainer = this.embeddedWebServer;
if (localContainer != null) {
try {
localContainer.stop();
this.embeddedServletContainer = null;
this.embeddedWebServer = null;
}
catch (Exception ex) {
throw new IllegalStateException(ex);
@ -341,12 +341,12 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
}
/**
* Returns the {@link EmbeddedServletContainer} that was created by the context or
* Returns the {@link EmbeddedWebServer} that was created by the context or
* {@code null} if the container has not yet been created.
* @return the embedded servlet container
*/
public EmbeddedServletContainer getEmbeddedServletContainer() {
return this.embeddedServletContainer;
public EmbeddedWebServer getEmbeddedWebServer() {
return this.embeddedWebServer;
}
/**

@ -17,8 +17,8 @@
package org.springframework.boot.context.embedded;
/**
* Simple interface that represents a fully configured embedded servlet container (for
* example Tomcat or Jetty). Allows the container to be {@link #start() started} and
* Simple interface that represents a fully configured embedded web server (for
* example Tomcat or Jetty). Allows the server to be {@link #start() started} and
* {@link #stop() stopped}.
* <p>
* Instances of this class are usually obtained via a
@ -28,21 +28,21 @@ package org.springframework.boot.context.embedded;
* @author Dave Syer
* @see EmbeddedServletContainerFactory
*/
public interface EmbeddedServletContainer {
public interface EmbeddedWebServer {
/**
* Starts the embedded servlet container. Calling this method on an already started
* container has no effect.
* @throws EmbeddedServletContainerException if the container cannot be started
* @throws EmbeddedWebServerException if the container cannot be started
*/
void start() throws EmbeddedServletContainerException;
void start() throws EmbeddedWebServerException;
/**
* Stops the embedded servlet container. Calling this method on an already stopped
* container has no effect.
* @throws EmbeddedServletContainerException if the container cannot be stopped
* @throws EmbeddedWebServerException if the container cannot be stopped
*/
void stop() throws EmbeddedServletContainerException;
void stop() throws EmbeddedWebServerException;
/**
* Return the port this server is listening on.

@ -22,9 +22,9 @@ package org.springframework.boot.context.embedded;
* @author Phillip Webb
*/
@SuppressWarnings("serial")
public class EmbeddedServletContainerException extends RuntimeException {
public class EmbeddedWebServerException extends RuntimeException {
public EmbeddedServletContainerException(String message, Throwable cause) {
public EmbeddedWebServerException(String message, Throwable cause) {
super(message, cause);
}

@ -23,7 +23,7 @@ package org.springframework.boot.context.embedded;
* @author Andy Wilkinson
* @since 1.4.0
*/
public class PortInUseException extends EmbeddedServletContainerException {
public class PortInUseException extends EmbeddedWebServerException {
private final int port;

@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
/**
* {@link ApplicationContextInitializer} that sets {@link Environment} properties for the
* ports that {@link EmbeddedServletContainer} servers are actually listening on. The
* ports that {@link EmbeddedWebServer} servers are actually listening on. The
* property {@literal "local.server.port"} can be injected directly into tests using
* {@link Value @Value} or obtained via the {@link Environment}.
* <p>

@ -19,7 +19,7 @@ package org.springframework.boot.context.embedded;
import java.security.KeyStore;
/**
* Interface to provide SSL key stores for an {@link EmbeddedServletContainer} to use. Can
* Interface to provide SSL key stores for an {@link EmbeddedWebServer} to use. Can
* be used when file based key stores cannot be used.
*
* @author Phillip Webb

@ -28,15 +28,15 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.PortInUseException;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link EmbeddedServletContainer} that can be used to control an embedded Jetty server.
* {@link EmbeddedWebServer} that can be used to control an embedded Jetty server.
* Usually this class should be created using the
* {@link JettyEmbeddedServletContainerFactory} and not directly.
*
@ -46,7 +46,7 @@ import org.springframework.util.StringUtils;
* @author Eddú Meléndez
* @see JettyEmbeddedServletContainerFactory
*/
public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
public class JettyEmbeddedServletContainer implements EmbeddedWebServer {
private static final Log logger = LogFactory
.getLog(JettyEmbeddedServletContainer.class);
@ -96,7 +96,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
catch (Exception ex) {
// Ensure process isn't left running
stopSilently();
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to start embedded Jetty servlet container", ex);
}
}
@ -112,7 +112,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
}
@Override
public void start() throws EmbeddedServletContainerException {
public void start() throws EmbeddedWebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
@ -143,11 +143,11 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
JettyEmbeddedServletContainer.logger
.info("Jetty started on port(s) " + getActualPortsDescription());
}
catch (EmbeddedServletContainerException ex) {
catch (EmbeddedWebServerException ex) {
throw ex;
}
catch (Exception ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to start embedded Jetty servlet container", ex);
}
}
@ -216,7 +216,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
Thread.currentThread().interrupt();
}
catch (Exception ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to stop embedded Jetty servlet container", ex);
}
}

@ -65,9 +65,9 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.Compression;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.MimeMappings;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.embedded.Ssl.ClientAuth;
@ -149,7 +149,7 @@ public class JettyEmbeddedServletContainerFactory
}
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
public EmbeddedWebServer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
int port = (getPort() >= 0 ? getPort() : 0);
@ -291,7 +291,7 @@ public class JettyEmbeddedServletContainerFactory
factory.setKeyStoreResource(Resource.newResource(url));
}
catch (IOException ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Could not find key store '" + ssl.getKeyStore() + "'", ex);
}
if (ssl.getKeyStoreType() != null) {
@ -312,7 +312,7 @@ public class JettyEmbeddedServletContainerFactory
factory.setTrustStoreResource(Resource.newResource(url));
}
catch (IOException ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Could not find trust store '" + ssl.getTrustStore() + "'", ex);
}
}

@ -16,7 +16,7 @@
/**
* Support for Jetty
* {@link org.springframework.boot.context.embedded.EmbeddedServletContainer
* {@link org.springframework.boot.context.embedded.EmbeddedWebServer
* EmbeddedServletContainers}.
*
* @see org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory

@ -18,7 +18,7 @@ package org.springframework.boot.context.embedded.tomcat;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
/**
* A {@code ConnectorStartFailedException} is thrown when a Tomcat {@link Connector} fails
@ -27,7 +27,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerExcepti
* @author Andy Wilkinson
* @since 1.4.1
*/
public class ConnectorStartFailedException extends EmbeddedServletContainerException {
public class ConnectorStartFailedException extends EmbeddedWebServerException {
private final int port;

@ -34,12 +34,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.naming.ContextBindings;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.util.Assert;
/**
* {@link EmbeddedServletContainer} that can be used to control an embedded Tomcat server.
* {@link EmbeddedWebServer} that can be used to control an embedded Tomcat server.
* Usually this class should be created using the
* {@link TomcatEmbeddedServletContainerFactory} and not directly.
*
@ -47,7 +47,7 @@ import org.springframework.util.Assert;
* @author Dave Syer
* @see TomcatEmbeddedServletContainerFactory
*/
public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer {
public class TomcatEmbeddedServletContainer implements EmbeddedWebServer {
private static final Log logger = LogFactory
.getLog(TomcatEmbeddedServletContainer.class);
@ -84,7 +84,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
initialize();
}
private void initialize() throws EmbeddedServletContainerException {
private void initialize() throws EmbeddedWebServerException {
TomcatEmbeddedServletContainer.logger
.info("Tomcat initialized with port(s): " + getPortsDescription(false));
synchronized (this.monitor) {
@ -114,7 +114,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
startDaemonAwaitThread();
}
catch (Exception ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to start embedded Tomcat", ex);
}
}
@ -175,7 +175,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
}
@Override
public void start() throws EmbeddedServletContainerException {
public void start() throws EmbeddedWebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
@ -196,7 +196,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
throw ex;
}
catch (Exception ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to start embedded Tomcat servlet container", ex);
}
finally {
@ -267,7 +267,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
}
catch (Exception ex) {
TomcatEmbeddedServletContainer.logger.error("Cannot start connector: ", ex);
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to start embedded Tomcat connectors", ex);
}
}
@ -277,7 +277,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
}
@Override
public void stop() throws EmbeddedServletContainerException {
public void stop() throws EmbeddedWebServerException {
synchronized (this.monitor) {
if (!this.started) {
return;
@ -293,7 +293,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
}
}
catch (Exception ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to stop embedded Tomcat", ex);
}
finally {

@ -57,9 +57,9 @@ import org.apache.tomcat.util.net.SSLHostConfig;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.Compression;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.MimeMappings;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.embedded.Ssl.ClientAuth;
@ -156,7 +156,7 @@ public class TomcatEmbeddedServletContainerFactory
}
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
public EmbeddedWebServer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
Tomcat tomcat = new Tomcat();
File baseDir = (this.baseDirectory != null ? this.baseDirectory
@ -414,7 +414,7 @@ public class TomcatEmbeddedServletContainerFactory
protocol.setKeystoreFile(ResourceUtils.getURL(ssl.getKeyStore()).toString());
}
catch (FileNotFoundException ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Could not load key store: " + ex.getMessage(), ex);
}
if (ssl.getKeyStoreType() != null) {
@ -433,7 +433,7 @@ public class TomcatEmbeddedServletContainerFactory
ResourceUtils.getURL(ssl.getTrustStore()).toString());
}
catch (FileNotFoundException ex) {
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Could not load trust store: " + ex.getMessage(), ex);
}
}

@ -16,7 +16,7 @@
/**
* Support for Tomcat
* {@link org.springframework.boot.context.embedded.EmbeddedServletContainer
* {@link org.springframework.boot.context.embedded.EmbeddedWebServer
* EmbeddedServletContainers}.
*
* @see org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory

@ -44,8 +44,8 @@ import org.apache.commons.logging.LogFactory;
import org.xnio.channels.BoundChannel;
import org.springframework.boot.context.embedded.Compression;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.PortInUseException;
import org.springframework.http.HttpHeaders;
import org.springframework.util.MimeType;
@ -54,7 +54,7 @@ import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link EmbeddedServletContainer} that can be used to control an embedded Undertow
* {@link EmbeddedWebServer} that can be used to control an embedded Undertow
* server. Typically this class should be created using
* {@link UndertowEmbeddedServletContainerFactory} and not directly.
*
@ -65,7 +65,7 @@ import org.springframework.util.StringUtils;
* @since 1.2.0
* @see UndertowEmbeddedServletContainerFactory
*/
public class UndertowEmbeddedServletContainer implements EmbeddedServletContainer {
public class UndertowEmbeddedServletContainer implements EmbeddedWebServer {
private static final Log logger = LogFactory
.getLog(UndertowEmbeddedServletContainer.class);
@ -142,7 +142,7 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
}
@Override
public void start() throws EmbeddedServletContainerException {
public void start() throws EmbeddedWebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
@ -169,7 +169,7 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
failedPorts.iterator().next().getNumber());
}
}
throw new EmbeddedServletContainerException(
throw new EmbeddedWebServerException(
"Unable to start embedded Undertow", ex);
}
}
@ -306,7 +306,7 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
}
@Override
public void stop() throws EmbeddedServletContainerException {
public void stop() throws EmbeddedWebServerException {
synchronized (this.monitor) {
if (!this.started) {
return;
@ -317,7 +317,7 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
this.undertow.stop();
}
catch (Exception ex) {
throw new EmbeddedServletContainerException("Unable to stop undertow",
throw new EmbeddedWebServerException("Unable to stop undertow",
ex);
}
}

@ -67,8 +67,8 @@ import org.xnio.Xnio;
import org.xnio.XnioWorker;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.MimeMappings.Mapping;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.embedded.Ssl.ClientAuth;
@ -219,7 +219,7 @@ public class UndertowEmbeddedServletContainerFactory
}
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
public EmbeddedWebServer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
DeploymentManager manager = createDeploymentManager(initializers);
int port = getPort();

@ -16,7 +16,7 @@
/**
* Support for Undertow
* {@link org.springframework.boot.context.embedded.EmbeddedServletContainer
* {@link org.springframework.boot.context.embedded.EmbeddedWebServer
* EmbeddedServletContainers}.
*
* @see org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory

@ -128,7 +128,7 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
@Rule
public InternalOutputCapture output = new InternalOutputCapture();
protected EmbeddedServletContainer container;
protected EmbeddedWebServer container;
private final HttpClientContext httpClientContext = HttpClientContext.create();

@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link EmbeddedWebApplicationContext} and
* {@link EmbeddedServletContainer}s running Spring MVC.
* {@link EmbeddedWebServer}s running Spring MVC.
*
* @author Phillip Webb
* @author Ivan Sopov
@ -98,7 +98,7 @@ public class EmbeddedServletContainerMvcIntegrationTests {
SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
ClientHttpRequest request = clientHttpRequestFactory.createRequest(
new URI("http://localhost:"
+ context.getEmbeddedServletContainer().getPort() + resourcePath),
+ context.getEmbeddedWebServer().getPort() + resourcePath),
HttpMethod.GET);
ClientHttpResponse response = request.execute();
try {

@ -55,7 +55,7 @@ public class MockEmbeddedServletContainerFactory
private MockEmbeddedServletContainer container;
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
public EmbeddedWebServer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
this.container = spy(new MockEmbeddedServletContainer(
mergeInitializers(initializers), getPort()));
@ -80,7 +80,7 @@ public class MockEmbeddedServletContainerFactory
: getContainer().getRegisteredFilters().get(index);
}
public static class MockEmbeddedServletContainer implements EmbeddedServletContainer {
public static class MockEmbeddedServletContainer implements EmbeddedWebServer {
private ServletContext servletContext;
@ -167,7 +167,7 @@ public class MockEmbeddedServletContainerFactory
}
@Override
public void start() throws EmbeddedServletContainerException {
public void start() throws EmbeddedWebServerException {
}
@Override

@ -50,7 +50,7 @@ import org.mockito.InOrder;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactoryTests;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.testutil.InternalOutputCapture;
import org.springframework.test.util.ReflectionTestUtils;
@ -335,7 +335,7 @@ public class TomcatEmbeddedServletContainerFactoryTests
TomcatEmbeddedServletContainerFactoryTests.this.container.start();
fail();
}
catch (EmbeddedServletContainerException ex) {
catch (EmbeddedWebServerException ex) {
// Ignore
}
}

@ -27,9 +27,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;
@ -120,7 +120,7 @@ public class EmbeddedServerPortFileWriterTests {
private EmbeddedServletContainerInitializedEvent mockEvent(String name, int port) {
EmbeddedWebApplicationContext applicationContext = mock(
EmbeddedWebApplicationContext.class);
EmbeddedServletContainer source = mock(EmbeddedServletContainer.class);
EmbeddedWebServer source = mock(EmbeddedWebServer.class);
given(applicationContext.getNamespace()).willReturn(name);
given(source.getPort()).willReturn(port);
EmbeddedServletContainerInitializedEvent event = new EmbeddedServletContainerInitializedEvent(

@ -93,7 +93,7 @@ public class ErrorPageFilterIntegrationTests {
private void doTest(AnnotationConfigEmbeddedWebApplicationContext context,
String resourcePath, HttpStatus status) throws Exception {
int port = context.getEmbeddedServletContainer().getPort();
int port = context.getEmbeddedWebServer().getPort();
RestTemplate template = new RestTemplate();
ResponseEntity<String> entity = template.getForEntity(
new URI("http://localhost:" + port + resourcePath), String.class);

Loading…
Cancel
Save