001/*
002 * Copyright 2002-2014 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 *      https://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.web.context;
018
019import javax.servlet.ServletConfig;
020import javax.servlet.ServletContext;
021
022import org.springframework.context.ConfigurableApplicationContext;
023
024/**
025 * Interface to be implemented by configurable web application contexts.
026 * Supported by {@link ContextLoader} and
027 * {@link org.springframework.web.servlet.FrameworkServlet}.
028 *
029 * <p>Note: The setters of this interface need to be called before an
030 * invocation of the {@link #refresh} method inherited from
031 * {@link org.springframework.context.ConfigurableApplicationContext}.
032 * They do not cause an initialization of the context on their own.
033 *
034 * @author Juergen Hoeller
035 * @since 05.12.2003
036 * @see #refresh
037 * @see ContextLoader#createWebApplicationContext
038 * @see org.springframework.web.servlet.FrameworkServlet#createWebApplicationContext
039 */
040public interface ConfigurableWebApplicationContext extends WebApplicationContext, ConfigurableApplicationContext {
041
042        /**
043         * Prefix for ApplicationContext ids that refer to context path and/or servlet name.
044         */
045        String APPLICATION_CONTEXT_ID_PREFIX = WebApplicationContext.class.getName() + ":";
046
047        /**
048         * Name of the ServletConfig environment bean in the factory.
049         * @see javax.servlet.ServletConfig
050         */
051        String SERVLET_CONFIG_BEAN_NAME = "servletConfig";
052
053
054        /**
055         * Set the ServletContext for this web application context.
056         * <p>Does not cause an initialization of the context: refresh needs to be
057         * called after the setting of all configuration properties.
058         * @see #refresh()
059         */
060        void setServletContext(ServletContext servletContext);
061
062        /**
063         * Set the ServletConfig for this web application context.
064         * Only called for a WebApplicationContext that belongs to a specific Servlet.
065         * @see #refresh()
066         */
067        void setServletConfig(ServletConfig servletConfig);
068
069        /**
070         * Return the ServletConfig for this web application context, if any.
071         */
072        ServletConfig getServletConfig();
073
074        /**
075         * Set the namespace for this web application context,
076         * to be used for building a default context config location.
077         * The root web application context does not have a namespace.
078         */
079        void setNamespace(String namespace);
080
081        /**
082         * Return the namespace for this web application context, if any.
083         */
084        String getNamespace();
085
086        /**
087         * Set the config locations for this web application context in init-param style,
088         * i.e. with distinct locations separated by commas, semicolons or whitespace.
089         * <p>If not set, the implementation is supposed to use a default for the
090         * given namespace or the root web application context, as appropriate.
091         */
092        void setConfigLocation(String configLocation);
093
094        /**
095         * Set the config locations for this web application context.
096         * <p>If not set, the implementation is supposed to use a default for the
097         * given namespace or the root web application context, as appropriate.
098         */
099        void setConfigLocations(String... configLocations);
100
101        /**
102         * Return the config locations for this web application context,
103         * or {@code null} if none specified.
104         */
105        String[] getConfigLocations();
106
107}