Search in sources :

Example 1 with AbstractConfiguration

use of org.eclipse.jetty.webapp.AbstractConfiguration in project spring-boot by spring-projects.

the class JettyServletWebServerFactoryTests method errorHandlerCanBeOverridden.

@Test
void errorHandlerCanBeOverridden() {
    JettyServletWebServerFactory factory = getFactory();
    factory.addConfigurations(new AbstractConfiguration() {

        @Override
        public void configure(WebAppContext context) throws Exception {
            context.setErrorHandler(new CustomErrorHandler());
        }
    });
    JettyWebServer jettyWebServer = (JettyWebServer) factory.getWebServer();
    WebAppContext context = findWebAppContext(jettyWebServer);
    assertThat(context.getErrorHandler()).isInstanceOf(CustomErrorHandler.class);
}
Also used : AbstractConfiguration(org.eclipse.jetty.webapp.AbstractConfiguration) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) PortInUseException(org.springframework.boot.web.server.PortInUseException) WebServerException(org.springframework.boot.web.server.WebServerException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractConfiguration

use of org.eclipse.jetty.webapp.AbstractConfiguration in project spring-boot by spring-projects.

the class JettyServletWebServerFactory method getErrorPageConfiguration.

/**
	 * Create a configuration object that adds error handlers.
	 * @return a configuration object for adding error pages
	 */
private Configuration getErrorPageConfiguration() {
    return new AbstractConfiguration() {

        @Override
        public void configure(WebAppContext context) throws Exception {
            ErrorHandler errorHandler = context.getErrorHandler();
            context.setErrorHandler(new JettyEmbeddedErrorHandler(errorHandler));
            addJettyErrorPages(errorHandler, getErrorPages());
        }
    };
}
Also used : AbstractConfiguration(org.eclipse.jetty.webapp.AbstractConfiguration) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) ErrorHandler(org.eclipse.jetty.server.handler.ErrorHandler) ErrorPageErrorHandler(org.eclipse.jetty.servlet.ErrorPageErrorHandler)

Aggregations

AbstractConfiguration (org.eclipse.jetty.webapp.AbstractConfiguration)2 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)2 ExecutionException (java.util.concurrent.ExecutionException)1 HttpHostConnectException (org.apache.http.conn.HttpHostConnectException)1 ErrorHandler (org.eclipse.jetty.server.handler.ErrorHandler)1 ErrorPageErrorHandler (org.eclipse.jetty.servlet.ErrorPageErrorHandler)1 Test (org.junit.jupiter.api.Test)1 PortInUseException (org.springframework.boot.web.server.PortInUseException)1 WebServerException (org.springframework.boot.web.server.WebServerException)1