|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -39,23 +39,24 @@ import org.springframework.web.context.ServletContextAware; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Subclass of {@link GenericApplicationContext}, suitable for web environments. |
|
|
|
* Subclass of {@link GenericApplicationContext}, suitable for web environments. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Implements {@link org.springframework.web.context.ConfigurableWebApplicationContext}, |
|
|
|
* <p>Implements {@link ConfigurableWebApplicationContext}, but is not intended for |
|
|
|
* but is not intended for declarative setup in {@code web.xml}. Instead, it is designed |
|
|
|
* declarative setup in {@code web.xml}. Instead, it is designed for programmatic setup, |
|
|
|
* for programmatic setup, for example for building nested contexts or for use within |
|
|
|
* for example for building nested contexts or for use within |
|
|
|
* {@link org.springframework.web.WebApplicationInitializer WebApplicationInitializers}. |
|
|
|
* {@link org.springframework.web.WebApplicationInitializer WebApplicationInitializers}. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p><b>If you intend to implement a WebApplicationContext that reads bean definitions |
|
|
|
|
|
|
|
* from configuration files, consider deriving from AbstractRefreshableWebApplicationContext, |
|
|
|
|
|
|
|
* reading the bean definitions in an implementation of the {@code loadBeanDefinitions} |
|
|
|
|
|
|
|
* method.</b> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>Interprets resource paths as servlet context resources, i.e. as paths beneath |
|
|
|
* <p>Interprets resource paths as servlet context resources, i.e. as paths beneath |
|
|
|
* the web application root. Absolute paths, e.g. for files outside the web app root, |
|
|
|
* the web application root. Absolute paths — for example, for files outside |
|
|
|
* can be accessed via "file:" URLs, as implemented by AbstractApplicationContext. |
|
|
|
* the web app root — can be accessed via {@code file:} URLs, as implemented |
|
|
|
|
|
|
|
* by {@code AbstractApplicationContext}. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>In addition to the special beans detected by |
|
|
|
* <p>In addition to the special beans detected by |
|
|
|
* {@link org.springframework.context.support.AbstractApplicationContext}, |
|
|
|
* {@link org.springframework.context.support.AbstractApplicationContext AbstractApplicationContext}, |
|
|
|
* this class detects a ThemeSource bean in the context, with the name "themeSource". |
|
|
|
* this class detects a {@link ThemeSource} bean in the context, with the name "themeSource". |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>If you intend to implement a {@code WebApplicationContext} that reads bean definitions |
|
|
|
|
|
|
|
* from configuration files, consider deriving from {@link AbstractRefreshableWebApplicationContext}, |
|
|
|
|
|
|
|
* reading the bean definitions in an implementation of the {@code loadBeanDefinitions} |
|
|
|
|
|
|
|
* method. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Chris Beams |
|
|
|
* @author Chris Beams |
|
|
@ -72,7 +73,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new GenericWebApplicationContext. |
|
|
|
* Create a new {@code GenericWebApplicationContext}. |
|
|
|
* @see #setServletContext |
|
|
|
* @see #setServletContext |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #refresh |
|
|
|
* @see #refresh |
|
|
@ -82,8 +83,8 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new GenericWebApplicationContext for the given ServletContext. |
|
|
|
* Create a new {@code GenericWebApplicationContext} for the given {@link ServletContext}. |
|
|
|
* @param servletContext the ServletContext to run in |
|
|
|
* @param servletContext the {@code ServletContext} to run in |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #refresh |
|
|
|
* @see #refresh |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -92,8 +93,8 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new GenericWebApplicationContext with the given DefaultListableBeanFactory. |
|
|
|
* Create a new {@code GenericWebApplicationContext} with the given {@link DefaultListableBeanFactory}. |
|
|
|
* @param beanFactory the DefaultListableBeanFactory instance to use for this context |
|
|
|
* @param beanFactory the {@code DefaultListableBeanFactory} instance to use for this context |
|
|
|
* @see #setServletContext |
|
|
|
* @see #setServletContext |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #refresh |
|
|
|
* @see #refresh |
|
|
@ -103,9 +104,10 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new GenericWebApplicationContext with the given DefaultListableBeanFactory. |
|
|
|
* Create a new {@code GenericWebApplicationContext} with the given {@link DefaultListableBeanFactory} |
|
|
|
* @param beanFactory the DefaultListableBeanFactory instance to use for this context |
|
|
|
* and {@link ServletContext}. |
|
|
|
* @param servletContext the ServletContext to run in |
|
|
|
* @param beanFactory the {@code DefaultListableBeanFactory} instance to use for this context |
|
|
|
|
|
|
|
* @param servletContext the {@code ServletContext} to run in |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #registerBeanDefinition |
|
|
|
* @see #refresh |
|
|
|
* @see #refresh |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -116,7 +118,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the ServletContext that this WebApplicationContext runs in. |
|
|
|
* Set the {@link ServletContext} that this {@code WebApplicationContext} runs in. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setServletContext(@Nullable ServletContext servletContext) { |
|
|
|
public void setServletContext(@Nullable ServletContext servletContext) { |
|
|
@ -143,8 +145,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Register ServletContextAwareProcessor. |
|
|
|
* Register request/session scopes, environment beans, a {@link ServletContextAwareProcessor}, etc. |
|
|
|
* @see ServletContextAwareProcessor |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { |
|
|
|
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { |
|
|
@ -157,7 +158,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This implementation supports file paths beneath the root of the ServletContext. |
|
|
|
* This implementation supports file paths beneath the root of the {@link ServletContext}. |
|
|
|
* @see ServletContextResource |
|
|
|
* @see ServletContextResource |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -236,7 +237,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
if (StringUtils.hasText(configLocation)) { |
|
|
|
if (StringUtils.hasText(configLocation)) { |
|
|
|
throw new UnsupportedOperationException( |
|
|
|
throw new UnsupportedOperationException( |
|
|
|
"GenericWebApplicationContext does not support setConfigLocation(). " + |
|
|
|
"GenericWebApplicationContext does not support setConfigLocation(). " + |
|
|
|
"Do you still have an 'contextConfigLocations' init-param set?"); |
|
|
|
"Do you still have a 'contextConfigLocation' init-param set?"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -245,7 +246,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext |
|
|
|
if (!ObjectUtils.isEmpty(configLocations)) { |
|
|
|
if (!ObjectUtils.isEmpty(configLocations)) { |
|
|
|
throw new UnsupportedOperationException( |
|
|
|
throw new UnsupportedOperationException( |
|
|
|
"GenericWebApplicationContext does not support setConfigLocations(). " + |
|
|
|
"GenericWebApplicationContext does not support setConfigLocations(). " + |
|
|
|
"Do you still have an 'contextConfigLocations' init-param set?"); |
|
|
|
"Do you still have a 'contextConfigLocations' init-param set?"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|