001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.web.servlet.server;
018
019import java.io.File;
020import java.nio.charset.Charset;
021import java.util.List;
022import java.util.Locale;
023import java.util.Map;
024
025import javax.servlet.ServletContext;
026
027import org.springframework.boot.web.server.ConfigurableWebServerFactory;
028import org.springframework.boot.web.server.MimeMappings;
029import org.springframework.boot.web.server.WebServerFactoryCustomizer;
030import org.springframework.boot.web.servlet.ServletContextInitializer;
031
032/**
033 * A configurable {@link ServletWebServerFactory}.
034 *
035 * @author Dave Syer
036 * @author Andy Wilkinson
037 * @author Stephane Nicoll
038 * @author EddĂș MelĂ©ndez
039 * @author Brian Clozel
040 * @since 2.0.0
041 * @see ServletWebServerFactory
042 * @see WebServerFactoryCustomizer
043 */
044public interface ConfigurableServletWebServerFactory
045                extends ConfigurableWebServerFactory, ServletWebServerFactory {
046
047        /**
048         * Sets the context path for the web server. The context should start with a "/"
049         * character but not end with a "/" character. The default context path can be
050         * specified using an empty string.
051         * @param contextPath the contextPath to set
052         */
053        void setContextPath(String contextPath);
054
055        /**
056         * Sets the display name of the application deployed in the web server.
057         * @param displayName the displayName to set
058         * @since 1.3.0
059         */
060        void setDisplayName(String displayName);
061
062        /**
063         * Sets the configuration that will be applied to the container's HTTP session
064         * support.
065         * @param session the session configuration
066         */
067        void setSession(Session session);
068
069        /**
070         * Set if the DefaultServlet should be registered. Defaults to {@code true} so that
071         * files from the {@link #setDocumentRoot(File) document root} will be served.
072         * @param registerDefaultServlet if the default servlet should be registered
073         */
074        void setRegisterDefaultServlet(boolean registerDefaultServlet);
075
076        /**
077         * Sets the mime-type mappings.
078         * @param mimeMappings the mime type mappings (defaults to
079         * {@link MimeMappings#DEFAULT})
080         */
081        void setMimeMappings(MimeMappings mimeMappings);
082
083        /**
084         * Sets the document root directory which will be used by the web context to serve
085         * static files.
086         * @param documentRoot the document root or {@code null} if not required
087         */
088        void setDocumentRoot(File documentRoot);
089
090        /**
091         * Sets {@link ServletContextInitializer} that should be applied in addition to
092         * {@link ServletWebServerFactory#getWebServer(ServletContextInitializer...)}
093         * parameters. This method will replace any previously set or added initializers.
094         * @param initializers the initializers to set
095         * @see #addInitializers
096         */
097        void setInitializers(List<? extends ServletContextInitializer> initializers);
098
099        /**
100         * Add {@link ServletContextInitializer}s to those that should be applied in addition
101         * to {@link ServletWebServerFactory#getWebServer(ServletContextInitializer...)}
102         * parameters.
103         * @param initializers the initializers to add
104         * @see #setInitializers
105         */
106        void addInitializers(ServletContextInitializer... initializers);
107
108        /**
109         * Sets the configuration that will be applied to the server's JSP servlet.
110         * @param jsp the JSP servlet configuration
111         */
112        void setJsp(Jsp jsp);
113
114        /**
115         * Sets the Locale to Charset mappings.
116         * @param localeCharsetMappings the Locale to Charset mappings
117         */
118        void setLocaleCharsetMappings(Map<Locale, Charset> localeCharsetMappings);
119
120        /**
121         * Sets the init parameters that are applied to the container's
122         * {@link ServletContext}.
123         * @param initParameters the init parameters
124         */
125        void setInitParameters(Map<String, String> initParameters);
126
127}