From 933b0d52d53a5daa3ca8fa7511081a8e7c4c978d Mon Sep 17 00:00:00 2001 From: Maxim Solodovnik Date: Wed, 27 Sep 2023 22:44:46 +0700 Subject: [PATCH] [WICKET-7077] no need to re-create global spring context (#665) --- .../spring/SpringWebApplicationFactory.java | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/wicket-spring/src/main/java/org/apache/wicket/spring/SpringWebApplicationFactory.java b/wicket-spring/src/main/java/org/apache/wicket/spring/SpringWebApplicationFactory.java index f5b1476ddc4..4d4da3166b7 100644 --- a/wicket-spring/src/main/java/org/apache/wicket/spring/SpringWebApplicationFactory.java +++ b/wicket-spring/src/main/java/org/apache/wicket/spring/SpringWebApplicationFactory.java @@ -18,7 +18,6 @@ import java.util.Map; -import jakarta.servlet.FilterConfig; import jakarta.servlet.ServletContext; import org.apache.wicket.protocol.http.IWebApplicationFactory; @@ -36,9 +35,9 @@ /** * Implementation of IWebApplicationFactory that pulls the WebApplication object out of spring * application context. - * + * * Configuration example: - * + * *
  * <filter>
  *   <filter-name>MyApplication</filter-name>
@@ -49,12 +48,12 @@
  *   </init-param>
  * </filter>
  * 
- * + * * applicationBean init parameter can be used if there are multiple WebApplications * defined on the spring application context. - * + * * Example: - * + * *
  * <filter>
  *   <filter-name>MyApplication</filter-name>
@@ -69,13 +68,13 @@
  *   </init-param>
  * </filter>
  * 
- * + * *

* This factory is also capable of creating a {@link WebApplication}-specific application context * (path to which is specified via the {@code contextConfigLocation} filter param) and chaining it * to the global one *

- * + * *
  * <filter>
  *   <filter-name>MyApplication</filter-name>
@@ -90,10 +89,10 @@
  *   </init-param>
  * </filter>
  * 
- * + * * @author Igor Vaynberg (ivaynberg) * @author Janne Hietamäki (jannehietamaki) - * + * */ public class SpringWebApplicationFactory implements IWebApplicationFactory { @@ -104,30 +103,19 @@ public class SpringWebApplicationFactory implements IWebApplicationFactory /** * Returns location of context config that will be used to create a {@link WebApplication} * -specific application context. - * + * * @param filter * @return location of context config */ protected final String getContextConfigLocation(final WicketFilter filter) { - String contextConfigLocation; - - final FilterConfig filterConfig = filter.getFilterConfig(); - contextConfigLocation = filterConfig.getInitParameter("contextConfigLocation"); - - if (contextConfigLocation == null) - { - final ServletContext servletContext = filterConfig.getServletContext(); - contextConfigLocation = servletContext.getInitParameter("contextConfigLocation"); - } - - return contextConfigLocation; + return filter.getFilterConfig().getInitParameter("contextConfigLocation"); } /** * Factory method used to create a new instance of the web application context, by default an * instance of {@link XmlWebApplicationContext} will be created. - * + * * @return application context instance */ protected ConfigurableWebApplicationContext newApplicationContext() @@ -191,7 +179,7 @@ private WebApplication createApplication(final ApplicationContext applicationCon /** * Creates and initializes a new {@link WebApplicationContext}, with the given context as the * parent. Based on the logic in Spring's FrameworkServlet#createWebApplicationContext() - * + * * @param parent * parent application context * @param filter @@ -216,7 +204,7 @@ protected final ConfigurableWebApplicationContext createWebApplicationContext( /** * This is a hook for potential subclasses to perform additional processing on the context. * Based on the logic in Spring's FrameworkServlet#postProcessWebApplicationContext() - * + * * @param wac * additional application context * @param filter