@Test public void verifySingleConnector() { // Relevant to Tomcat 9.0 assertThat(applicationContext).isInstanceOf(WebServerApplicationContext.class); WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer(); assertThat(webServer).isInstanceOf(TomcatWebServer.class); assertThat(((TomcatWebServer) webServer).getTomcat() .getEngine() .getService() .findConnectors()).hasSize(1); }
private ThreadPool findThreadPool(ApplicationContext applicationContext) { if (applicationContext instanceof WebServerApplicationContext) { WebServer webServer = ((WebServerApplicationContext) applicationContext) .getWebServer(); if (webServer instanceof JettyWebServer) { return ((JettyWebServer) webServer).getServer().getThreadPool(); } } return null; }
private Manager findManager(ApplicationContext applicationContext) { if (applicationContext instanceof WebServerApplicationContext) { WebServer webServer = ((WebServerApplicationContext) applicationContext) .getWebServer(); if (webServer instanceof TomcatWebServer) { Context context = findContext((TomcatWebServer) webServer); return context.getManager(); } } return null; }
@Override public void afterSingletonsInstantiated() { if (this.applicationContext instanceof WebServerApplicationContext && ((WebServerApplicationContext) this.applicationContext) .getWebServer() != null) { ConfigurableWebServerApplicationContext managementContext = this.managementContextFactory .createManagementContext(this.applicationContext, EnableChildManagementContextConfiguration.class, PropertyPlaceholderAutoConfiguration.class); managementContext.setServerNamespace("management"); managementContext.setId(this.applicationContext.getId() + ":management"); setClassLoaderIfPossible(managementContext); CloseManagementContextListener.addIfPossible(this.applicationContext, managementContext); managementContext.refresh(); } else { logger.warn("Could not start embedded management container on " + "different port (management endpoints are still available " + "through JMX)"); } }