001/*
002 * Copyright 2012-2017 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;
018
019import javax.servlet.ServletContext;
020import javax.servlet.ServletException;
021
022import org.springframework.web.SpringServletContainerInitializer;
023import org.springframework.web.WebApplicationInitializer;
024
025/**
026 * Interface used to configure a Servlet 3.0+ {@link ServletContext context}
027 * programmatically. Unlike {@link WebApplicationInitializer}, classes that implement this
028 * interface (and do not implement {@link WebApplicationInitializer}) will <b>not</b> be
029 * detected by {@link SpringServletContainerInitializer} and hence will not be
030 * automatically bootstrapped by the Servlet container.
031 * <p>
032 * This interface is primarily designed to allow {@link ServletContextInitializer}s to be
033 * managed by Spring and not the Servlet container.
034 * <p>
035 * For configuration examples see {@link WebApplicationInitializer}.
036 *
037 * @author Phillip Webb
038 * @since 1.4.0
039 * @see WebApplicationInitializer
040 */
041@FunctionalInterface
042public interface ServletContextInitializer {
043
044        /**
045         * Configure the given {@link ServletContext} with any servlets, filters, listeners
046         * context-params and attributes necessary for initialization.
047         * @param servletContext the {@code ServletContext} to initialize
048         * @throws ServletException if any call against the given {@code ServletContext}
049         * throws a {@code ServletException}
050         */
051        void onStartup(ServletContext servletContext) throws ServletException;
052
053}