/** * Factory method called to create the {@link TomcatWebServer}. Subclasses can * override this method to return a different {@link TomcatWebServer} or apply * additional processing to the Tomcat server. * @param tomcat the Tomcat server. * @return a new {@link TomcatWebServer} instance */ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) { return new TomcatWebServer(tomcat, getPort() >= 0); }
/** * Factory method called to create the {@link TomcatWebServer}. Subclasses can * override this method to return a different {@link TomcatWebServer} or apply * additional processing to the Tomcat server. * @param tomcat the Tomcat server. * @return a new {@link TomcatWebServer} instance */ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) { return new TomcatWebServer(tomcat, getPort() >= 0); }
private Class<?> doLoadClass(String name) throws ClassNotFoundException { checkPackageAccess(name); if ((this.delegate || filter(name, true))) { Class<?> result = loadFromParent(name); return (result != null) ? result : findClassIgnoringNotFound(name); } Class<?> result = findClassIgnoringNotFound(name); return (result != null) ? result : loadFromParent(name); }
private void customizeSsl(Connector connector) { new SslConnectorCustomizer(getSsl(), getSslStoreProvider()).customize(connector); if (getHttp2() != null && getHttp2().isEnabled()) { connector.addUpgradeProtocol(new Http2Protocol()); } }
private void customizeSsl(Connector connector) { new SslConnectorCustomizer(getSsl(), getSslStoreProvider()).customize(connector); if (getHttp2() != null && getHttp2().isEnabled()) { connector.addUpgradeProtocol(new Http2Protocol()); } }
@Override public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { synchronized (getClassLoadingLock(name)) { Class<?> result = findExistingLoadedClass(name); result = (result != null) ? result : doLoadClass(name); if (result == null) { throw new ClassNotFoundException(name); } return resolveIfNecessary(result, resolve); } }
/** * Configure the Tomcat {@link Context}. * @param context the Tomcat context */ protected void configureContext(Context context) { this.contextLifecycleListeners.forEach(context::addLifecycleListener); new DisableReferenceClearingContextCustomizer().customize(context); this.tomcatContextCustomizers .forEach((customizer) -> customizer.customize(context)); }
@Override public void customize(TomcatServletWebServerFactory factory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("html", "text/html;charset=utf-8"); factory.setMimeMappings(mappings ); }
private Class<?> findExistingLoadedClass(String name) { Class<?> resultClass = findLoadedClass0(name); resultClass = (resultClass != null) ? resultClass : findLoadedClass(name); return resultClass; }
private void addLocaleMappings(TomcatEmbeddedContext context) { getLocaleCharsetMappings() .forEach((locale, charset) -> context.addLocaleEncodingMappingParameter( locale.toString(), charset.toString())); }
private void stopSilently() { try { stopTomcat(); } catch (LifecycleException ex) { // Ignore } }
private Class<?> resolveIfNecessary(Class<?> resultClass, boolean resolve) { if (resolve) { resolveClass(resultClass); } return (resultClass); }
private Class<?> findClassIgnoringNotFound(String name) { try { return findClass(name); } catch (ClassNotFoundException ex) { return null; } }
@Override protected void startInternal() throws LifecycleException { setState(LifecycleState.STARTING); }
/** * Create a new {@link TomcatWebServer} instance. * @param tomcat the underlying Tomcat server * @param autoStart if the server should be started */ public TomcatWebServer(Tomcat tomcat, boolean autoStart) { Assert.notNull(tomcat, "Tomcat Server must not be null"); this.tomcat = tomcat; this.autoStart = autoStart; initialize(); }
private void customizeProtocol(AbstractProtocol<?> protocol) { if (getAddress() != null) { protocol.setAddress(getAddress()); } }
@Override protected FailureAnalysis analyze(Throwable rootFailure, ConnectorStartFailedException cause) { return new FailureAnalysis( "The Tomcat connector configured to listen on port " + cause.getPort() + " failed to start. The port may already be in use or the" + " connector may be misconfigured.", "Verify the connector's configuration, identify and stop any process " + "that's listening on port " + cause.getPort() + ", or configure this application to listen on another port.", cause); }
private void customizeProtocol(AbstractProtocol<?> protocol) { if (getAddress() != null) { protocol.setAddress(getAddress()); } }
@Override protected WebResourceSet createMainResourceSet() { return new LoaderHidingWebResourceSet(super.createMainResourceSet()); }
TomcatErrorPage(ErrorPage errorPage) { this.location = errorPage.getPath(); this.exceptionType = errorPage.getExceptionName(); this.errorCode = errorPage.getStatusCode(); this.nativePage = createNativePage(); }